Zero  0.1.0
btree.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2011-2014, Hewlett-Packard Development Company, LP
3  */
4 
5 #ifndef __BTREE_H
6 #define __BTREE_H
7 
8 /*
9  * Interface to btree manager.
10  * NB: put NO INLINE FUNCTIONS here.
11  * Implementation is class btree_impl, in btree_impl.[ch].
12  */
13 #include "w_defines.h"
14 
15 class btree_page_h;
16 struct btree_stats_t;
17 class bt_cursor_t;
18 struct btree_lf_stats_t;
19 struct btree_int_stats_t;
20 class w_keystr_t;
22 struct okvl_mode;
23 
28 class btree_m : public smlevel_0 {
29  friend class btree_page_h;
30  friend class btree_impl;
31  friend class bt_cursor_t;
32  friend class btree_remove_log;
33  friend class btree_insert_log;
35  friend class btree_update_log;
36  friend class btree_overwrite_log;
37  friend class btree_ghost_mark_log;
39 
40 public:
41  btree_m() {};
42 
43  ~btree_m() {};
44 
45  void construct_once();
46 
47  void destruct_once();
48 
49  static smsize_t max_entry_size();
50 
52  static rc_t create(
53  StoreID stid,
54  PageID root
55  );
56 
60  static rc_t insert(
61  StoreID store,
62  const w_keystr_t& key,
63  const cvec_t& elem);
64 
68  static rc_t update(
69  StoreID store,
70  const w_keystr_t& key,
71  const cvec_t& elem);
72 
77  static rc_t put(
78  StoreID store,
79  const w_keystr_t& key,
80  const cvec_t& elem);
81 
85  static rc_t overwrite(
86  StoreID store,
87  const w_keystr_t& key,
88  const char* el,
89  smsize_t offset,
90  smsize_t elen);
91 
93  static rc_t remove(
94  StoreID store,
95  const w_keystr_t& key);
96 
98  static void print(const PageID& root, bool print_elem = true);
99 
101  static rc_t touch_all(StoreID stid, uint64_t& page_count);
102 
103  static rc_t touch(const btree_page_h& page, uint64_t& page_count);
104 
110  static rc_t defrag_page(btree_page_h& page);
111 
116  static rc_t lookup(
117  StoreID store,
118  const w_keystr_t& key_to_find,
119  void* el,
120  smsize_t& elen,
121  bool& found);
122 
123  static rc_t get_du_statistics(
124  const PageID& root_pid,
125  btree_stats_t& btree_stats,
126  bool audit);
127 
132  static rc_t verify_tree(
133  StoreID store, int hash_bits, bool& consistent);
134 
139  static rc_t verify_volume(
140  int hash_bits, verify_volume_result& result);
141 
142 protected:
143  /*
144  * for use by logrecs for undo
145  */
146  static rc_t remove_as_undo(StoreID store, const w_keystr_t& key);
147 
148  static rc_t update_as_undo(StoreID store, const w_keystr_t& key, const cvec_t& elem);
149 
150  static rc_t overwrite_as_undo(StoreID store, const w_keystr_t& key,
151  const char* el, smsize_t offset, smsize_t elen);
152 
153  static rc_t undo_ghost_mark(StoreID store, const w_keystr_t& key);
154 
155 private:
157  static rc_t is_empty(StoreID store, bool& ret);
158 
161  const PageID& currentpid,
162  btree_stats_t& _stats,
163  base_stat_t& lf_cnt,
164  base_stat_t& int_cnt,
165  btree_lf_stats_t& lf_stats,
166  btree_int_stats_t& int_stats,
167  bool audit);
168 };
169 
170 /*<std-footer incl-file-exclusion='BTREE_H'> -- do not edit anything below this line -- */
171 
172 #endif // __BTREE_H /*</std-footer>*/
Definition: btree_page_h.h:1110
A cursor object to sequentially read BTree.
Definition: btcursor.h:64
Definition: logdef_gen.h:282
static rc_t defrag_page(btree_page_h &page)
Defrags the given page to remove holes and ghost records in the page.
Definition: btree.cpp:115
static rc_t lookup(StoreID store, const w_keystr_t &key_to_find, void *el, smsize_t &elen, bool &found)
Definition: btree.cpp:120
static rc_t is_empty(StoreID store, bool &ret)
Definition: btree.cpp:60
static void print(const PageID &root, bool print_elem=true)
Definition: btree.cpp:138
static rc_t update(StoreID store, const w_keystr_t &key, const cvec_t &elem)
Definition: btree.cpp:78
uint32_t smsize_t
Definition: basics.h:41
~btree_m()
Definition: btree.h:43
w_base_t::base_stat_t base_stat_t
Definition: btree_page_h.h:16
Page handle for B-Tree data page.
Definition: btree_page_h.h:185
static rc_t put(StoreID store, const w_keystr_t &key, const cvec_t &elem)
Definition: btree.cpp:89
Definition: btree_verify.h:84
uint32_t StoreID
Definition: basics.h:47
static rc_t overwrite_as_undo(StoreID store, const w_keystr_t &key, const char *el, smsize_t offset, smsize_t elen)
Definition: btree.cpp:236
Key string class which can represent a few special values.
Definition: w_key.h:47
Definition: logdef_gen.h:295
static rc_t touch_all(StoreID stid, uint64_t &page_count)
Definition: btree.cpp:191
The internal implementation class which actually implements the functions of btree_m.
Definition: btree_impl.h:66
A constant vec_t (meaning things pointed to cannot be changed).
Definition: vec_t.h:95
Definition: btree_page_h.h:1133
Definition: logdef_gen.h:269
uint32_t PageID
Definition: basics.h:45
static rc_t verify_volume(int hash_bits, verify_volume_result &result)
Verifies consistency of all BTree indexes in the volume.
Definition: btree.cpp:132
static smsize_t max_entry_size()
Definition: btree.cpp:39
friend class btree_remove_log
Definition: btree.h:32
Definition: logdef_gen.h:322
Return code for most functions and methods.
Definition: w_rc.h:87
static rc_t verify_tree(StoreID store, int hash_bits, bool &consistent)
Definition: btree.cpp:127
static rc_t touch(const btree_page_h &page, uint64_t &page_count)
Definition: btree.cpp:198
Definition: btree.h:28
static rc_t remove_as_undo(StoreID store, const w_keystr_t &key)
Definition: btree.cpp:224
Represents a lock mode of one key entry in the OKVL lock manager.
Definition: w_okvl.h:95
Definition: btree_page_h.h:1082
static rc_t create(StoreID stid, PageID root)
Definition: btree.cpp:44
static rc_t undo_ghost_mark(StoreID store, const w_keystr_t &key)
Definition: btree.cpp:244
static rc_t insert(StoreID store, const w_keystr_t &key, const cvec_t &elem)
Definition: btree.cpp:70
Definition: logdef_gen.h:256
void destruct_once()
Definition: btree.cpp:31
static rc_t get_du_statistics(const PageID &root_pid, btree_stats_t &btree_stats, bool audit)
static rc_t _get_du_statistics_recurse(const PageID &currentpid, btree_stats_t &_stats, base_stat_t &lf_cnt, base_stat_t &int_cnt, btree_lf_stats_t &lf_stats, btree_int_stats_t &int_stats, bool audit)
static rc_t overwrite(StoreID store, const w_keystr_t &key, const char *el, smsize_t offset, smsize_t elen)
Definition: btree.cpp:100
static rc_t update_as_undo(StoreID store, const w_keystr_t &key, const cvec_t &elem)
Definition: btree.cpp:230
void construct_once()
Definition: btree.cpp:21
btree_m()
Definition: btree.h:41
StoreID stid() const
Definition: logrec.h:511
Definition: logdef_gen.h:309