Zero  0.1.0
fixable_page_h.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2011-2014, Hewlett-Packard Development Company, LP
3  */
4 
5 #ifndef __FIXABLE_PAGE_H_H
6 #define __FIXABLE_PAGE_H_H
7 
8 #include "buffer_pool.hpp"
9 #include "generic_page.h"
10 #include "latch.h"
11 #include "sm_base.h"
12 
27 public:
28  static int force_Q_fixing; // converts S mode to Q when: 0=no (default), 1=root only, 2=all <<<>>>
29 
30  // ======================================================================
31  // BEGIN: Construction/destruction/assignment
32  // ======================================================================
33 
36  _bufferpool_managed(false),
37  _mode(LATCH_NL) {}
38 
40  unfix();
41  }
42 
46  if (&p != this) {
47  unfix();
48  _pp = p._pp;
50  _mode = p._mode;
51  _Q_ticket = p._Q_ticket;
52  p._pp = nullptr;
53  p._mode = LATCH_NL;
54  }
55  return *this;
56  }
57 
58  // ======================================================================
59  // BEGIN: [Un]fixing pages
60  // ======================================================================
61 
63  bool is_fixed() const {
64  return _pp != 0;
65  }
66 
69  void unfix(bool evict = false);
70 
72  bool is_bufferpool_managed() const {
73  return _bufferpool_managed;
74  }
75 
98  w_rc_t fix_nonroot(const fixable_page_h& parent,
99  PageID pid, latch_mode_t mode, bool conditional = false,
100  bool virgin_page = false, bool only_if_hit = false);
101 
102  w_rc_t fix_direct(PageID pid, latch_mode_t mode, bool conditional = false,
103  bool virgin_page = false, bool only_if_hit = false,
104  bool do_recovery = true);
105 
117 
124  w_rc_t refix_direct(bf_idx idx, latch_mode_t mode, bool conditional = false);
125 
131  bool conditional = false, bool virgin = false);
132 
139 
140 
141  // ======================================================================
142  // BEGIN: Other page operations
143  // ======================================================================
144 
151  bool is_dirty() const;
152 
154  void update_page_lsn(const lsn_t& lsn) const;
155 
156  lsn_t get_page_lsn() const;
157 
159  uint32_t get_log_volume();
160 
161  void increment_log_volume(uint32_t);
162 
163  void reset_log_volume();
164 
166  bool has_check_recovery();
167 
169  void set_img_page_lsn(const lsn_t& lsn);
170 
173  bool is_to_be_deleted();
174 
177  w_rc_t set_to_be_deleted(bool log_it);
178 
182  void unset_to_be_deleted();
183 
184  void set_check_recovery(bool);
185 
187  _pp->tag = tag;
188  }
189 
191  return _mode;
192  }
193 
195  bool is_latched() const {
196  return _mode == LATCH_SH || _mode == LATCH_EX;
197  }
198 
207  bool change_possible_after_fix() const;
208 
218 
219 
220  // ======================================================================
221  // BEGIN: Interface for use only by buffer manager to perform swizzling
222  // ======================================================================
223 
225  bool has_children() const;
226 
228  int max_child_slot() const;
229 
232  PageID* child_slot_address(int child_slot) const;
233 
239 
240  PageID root() const;
241 
248 
249  bool is_pinned_for_restore();
250 
251 protected:
252  friend class borrowed_btree_page_h;
253 
256 
258 };
259 
260 #endif // __FIXABLE_PAGE_H_H
bool has_check_recovery()
return value of _check_recovery flag on CB
Definition: fixable_page_h.cpp:176
Definition: latch.h:82
void unfix(bool evict=false)
Definition: fixable_page_h.cpp:31
bool is_pinned_for_restore()
Definition: fixable_page_h.cpp:251
void set_check_recovery(bool)
Definition: fixable_page_h.cpp:154
latch_mode_t _mode
Definition: fixable_page_h.h:255
int64_t q_ticket_t
type of a Q mode ticket; exact type and location of definition TBD
Definition: latch.h:86
void set_img_page_lsn(const lsn_t &lsn)
Updates lsn field inside generic_page (i.e., in the page image)
Definition: fixable_page_h.cpp:148
static int force_Q_fixing
Definition: fixable_page_h.h:28
latch_mode_t latch_mode() const
Definition: fixable_page_h.h:190
Page handle class for any page type.
Definition: generic_page.h:135
void setup_for_restore(generic_page *pp)
Definition: fixable_page_h.cpp:238
bool is_bufferpool_managed() const
Is this page really fixed in bufferpool or a psuedo-fix?
Definition: fixable_page_h.h:72
w_rc_t fix_root(StoreID store, latch_mode_t mode, bool conditional=false, bool virgin=false)
Definition: fixable_page_h.cpp:102
int16_t general_recordid_t
An integer to point to any record in B-tree pages.
Definition: basics.h:71
bool _bufferpool_managed
is our associated page managed by the buffer pool?
Definition: fixable_page_h.h:254
w_rc_t set_to_be_deleted(bool log_it)
Definition: fixable_page_h.cpp:186
Definition: latch.h:80
uint32_t StoreID
Definition: basics.h:47
A generic page view: any Zero page can be viewed as being of this type but it only exposes fields sha...
Definition: generic_page.h:121
bool has_children() const
Definition: fixable_page_h.cpp:263
uint32_t get_log_volume()
returns log volume in the CB
Definition: fixable_page_h.cpp:159
q_ticket_t _Q_ticket
Definition: fixable_page_h.h:257
StoreID store() const
Definition: generic_page.h:150
uint32_t bf_idx
Definition: basics.h:56
uint16_t tag
Page type (a page_tag_t)
Definition: generic_page.h:60
w_rc_t refix_direct(bf_idx idx, latch_mode_t mode, bool conditional=false)
Definition: fixable_page_h.cpp:90
uint32_t PageID
Definition: basics.h:45
~fixable_page_h()
Definition: fixable_page_h.h:39
Log Sequence Number. See Log Sequence Numbers (LSN).
Definition: lsn.h:243
fixable_page_h & operator=(fixable_page_h &p)
Definition: fixable_page_h.h:45
Handle class for pages that may be fixed (i.e., paged in by the main buffer manager, zero::buffer_pool::BufferPool)
Definition: fixable_page_h.h:26
static general_recordid_t find_page_id_slot(generic_page *page, PageID pid)
Definition: fixable_page_h.cpp:286
PageID pid() const
Definition: generic_page.h:146
Return code for most functions and methods.
Definition: w_rc.h:87
bool is_dirty() const
Definition: fixable_page_h.cpp:129
page_tag_t tag() const
Definition: generic_page.h:154
bf_idx pin_for_refix()
Definition: fixable_page_h.cpp:84
bool change_possible_after_fix() const
Definition: fixable_page_h.cpp:209
void reset_log_volume()
Definition: fixable_page_h.cpp:171
Definition: latch.h:81
void fix_nonbufferpool_page(generic_page *s)
Definition: fixable_page_h.cpp:117
int max_child_slot() const
Definition: fixable_page_h.cpp:270
bool is_to_be_deleted()
Definition: fixable_page_h.cpp:182
bool is_latched() const
Do we hold our page&#39;s latch in SH or EX mode?
Definition: fixable_page_h.h:195
lsn_t get_page_lsn() const
Definition: fixable_page_h.cpp:138
bool is_fixed() const
Do we have an associated page?
Definition: fixable_page_h.h:63
fixable_page_h()
Create handle not yet fixed to a page.
Definition: fixable_page_h.h:35
bool upgrade_latch_conditional(latch_mode_t mode=LATCH_EX)
Definition: fixable_page_h.cpp:214
void update_page_lsn(const lsn_t &lsn) const
Updates page_lsn field stored in CB of buffered page.
Definition: fixable_page_h.cpp:143
void increment_log_volume(uint32_t)
Definition: fixable_page_h.cpp:166
latch_mode_t
Definition: latch.h:79
Specialized variant of btree_page_h that borrows a B-tree page from a fixable_page_h.
Definition: btree_page_h.h:1054
PageID root() const
Definition: fixable_page_h.cpp:302
generic_page * _pp
The actual page we are handling; may be NULL for fixable pages.
Definition: generic_page.h:173
void set_tag(page_tag_t tag)
Definition: fixable_page_h.h:186
w_rc_t fix_nonroot(const fixable_page_h &parent, PageID pid, latch_mode_t mode, bool conditional=false, bool virgin_page=false, bool only_if_hit=false)
Definition: fixable_page_h.cpp:42
const lsn_t & lsn() const
Definition: generic_page.h:158
w_rc_t fix_direct(PageID pid, latch_mode_t mode, bool conditional=false, bool virgin_page=false, bool only_if_hit=false, bool do_recovery=true)
Definition: fixable_page_h.cpp:62
page_tag_t
The type of a page; e.g., is this a B-tree page, an allocation page, or what?
Definition: generic_page.h:86
void unset_to_be_deleted()
Definition: fixable_page_h.cpp:200
PageID * child_slot_address(int child_slot) const
Definition: fixable_page_h.cpp:280