Zero  0.1.0
alloc_cache.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2011-2013, Hewlett-Packard Development Company, LP
3  */
4 
5 #ifndef __ALLOC_CACHE_H
6 #define __ALLOC_CACHE_H
7 
8 #include "w_defines.h"
9 #include "alloc_page.h"
10 #include "latch.h"
11 #include "stnode_page.h"
12 #include <map>
13 #include <vector>
14 #include <unordered_set>
15 
16 class bf_fixed_m;
17 
28 public:
29  alloc_cache_t(stnode_cache_t& stcache, bool virgin, bool clustered);
30 
37  rc_t sx_allocate_page(PageID& pid, StoreID stid = 0);
38 
44 
49  rc_t sx_format_alloc_page(PageID alloc_pid);
50 
51  bool is_allocated(PageID pid);
52 
55 
58 
60 
62 
63  static constexpr size_t extent_size = alloc_page::bits_held;
64 
65  static bool is_alloc_pid(PageID pid) {
66  return pid % extent_size == 0;
67  }
68 
69 private:
70 
90  std::vector<PageID> last_alloc_page;
91 
93 
95  mutable srwlock_t _latch;
96 
99 };
100 
101 #endif // __ALLOC_CACHE_H
static bool is_alloc_pid(PageID pid)
Definition: alloc_cache.h:65
stnode_cache_t & stcache
Definition: alloc_cache.h:92
PageID get_last_allocated_pid() const
Returns last allocated PID of ALL stores.
Definition: alloc_cache.cpp:57
srwlock_t _latch
Definition: alloc_cache.h:95
PageID _get_last_allocated_pid_internal() const
Definition: alloc_cache.cpp:62
rc_t sx_deallocate_page(PageID pid)
Definition: alloc_cache.cpp:158
static constexpr size_t extent_size
Definition: alloc_cache.h:63
uint32_t StoreID
Definition: basics.h:47
uint32_t extent_id_t
Definition: alloc_page.h:12
uint32_t PageID
Definition: basics.h:45
Log Sequence Number. See Log Sequence Numbers (LSN).
Definition: lsn.h:243
std::vector< PageID > last_alloc_page
Definition: alloc_cache.h:90
Store creation/destroy/query interface.
Definition: stnode_page.h:137
Return code for most functions and methods.
Definition: w_rc.h:87
lsn_t get_page_lsn(PageID pid)
rc_t load_alloc_page(StoreID stid, extent_id_t ext)
Definition: alloc_cache.cpp:37
Free-Page allocation/deallocation interface.
Definition: alloc_cache.h:27
rc_t sx_allocate_page(PageID &pid, StoreID stid=0)
Definition: alloc_cache.cpp:83
alloc_cache_t(stnode_cache_t &stcache, bool virgin, bool clustered)
Definition: alloc_cache.cpp:13
static constexpr int bits_held
Definition: alloc_page.h:46
rc_t sx_format_alloc_page(PageID alloc_pid)
Definition: alloc_cache.cpp:141
bool is_allocated(PageID pid)
Definition: alloc_cache.cpp:72
Shore read-write lock:: many-reader/one-writer spin lock.
Definition: latches.h:350