Zero  0.1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
fixable_page_h Class Reference

Handle class for pages that may be fixed (i.e., paged in by the main buffer manager, zero::buffer_pool::BufferPool) More...

#include <fixable_page_h.h>

Inheritance diagram for fixable_page_h:
generic_page_h btree_page_h borrowed_btree_page_h

Public Member Functions

 fixable_page_h ()
 Create handle not yet fixed to a page. More...
 
 ~fixable_page_h ()
 
fixable_page_hoperator= (fixable_page_h &p)
 
bool is_fixed () const
 Do we have an associated page? More...
 
void unfix (bool evict=false)
 
bool is_bufferpool_managed () const
 Is this page really fixed in bufferpool or a psuedo-fix? More...
 
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)
 
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)
 
bf_idx pin_for_refix ()
 
w_rc_t refix_direct (bf_idx idx, latch_mode_t mode, bool conditional=false)
 
w_rc_t fix_root (StoreID store, latch_mode_t mode, bool conditional=false, bool virgin=false)
 
void fix_nonbufferpool_page (generic_page *s)
 
bool is_dirty () const
 
void update_page_lsn (const lsn_t &lsn) const
 Updates page_lsn field stored in CB of buffered page. More...
 
lsn_t get_page_lsn () const
 
uint32_t get_log_volume ()
 returns log volume in the CB More...
 
void increment_log_volume (uint32_t)
 
void reset_log_volume ()
 
bool has_check_recovery ()
 return value of _check_recovery flag on CB More...
 
void set_img_page_lsn (const lsn_t &lsn)
 Updates lsn field inside generic_page (i.e., in the page image) More...
 
bool is_to_be_deleted ()
 
w_rc_t set_to_be_deleted (bool log_it)
 
void unset_to_be_deleted ()
 
void set_check_recovery (bool)
 
void set_tag (page_tag_t tag)
 
latch_mode_t latch_mode () const
 
bool is_latched () const
 Do we hold our page's latch in SH or EX mode? More...
 
bool change_possible_after_fix () const
 
bool upgrade_latch_conditional (latch_mode_t mode=LATCH_EX)
 
bool has_children () const
 
int max_child_slot () const
 
PageIDchild_slot_address (int child_slot) const
 
PageID root () const
 
void setup_for_restore (generic_page *pp)
 
bool is_pinned_for_restore ()
 
- Public Member Functions inherited from generic_page_h
 generic_page_h (generic_page *s)
 
virtual ~generic_page_h ()
 
generic_pageget_generic_page () const
 return pointer to underlying page More...
 
PageID pid () const
 
StoreID store () const
 
page_tag_t tag () const
 
const lsn_tlsn () const
 

Static Public Member Functions

static general_recordid_t find_page_id_slot (generic_page *page, PageID pid)
 

Static Public Attributes

static int force_Q_fixing = 0
 

Protected Attributes

bool _bufferpool_managed
 is our associated page managed by the buffer pool? More...
 
latch_mode_t _mode
 
q_ticket_t _Q_ticket
 
- Protected Attributes inherited from generic_page_h
generic_page_pp
 The actual page we are handling; may be NULL for fixable pages. More...
 

Friends

class borrowed_btree_page_h
 

Additional Inherited Members

- Protected Member Functions inherited from generic_page_h
 generic_page_h (generic_page *s, const PageID &pid, page_tag_t tag, StoreID store)
 

Detailed Description

Handle class for pages that may be fixed (i.e., paged in by the main buffer manager, zero::buffer_pool::BufferPool)

Currently, only B-tree pages are fixable.

Pages fixed using latching mode Q for the page being fixed are still subject to modification by other threads at any time, including replacement by a different page; the methods of this class are safe to use in this case (but may return errors such as eLATCHQFAIL) but super or subclass methods may not be safe to use in this case unless their description specifically says so or they are labeled "robust".

Constructor & Destructor Documentation

§ fixable_page_h()

fixable_page_h::fixable_page_h ( )
inline

Create handle not yet fixed to a page.

§ ~fixable_page_h()

fixable_page_h::~fixable_page_h ( )
inline

Member Function Documentation

§ change_possible_after_fix()

bool fixable_page_h::change_possible_after_fix ( ) const

Could someone else have changed our page via a EX latch since we last fixed it?

Returns false for non-bufferpool managed pages as they are assumed to be private pages not in the buffer pool.

Precondition
is_fixed()

§ child_slot_address()

PageID * fixable_page_h::child_slot_address ( int  child_slot) const

valid slots are [-1 .. max_child_slot()], where -1 is foster pointer and 0 is pid0

Precondition
We do not hold current page's latch in Q mode

§ find_page_id_slot()

general_recordid_t fixable_page_h::find_page_id_slot ( generic_page page,
PageID  pid 
)
static

Search in the given page to find the slot that contains the page id as a child. Returns >0 if a normal slot, 0 if pid0, -1 if foster, -2 if not found.

§ fix_direct()

w_rc_t fixable_page_h::fix_direct ( PageID  pid,
latch_mode_t  mode,
bool  conditional = false,
bool  virgin_page = false,
bool  only_if_hit = false,
bool  do_recovery = true 
)

§ fix_nonbufferpool_page()

void fixable_page_h::fix_nonbufferpool_page ( generic_page s)

Imaginery 'fix' for a non-bufferpool-managed page.

The resulting page is considered to be latched in EX mode.

§ fix_nonroot()

w_rc_t fixable_page_h::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 
)

Fixes a non-root page in the bufferpool. This method receives the parent page and efficiently fixes the page if the shpid (pointer) is already swizzled by the parent page. The optimization is transparent for most of the code because the shpid stored in the parent page is automatically (and atomically) changed to a swizzled pointer when permited by the latch mode.

Parameters
[in]parentparent of the page to be fixed. If you can't provide this, use fix_direct() though it can't exploit pointer swizzling and thus will be slower.
[in]pidID of the page to fix (or bufferpool index when swizzled)
[in]modelatch mode. Can be Q, SH, or EX.
[in]conditionalwhether the fix is conditional (returns immediately even if failed).
[in]virgin_pagewhether the page is a new page and thus doesn't have to be read from disk.
[in]only_if_hitwhether the page shouldn't be fixed on a page miss.

If parent.latch_mode() or mode is LATCH_Q, can return eLATCHQFAIL, ePARENTLATCHQFAIL, or eNEEDREALLATCH. The later occurs only when virgin_page is true or pid is not swizzled.

§ fix_root()

w_rc_t fixable_page_h::fix_root ( StoreID  store,
latch_mode_t  mode,
bool  conditional = false,
bool  virgin = false 
)

Fixes an existing (not virgin) root page for the given store. This method doesn't receive page ID because it's already known by bufferpool.

§ get_log_volume()

uint32_t fixable_page_h::get_log_volume ( )

returns log volume in the CB

§ get_page_lsn()

lsn_t fixable_page_h::get_page_lsn ( ) const

§ has_check_recovery()

bool fixable_page_h::has_check_recovery ( )

return value of _check_recovery flag on CB

§ has_children()

bool fixable_page_h::has_children ( ) const
Precondition
We do not hold current page's latch in Q mode

§ increment_log_volume()

void fixable_page_h::increment_log_volume ( uint32_t  v)

§ is_bufferpool_managed()

bool fixable_page_h::is_bufferpool_managed ( ) const
inline

Is this page really fixed in bufferpool or a psuedo-fix?

§ is_dirty()

bool fixable_page_h::is_dirty ( ) const

Return true if this page in the bufferpool is marked dirty. If this page is not a bufferpool-managed page, returns false.

Precondition
We do not hold current page's latch in Q mode

§ is_fixed()

bool fixable_page_h::is_fixed ( ) const
inline

Do we have an associated page?

§ is_latched()

bool fixable_page_h::is_latched ( ) const
inline

Do we hold our page's latch in SH or EX mode?

§ is_pinned_for_restore()

bool fixable_page_h::is_pinned_for_restore ( )

§ is_to_be_deleted()

bool fixable_page_h::is_to_be_deleted ( )

Return flag for if this page to be deleted when bufferpool evicts it.

Precondition
We do not hold current page's latch in Q mode

§ latch_mode()

latch_mode_t fixable_page_h::latch_mode ( ) const
inline

§ max_child_slot()

int fixable_page_h::max_child_slot ( ) const
Precondition
We do not hold current page's latch in Q mode

§ operator=()

fixable_page_h& fixable_page_h::operator= ( fixable_page_h p)
inline

assignment; steals the ownership of the page/latch p and unfixes old associated page if exists and is different

§ pin_for_refix()

bf_idx fixable_page_h::pin_for_refix ( )

Adds an additional pin count for the given page. This is used to re-fix the page later without parent pointer. See fix_direct() why we need this feature. Never forget to call a corresponding unpin_for_refix() for this page. Otherwise, the page will be in the bufferpool forever.

Precondition
We hold our associated page's latch in SH or EX mode, it is managed by the buffer pool
Returns
slot index of the page in this bufferpool. Pass this value to the subsequent refix_direct() and unpin_for_refix() call.

§ refix_direct()

w_rc_t fixable_page_h::refix_direct ( bf_idx  idx,
latch_mode_t  mode,
bool  conditional = false 
)

Fixes a page with the already known slot index, assuming the slot has at least one pin count. Used with pin_for_refix() and unpin_for_refix().

Currently returns eNEEDREALLATCH if mode is Q

§ reset_log_volume()

void fixable_page_h::reset_log_volume ( )

§ root()

PageID fixable_page_h::root ( ) const

§ set_check_recovery()

void fixable_page_h::set_check_recovery ( bool  chk)

§ set_img_page_lsn()

void fixable_page_h::set_img_page_lsn ( const lsn_t lsn)

Updates lsn field inside generic_page (i.e., in the page image)

§ set_tag()

void fixable_page_h::set_tag ( page_tag_t  tag)
inline

§ set_to_be_deleted()

rc_t fixable_page_h::set_to_be_deleted ( bool  log_it)

Flag this page to be deleted when bufferpool evicts it.

Precondition
We hold our associated page's latch in SH or EX mode

§ setup_for_restore()

void fixable_page_h::setup_for_restore ( generic_page pp)

Used by restore to perform REDO on a page allocated ouside the buffer pool. Ideally, this would not be necessary, but unfortunately, the log record interface requires a fixable_page_h to perform REDO.

§ unfix()

void fixable_page_h::unfix ( bool  evict = false)

Unassociate us with any page; releases latch we may have held on previously associated page.

§ unset_to_be_deleted()

void fixable_page_h::unset_to_be_deleted ( )

Unset the to be deleted flag. This is only used by UNDO, so no logging and no failure possible.

Precondition
We hold our associated page's latch in SH or EX mode

§ update_page_lsn()

void fixable_page_h::update_page_lsn ( const lsn_t lsn) const

Updates page_lsn field stored in CB of buffered page.

§ upgrade_latch_conditional()

bool fixable_page_h::upgrade_latch_conditional ( latch_mode_t  mode = LATCH_EX)

Attempt to upgrade our latch to at least mode, which must be either LATCH_EX (the default) or LATCH_SH. Returns true iff our latch mode afterwards is >= mode. Our latch mode is unchanged if we return false.

WARNING: this operation can spuriously fail once in a while (e.g., S -> X may fail even without any other latch holders).

Friends And Related Function Documentation

§ borrowed_btree_page_h

friend class borrowed_btree_page_h
friend

Member Data Documentation

§ _bufferpool_managed

bool fixable_page_h::_bufferpool_managed
protected

is our associated page managed by the buffer pool?

§ _mode

latch_mode_t fixable_page_h::_mode
protected

§ _Q_ticket

q_ticket_t fixable_page_h::_Q_ticket
protected

§ force_Q_fixing

int fixable_page_h::force_Q_fixing = 0
static

The documentation for this class was generated from the following files: