libfoedus-core
FOEDUS Core Library
foedus::storage::masstree::MasstreeIntermediatePage Class Referencefinal

Represents one intermediate page in Masstree Storage. More...

Detailed Description

Represents one intermediate page in Masstree Storage.

An intermediate page consists of bunch of separator keys and pointers to children nodes, which might be another intermediate pages or border nodes.

Attention
Do NOT instantiate this object or derive from this class. A page is always reinterpret-ed from a pooled memory region. No meaningful RTTI.

Definition at line 262 of file masstree_page_impl.hpp.

#include <masstree_page_impl.hpp>

Inheritance diagram for foedus::storage::masstree::MasstreeIntermediatePage:
Collaboration diagram for foedus::storage::masstree::MasstreeIntermediatePage:

Classes

struct  MiniPage
 

Public Member Functions

 MasstreeIntermediatePage ()=delete
 
 MasstreeIntermediatePage (const MasstreeIntermediatePage &other)=delete
 
MasstreeIntermediatePageoperator= (const MasstreeIntermediatePage &other)=delete
 
void prefetch () const
 prefetch upto separators. More...
 
uint8_t find_minipage (KeySlice slice) const __attribute__((always_inline))
 Navigates a searching key-slice to one of the mini pages in this page. More...
 
MiniPageget_minipage (uint8_t index) __attribute__((always_inline))
 
const MiniPageget_minipage (uint8_t index) const __attribute__((always_inline))
 
KeySlice get_separator (uint8_t index) const __attribute__((always_inline))
 
void release_pages_recursive_parallel (Engine *engine)
 This method is used when we release a large number of volatile pages, most likely when we drop a storage. More...
 
void release_pages_recursive (const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
 
void initialize_volatile_page (StorageId storage_id, VolatilePagePointer page_id, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)
 
void initialize_snapshot_page (StorageId storage_id, SnapshotPagePointer page_id, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)
 
void append_pointer_snapshot (KeySlice low_fence, SnapshotPagePointer pointer)
 Appends a new poiner and separator in an existing mini page, used only by snapshot composer. More...
 
void append_minipage_snapshot (KeySlice low_fence, SnapshotPagePointer pointer)
 Appends a new separator and the initial pointer in new mini page, used only by snapshot composer. More...
 
bool is_full_snapshot () const
 Whether this page is full of poiters, used only by snapshot composer (or when no race) More...
 
void extract_separators_snapshot (uint8_t index, uint8_t index_mini, KeySlice *separator_low, KeySlice *separator_high) const
 Retrieves separators defining the index, used only by snapshot composer, thus no race. More...
 
void extract_separators_volatile (uint8_t index, uint8_t index_mini, KeySlice *separator_low, KeySlice *separator_high) const
 Retrieves separators defining the index, used for volatile page, which requires appropriate locks or retries by the caller. More...
 
void extract_separators_common (uint8_t index, uint8_t index_mini, KeySlice *separator_low, KeySlice *separator_high) const
 Retrieves separators defining the index, used only by snapshot composer (or when no race) More...
 
void verify_separators () const
 
void set_separator (uint8_t minipage_index, KeySlice new_separator)
 Place a new separator for a new minipage. More...
 
- Public Member Functions inherited from foedus::storage::masstree::MasstreePage
 MasstreePage ()=delete
 
 MasstreePage (const MasstreePage &other)=delete
 
MasstreePageoperator= (const MasstreePage &other)=delete
 
PageHeaderheader ()
 
const PageHeaderheader () const
 
VolatilePagePointer get_volatile_page_id () const
 
SnapshotPagePointer get_snapshot_page_id () const
 
bool is_border () const __attribute__((always_inline))
 
bool is_empty_range () const __attribute__((always_inline))
 An empty-range page, either intermediate or border, never has any entries. More...
 
KeySlice get_low_fence () const __attribute__((always_inline))
 
KeySlice get_high_fence () const __attribute__((always_inline))
 
bool is_high_fence_supremum () const __attribute__((always_inline))
 
bool is_low_fence_infimum () const __attribute__((always_inline))
 
bool is_layer_root () const __attribute__((always_inline))
 
KeySlice get_foster_fence () const __attribute__((always_inline))
 
bool is_foster_minor_null () const __attribute__((always_inline))
 
bool is_foster_major_null () const __attribute__((always_inline))
 
VolatilePagePointer get_foster_minor () const __attribute__((always_inline))
 
VolatilePagePointer get_foster_major () const __attribute__((always_inline))
 
void set_foster_twin (VolatilePagePointer minor, VolatilePagePointer major)
 
void install_foster_twin (VolatilePagePointer minor, VolatilePagePointer major, KeySlice foster_fence)
 
bool within_fences (KeySlice slice) const __attribute__((always_inline))
 
bool within_foster_minor (KeySlice slice) const __attribute__((always_inline))
 
bool within_foster_major (KeySlice slice) const __attribute__((always_inline))
 
bool has_foster_child () const __attribute__((always_inline))
 
uint8_t get_layer () const __attribute__((always_inline))
 Layer-0 stores the first 8 byte slice, Layer-1 next 8 byte... More...
 
uint8_t get_btree_level () const __attribute__((always_inline))
 used only in masstree. More...
 
SlotIndex get_key_count () const __attribute__((always_inline))
 physical key count (those keys might be deleted) in this page. More...
 
void set_key_count (SlotIndex count) __attribute__((always_inline))
 
void increment_key_count () __attribute__((always_inline))
 
void prefetch_general () const __attribute__((always_inline))
 prefetch upto keys/separators, whether this page is border or interior. More...
 
const PageVersionget_version () const __attribute__((always_inline))
 
PageVersionget_version () __attribute__((always_inline))
 
const PageVersionget_version_address () const __attribute__((always_inline))
 
PageVersionget_version_address () __attribute__((always_inline))
 
xct::McsWwLockget_lock_address () __attribute__((always_inline))
 
bool is_locked () const __attribute__((always_inline))
 
bool is_moved () const __attribute__((always_inline))
 
bool is_retired () const __attribute__((always_inline))
 
void set_moved () __attribute__((always_inline))
 
void set_retired () __attribute__((always_inline))
 
void release_pages_recursive_common (const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
 
void set_foster_major_offset_unsafe (memory::PagePoolOffset offset) __attribute__((always_inline))
 As the name suggests, this should be used only by composer. More...
 
void set_high_fence_unsafe (KeySlice high_fence) __attribute__((always_inline))
 As the name suggests, this should be used only by composer. More...
 

Friends

struct SplitIntermediate
 
std::ostream & operator<< (std::ostream &o, const MasstreeIntermediatePage &v)
 defined in masstree_page_debug.cpp. More...
 

Additional Inherited Members

- Protected Member Functions inherited from foedus::storage::masstree::MasstreePage
void initialize_volatile_common (StorageId storage_id, VolatilePagePointer page_id, PageType page_type, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)
 
void initialize_snapshot_common (StorageId storage_id, SnapshotPagePointer page_id, PageType page_type, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)
 
- Protected Attributes inherited from foedus::storage::masstree::MasstreePage
PageHeader header_
 
KeySlice low_fence_
 Inclusive low fence of this page. More...
 
KeySlice high_fence_
 Inclusive high fence of this page. More...
 
KeySlice foster_fence_
 Inclusive low_fence of foster child. More...
 
VolatilePagePointer foster_twin_ [2]
 Points to foster children, or tentative child pages. More...
 

Constructor & Destructor Documentation

foedus::storage::masstree::MasstreeIntermediatePage::MasstreeIntermediatePage ( )
delete
foedus::storage::masstree::MasstreeIntermediatePage::MasstreeIntermediatePage ( const MasstreeIntermediatePage other)
delete

Member Function Documentation

void foedus::storage::masstree::MasstreeIntermediatePage::append_minipage_snapshot ( KeySlice  low_fence,
SnapshotPagePointer  pointer 
)
inline

Appends a new separator and the initial pointer in new mini page, used only by snapshot composer.

Precondition
header_.snapshot
!is_full_snapshot()

Definition at line 1522 of file masstree_page_impl.hpp.

References ASSERT_ND, foedus::storage::VolatilePagePointer::clear(), foedus::storage::masstree::MasstreePage::get_key_count(), get_minipage(), foedus::storage::masstree::MasstreePage::header_, is_full_snapshot(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::pointers_, foedus::storage::masstree::MasstreePage::set_key_count(), foedus::storage::PageHeader::snapshot_, foedus::storage::DualPagePointer::snapshot_pointer_, and foedus::storage::DualPagePointer::volatile_pointer_.

Referenced by append_pointer_snapshot().

1524  {
1527  uint16_t key_count = get_key_count();
1529  ASSERT_ND(mini_pages_[key_count].key_count_ == kMaxIntermediateMiniSeparators);
1530  ASSERT_ND(low_fence > get_minipage(key_count).separators_[kMaxIntermediateMiniSeparators - 1]);
1531  separators_[key_count] = low_fence;
1532  MiniPage& new_minipage = mini_pages_[key_count + 1];
1533  new_minipage.key_count_ = 0;
1534  new_minipage.pointers_[0].volatile_pointer_.clear();
1535  new_minipage.pointers_[0].snapshot_pointer_ = pointer;
1536  set_key_count(key_count + 1);
1537 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
const uint16_t kMaxIntermediateMiniSeparators
Max number of separators stored in the second level of intermediate pages.
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
bool is_full_snapshot() const
Whether this page is full of poiters, used only by snapshot composer (or when no race) ...
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
void set_key_count(SlotIndex count) __attribute__((always_inline))

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::append_pointer_snapshot ( KeySlice  low_fence,
SnapshotPagePointer  pointer 
)
inline

Appends a new poiner and separator in an existing mini page, used only by snapshot composer.

Precondition
header_.snapshot
!is_full_snapshot()

Definition at line 1496 of file masstree_page_impl.hpp.

References append_minipage_snapshot(), ASSERT_ND, foedus::storage::VolatilePagePointer::clear(), foedus::storage::extract_snapshot_id_from_snapshot_pointer(), foedus::storage::masstree::MasstreePage::get_high_fence(), foedus::storage::masstree::MasstreePage::get_key_count(), foedus::storage::masstree::MasstreePage::get_low_fence(), foedus::storage::masstree::MasstreePage::header_, is_full_snapshot(), foedus::storage::masstree::MasstreePage::is_high_fence_supremum(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::pointers_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::separators_, foedus::storage::PageHeader::snapshot_, foedus::storage::DualPagePointer::snapshot_pointer_, and foedus::storage::DualPagePointer::volatile_pointer_.

1498  {
1501  uint16_t index = get_key_count();
1502  MiniPage& mini = mini_pages_[index];
1503  uint16_t index_mini = mini.key_count_;
1504  ASSERT_ND(low_fence > get_low_fence());
1505  ASSERT_ND(is_high_fence_supremum() || low_fence < get_high_fence());
1506  ASSERT_ND(pointer == 0 || extract_snapshot_id_from_snapshot_pointer(pointer) != 0);
1507  if (index_mini < kMaxIntermediateMiniSeparators) {
1508  // p0 s0 p1 + "s p" -> p0 s0 p1 s1 p2
1509  ASSERT_ND(pointer == 0 // composer init_root uses this method to set null pointers..
1510  || mini.pointers_[index_mini].snapshot_pointer_ != pointer); // otherwise dup.
1511  ASSERT_ND(index_mini == 0 || low_fence > mini.separators_[index_mini - 1]);
1512  ASSERT_ND(index == 0 || low_fence > separators_[index - 1]);
1513  mini.separators_[index_mini] = low_fence;
1514  mini.pointers_[index_mini + 1].volatile_pointer_.clear();
1515  mini.pointers_[index_mini + 1].snapshot_pointer_ = pointer;
1516  ++mini.key_count_;
1517  } else {
1518  append_minipage_snapshot(low_fence, pointer);
1519  }
1520 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
const uint16_t kMaxIntermediateMiniSeparators
Max number of separators stored in the second level of intermediate pages.
uint16_t extract_snapshot_id_from_snapshot_pointer(SnapshotPagePointer pointer)
Definition: storage_id.hpp:98
KeySlice get_high_fence() const __attribute__((always_inline))
KeySlice get_low_fence() const __attribute__((always_inline))
bool is_high_fence_supremum() const __attribute__((always_inline))
void append_minipage_snapshot(KeySlice low_fence, SnapshotPagePointer pointer)
Appends a new separator and the initial pointer in new mini page, used only by snapshot composer...
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
bool is_full_snapshot() const
Whether this page is full of poiters, used only by snapshot composer (or when no race) ...
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::extract_separators_common ( uint8_t  index,
uint8_t  index_mini,
KeySlice separator_low,
KeySlice separator_high 
) const
inline

Retrieves separators defining the index, used only by snapshot composer (or when no race)

Definition at line 1539 of file masstree_page_impl.hpp.

References ASSERT_ND, foedus::storage::masstree::MasstreePage::get_high_fence(), foedus::storage::masstree::MasstreePage::get_key_count(), foedus::storage::masstree::MasstreePage::get_low_fence(), get_minipage(), get_separator(), foedus::storage::masstree::MasstreePage::is_border(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, and foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::separators_.

Referenced by extract_separators_snapshot(), and extract_separators_volatile().

1543  {
1544  ASSERT_ND(!is_border());
1545  uint8_t key_count = get_key_count();
1546  ASSERT_ND(index <= key_count);
1547  const MasstreeIntermediatePage::MiniPage& minipage = get_minipage(index);
1548  ASSERT_ND(index_mini <= minipage.key_count_);
1549  if (index_mini == 0) {
1550  if (index == 0) {
1551  *separator_low = get_low_fence();
1552  } else {
1553  *separator_low = get_separator(index - 1U);
1554  }
1555  } else {
1556  *separator_low = minipage.separators_[index_mini - 1U];
1557  }
1558  if (index_mini == minipage.key_count_) {
1559  if (index == key_count) {
1560  *separator_high = get_high_fence();
1561  } else {
1562  *separator_high = get_separator(index);
1563  }
1564  } else {
1565  *separator_high = minipage.separators_[index_mini];
1566  }
1567 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
bool is_border() const __attribute__((always_inline))
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
KeySlice get_separator(uint8_t index) const __attribute__((always_inline))
KeySlice get_high_fence() const __attribute__((always_inline))
KeySlice get_low_fence() const __attribute__((always_inline))
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::extract_separators_snapshot ( uint8_t  index,
uint8_t  index_mini,
KeySlice separator_low,
KeySlice separator_high 
) const
inline

Retrieves separators defining the index, used only by snapshot composer, thus no race.

Definition at line 367 of file masstree_page_impl.hpp.

References ASSERT_ND, extract_separators_common(), foedus::storage::masstree::MasstreePage::header_, and foedus::storage::PageHeader::snapshot_.

Referenced by foedus::storage::masstree::MasstreeComposer::construct_root().

371  {
373  extract_separators_common(index, index_mini, separator_low, separator_high);
374  }
void extract_separators_common(uint8_t index, uint8_t index_mini, KeySlice *separator_low, KeySlice *separator_high) const
Retrieves separators defining the index, used only by snapshot composer (or when no race) ...
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::extract_separators_volatile ( uint8_t  index,
uint8_t  index_mini,
KeySlice separator_low,
KeySlice separator_high 
) const
inline

Retrieves separators defining the index, used for volatile page, which requires appropriate locks or retries by the caller.

The caller must be careful!

Definition at line 379 of file masstree_page_impl.hpp.

References ASSERT_ND, extract_separators_common(), foedus::storage::masstree::MasstreePage::header_, and foedus::storage::PageHeader::snapshot_.

383  {
385  extract_separators_common(index, index_mini, separator_low, separator_high);
386  }
void extract_separators_common(uint8_t index, uint8_t index_mini, KeySlice *separator_low, KeySlice *separator_high) const
Retrieves separators defining the index, used only by snapshot composer (or when no race) ...
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

uint8_t foedus::storage::masstree::MasstreeIntermediatePage::find_minipage ( KeySlice  slice) const
inline

Navigates a searching key-slice to one of the mini pages in this page.

Definition at line 312 of file masstree_page_impl.hpp.

References ASSERT_ND, and foedus::storage::masstree::MasstreePage::get_key_count().

Referenced by foedus::storage::masstree::MasstreeStoragePimpl::fatify_first_root_double(), foedus::storage::masstree::MasstreeStoragePimpl::find_border_physical(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_next_layer(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_this_layer_recurse(), foedus::storage::masstree::Adopt::run(), and foedus::storage::masstree::MasstreeBorderPage::track_moved_record_next_layer().

312  {
313  uint8_t key_count = get_key_count();
315  for (uint8_t i = 0; i < key_count; ++i) {
316  if (slice < separators_[i]) {
317  return i;
318  }
319  }
320  return key_count;
321  }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

MiniPage& foedus::storage::masstree::MasstreeIntermediatePage::get_minipage ( uint8_t  index)
inline

Definition at line 322 of file masstree_page_impl.hpp.

Referenced by foedus::storage::masstree::Adopt::adopt_case_a(), foedus::storage::masstree::Adopt::adopt_case_b(), append_minipage_snapshot(), foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::masstree::count_children_approximate(), foedus::storage::masstree::MasstreeComposer::drop_volatiles(), extract_separators_common(), foedus::storage::masstree::MasstreeStoragePimpl::fatify_first_root_double(), foedus::storage::masstree::MasstreeStoragePimpl::find_border_physical(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::get_high_key(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::get_low_key(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::get_pointer(), foedus::storage::masstree::grow_case_b_common(), initialize_snapshot_page(), initialize_volatile_page(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::is_valid(), foedus::storage::masstree::MasstreeStoragePimpl::load_empty(), foedus::storage::masstree::SplitIntermediate::migrate_pointers(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::next(), foedus::storage::masstree::operator<<(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_this_layer_recurse(), foedus::storage::masstree::MasstreeStoragePimpl::prefetch_pages_normalized_recurse(), release_pages_recursive(), release_pages_recursive_parallel(), foedus::storage::masstree::Adopt::run(), foedus::storage::masstree::MasstreeBorderPage::track_moved_record_next_layer(), verify_separators(), and foedus::storage::masstree::MasstreeStoragePimpl::verify_single_thread_intermediate().

322 { return mini_pages_[index]; }

Here is the caller graph for this function:

const MiniPage& foedus::storage::masstree::MasstreeIntermediatePage::get_minipage ( uint8_t  index) const
inline

Definition at line 323 of file masstree_page_impl.hpp.

323 { return mini_pages_[index]; }
void foedus::storage::masstree::MasstreeIntermediatePage::initialize_snapshot_page ( StorageId  storage_id,
SnapshotPagePointer  page_id,
uint8_t  layer,
uint8_t  level,
KeySlice  low_fence,
KeySlice  high_fence 
)

Definition at line 108 of file masstree_page_impl.cpp.

References get_minipage(), foedus::storage::masstree::MasstreePage::initialize_snapshot_common(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::kMasstreeIntermediatePageType, and foedus::storage::masstree::kMaxIntermediateSeparators.

114  {
116  storage_id,
117  page_id,
119  layer,
120  level,
121  low_fence,
122  high_fence);
123  for (uint16_t i = 0; i <= kMaxIntermediateSeparators; ++i) {
124  get_minipage(i).key_count_ = 0;
125  }
126 }
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
void initialize_snapshot_common(StorageId storage_id, SnapshotPagePointer page_id, PageType page_type, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)

Here is the call graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::initialize_volatile_page ( StorageId  storage_id,
VolatilePagePointer  page_id,
uint8_t  layer,
uint8_t  level,
KeySlice  low_fence,
KeySlice  high_fence 
)

Definition at line 88 of file masstree_page_impl.cpp.

References get_minipage(), foedus::storage::masstree::MasstreePage::initialize_volatile_common(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::kMasstreeIntermediatePageType, and foedus::storage::masstree::kMaxIntermediateSeparators.

Referenced by foedus::storage::masstree::grow_case_b_common(), foedus::storage::masstree::MasstreeStoragePimpl::load_empty(), and foedus::storage::masstree::SplitIntermediate::split_impl_no_error().

94  {
96  storage_id,
97  page_id,
99  layer,
100  level,
101  low_fence,
102  high_fence);
103  for (uint16_t i = 0; i <= kMaxIntermediateSeparators; ++i) {
104  get_minipage(i).key_count_ = 0;
105  }
106 }
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
void initialize_volatile_common(StorageId storage_id, VolatilePagePointer page_id, PageType page_type, uint8_t layer, uint8_t level, KeySlice low_fence, KeySlice high_fence)
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::storage::masstree::MasstreeIntermediatePage::is_full_snapshot ( ) const
inline

Whether this page is full of poiters, used only by snapshot composer (or when no race)

Definition at line 1487 of file masstree_page_impl.hpp.

References ASSERT_ND, foedus::storage::masstree::MasstreePage::get_key_count(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, and foedus::storage::masstree::kMaxIntermediateMiniSeparators.

Referenced by append_minipage_snapshot(), and append_pointer_snapshot().

1487  {
1488  uint16_t keys = get_key_count();
1490  const MiniPage& minipage = mini_pages_[keys];
1491  uint16_t keys_mini = minipage.key_count_;
1493  return keys == kMaxIntermediateSeparators && keys_mini == kMaxIntermediateMiniSeparators;
1494 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
const uint16_t kMaxIntermediateMiniSeparators
Max number of separators stored in the second level of intermediate pages.
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

MasstreeIntermediatePage& foedus::storage::masstree::MasstreeIntermediatePage::operator= ( const MasstreeIntermediatePage other)
delete
void foedus::storage::masstree::MasstreeIntermediatePage::prefetch ( ) const
inline

prefetch upto separators.

Definition at line 305 of file masstree_page_impl.hpp.

References foedus::assorted::prefetch_cachelines().

305  {
307  }
void prefetch_cachelines(const void *address, int cacheline_count)
Prefetch multiple contiguous cachelines to L1 cache.
Definition: cacheline.hpp:66

Here is the call graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive ( const memory::GlobalVolatilePageResolver page_resolver,
memory::PageReleaseBatch batch 
)

Definition at line 226 of file masstree_page_impl.cpp.

References ASSERT_ND, foedus::storage::masstree::MasstreePage::foster_twin_, foedus::storage::masstree::MasstreePage::get_key_count(), get_minipage(), foedus::storage::masstree::MasstreePage::header(), foedus::storage::masstree::MasstreePage::header_, foedus::storage::masstree::MasstreePage::is_empty_range(), foedus::storage::PageVersion::is_moved(), foedus::storage::masstree::MasstreePage::is_moved(), foedus::storage::VolatilePagePointer::is_null(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::masstree::kMaxIntermediateMiniSeparators, foedus::storage::masstree::kMaxIntermediateSeparators, foedus::storage::PageHeader::page_id_, foedus::storage::PageHeader::page_version_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::pointers_, foedus::memory::PageReleaseBatch::release(), release_pages_recursive(), foedus::storage::masstree::MasstreePage::release_pages_recursive_common(), foedus::memory::GlobalVolatilePageResolver::resolve_offset(), foedus::storage::DualPagePointer::volatile_pointer_, and foedus::storage::VolatilePagePointer::word.

Referenced by release_pages_recursive(), and foedus::storage::masstree::MasstreePage::release_pages_recursive_common().

228  {
229  if (!is_empty_range()) {
231  for (int i = 0; i < 2; ++i) {
232  ASSERT_ND(!foster_twin_[i].is_null());
234  reinterpret_cast<MasstreeIntermediatePage*>(
235  page_resolver.resolve_offset(foster_twin_[i]));
236  p->release_pages_recursive(page_resolver, batch);
237  foster_twin_[i].word = 0;
238  }
239  } else {
240  uint16_t key_count = get_key_count();
242  for (uint8_t i = 0; i < key_count + 1; ++i) {
243  MiniPage& minipage = get_minipage(i);
244  uint16_t mini_count = minipage.key_count_;
246  for (uint8_t j = 0; j < mini_count + 1; ++j) {
247  VolatilePagePointer pointer = minipage.pointers_[j].volatile_pointer_;
248  if (!pointer.is_null()) {
249  MasstreePage* child = reinterpret_cast<MasstreePage*>(
250  page_resolver.resolve_offset(pointer));
251  child->release_pages_recursive_common(page_resolver, batch);
252  }
253  }
254  }
255  }
256  } else {
257  ASSERT_ND(!is_moved());
258  ASSERT_ND(get_key_count() == 0);
259  }
260 
261  VolatilePagePointer volatile_id;
262  volatile_id.word = header().page_id_;
263  batch->release(volatile_id);
264 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
bool is_empty_range() const __attribute__((always_inline))
An empty-range page, either intermediate or border, never has any entries.
bool is_moved() const __attribute__((always_inline))
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
const uint16_t kMaxIntermediateMiniSeparators
Max number of separators stored in the second level of intermediate pages.
VolatilePagePointer foster_twin_[2]
Points to foster children, or tentative child pages.
bool is_moved() const __attribute__((always_inline))
Definition: page.hpp:139
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
PageVersion page_version_
Used in several storage types as concurrency control mechanism for the page.
Definition: page.hpp:272
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive_parallel ( Engine engine)

This method is used when we release a large number of volatile pages, most likely when we drop a storage.

In that case, we don't need to stick to the current thread. rather, this thread spawns lots of threads to parallelize the work.

Definition at line 188 of file masstree_page_impl.cpp.

References ASSERT_ND, foedus::storage::masstree::MasstreePage::foster_twin_, foedus::storage::masstree::MasstreePage::get_key_count(), foedus::Engine::get_memory_manager(), get_minipage(), foedus::memory::EngineMemory::get_node_memory(), foedus::storage::VolatilePagePointer::get_numa_node(), foedus::storage::VolatilePagePointer::get_offset(), foedus::storage::masstree::MasstreePage::header(), foedus::storage::masstree::MasstreePage::header_, foedus::storage::PageVersion::is_moved(), foedus::storage::VolatilePagePointer::is_null(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::masstree::kMaxIntermediateMiniSeparators, foedus::storage::masstree::kMaxIntermediateSeparators, foedus::storage::PageHeader::page_id_, foedus::storage::PageHeader::page_version_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::pointers_, foedus::memory::PagePool::release_one(), foedus::storage::masstree::release_parallel(), foedus::storage::DualPagePointer::volatile_pointer_, and foedus::storage::VolatilePagePointer::word.

Referenced by foedus::storage::masstree::MasstreeStoragePimpl::drop().

188  {
189  // so far, we spawn a thread for every single pointer.
190  // it might be an oversubscription, but not a big issue.
191  std::vector<std::thread> threads;
193  for (int i = 0; i < 2; ++i) {
194  ASSERT_ND(!foster_twin_[i].is_null());
195  threads.emplace_back(release_parallel, engine, foster_twin_[i]);
196  }
197  // if this page is moved, following pointers in this page results in double-release.
198  // we just follow pointers in non-moved page.
199  } else {
200  uint16_t key_count = get_key_count();
202  for (uint8_t i = 0; i < key_count + 1; ++i) {
203  MiniPage& minipage = get_minipage(i);
204  uint16_t mini_count = minipage.key_count_;
206  for (uint8_t j = 0; j < mini_count + 1; ++j) {
207  VolatilePagePointer pointer = minipage.pointers_[j].volatile_pointer_;
208  if (!pointer.is_null()) {
209  threads.emplace_back(release_parallel, engine, pointer);
210  }
211  }
212  }
213  }
214 
215  for (auto& t : threads) {
216  t.join();
217  }
218 
219  VolatilePagePointer volatile_id;
220  volatile_id.word = header().page_id_;
221  memory::PagePool* pool = engine->get_memory_manager()->get_node_memory(
222  volatile_id.get_numa_node())->get_volatile_pool();
223  pool->release_one(volatile_id.get_offset());
224 }
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
const uint16_t kMaxIntermediateMiniSeparators
Max number of separators stored in the second level of intermediate pages.
VolatilePagePointer foster_twin_[2]
Points to foster children, or tentative child pages.
bool is_moved() const __attribute__((always_inline))
Definition: page.hpp:139
const uint16_t kMaxIntermediateSeparators
Max number of separators stored in the first level of intermediate pages.
PageVersion page_version_
Used in several storage types as concurrency control mechanism for the page.
Definition: page.hpp:272
void release_parallel(Engine *engine, VolatilePagePointer pointer)
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::set_separator ( uint8_t  minipage_index,
KeySlice  new_separator 
)
inline

Place a new separator for a new minipage.

Definition at line 397 of file masstree_page_impl.hpp.

Referenced by foedus::storage::masstree::Adopt::adopt_case_b().

397  {
398  separators_[minipage_index] = new_separator;
399  }

Here is the caller graph for this function:

void foedus::storage::masstree::MasstreeIntermediatePage::verify_separators ( ) const

Definition at line 475 of file masstree_page_impl.cpp.

References ASSERT_ND, foedus::storage::masstree::MasstreePage::get_key_count(), get_minipage(), foedus::storage::masstree::MasstreePage::high_fence_, foedus::storage::DualPagePointer::is_both_null(), foedus::storage::masstree::MasstreePage::is_empty_range(), foedus::storage::masstree::MasstreePage::is_moved(), foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::key_count_, foedus::storage::masstree::MasstreePage::low_fence_, foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::pointers_, and foedus::storage::masstree::MasstreeIntermediatePage::MiniPage::separators_.

Referenced by foedus::storage::masstree::SplitIntermediate::migrate_pointers(), foedus::storage::masstree::Adopt::run(), and foedus::storage::masstree::SplitIntermediate::split_impl_no_error().

475  {
476 #ifndef NDEBUG
477  if (is_empty_range()) {
478  ASSERT_ND(get_key_count() == 0);
479  ASSERT_ND(!is_moved());
480  return;
481  }
482  for (uint8_t i = 0; i <= get_key_count(); ++i) {
483  KeySlice low, high;
484  if (i < get_key_count()) {
485  if (i > 0) {
486  low = separators_[i - 1];
487  } else {
488  low = low_fence_;
489  }
490  high = separators_[i];
491  ASSERT_ND(separators_[i] > low);
492  } else {
493  ASSERT_ND(i == get_key_count());
494  if (i == 0) {
495  low = low_fence_;
496  } else {
497  low = separators_[i - 1];
498  }
499  high = high_fence_;
500  }
501  const MiniPage& minipage = get_minipage(i);
502  for (uint8_t j = 0; j <= minipage.key_count_; ++j) {
503  ASSERT_ND(!minipage.pointers_[j].is_both_null());
504  if (j < minipage.key_count_) {
505  ASSERT_ND(minipage.separators_[j] > low);
506  ASSERT_ND(minipage.separators_[j] < high);
507  }
508  }
509  }
510 #endif // NDEBUG
511 }
KeySlice high_fence_
Inclusive high fence of this page.
SlotIndex get_key_count() const __attribute__((always_inline))
physical key count (those keys might be deleted) in this page.
bool is_empty_range() const __attribute__((always_inline))
An empty-range page, either intermediate or border, never has any entries.
bool is_moved() const __attribute__((always_inline))
KeySlice low_fence_
Inclusive low fence of this page.
MiniPage & get_minipage(uint8_t index) __attribute__((always_inline))
uint64_t KeySlice
Each key slice is an 8-byte integer.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const MasstreeIntermediatePage v 
)
friend

defined in masstree_page_debug.cpp.

Definition at line 54 of file masstree_page_debug.cpp.

54  {
55  o << "<MasstreeIntermediatePage>";
57  if (v.is_empty_range()) {
58  o << "<EmptyRangePage />";
59  } else {
60  for (uint16_t i = 0; i <= v.get_key_count(); ++i) {
61  const MasstreeIntermediatePage::MiniPage& minipage = v.get_minipage(i);
62  KeySlice minipage_low = i == 0 ? v.get_low_fence() : v.get_separator(i - 1);
63  o << std::endl << " <Minipage index=\"" << static_cast<int>(i)
64  << "\" low=\"" << assorted::Hex(minipage_low, 16)
65  << "\" count=\"" << static_cast<int>(minipage.key_count_)
66  << "\">";
67  for (uint16_t j = 0; j <= minipage.key_count_; ++j) {
68  o << std::endl << " <Pointer index=\"" << static_cast<int>(j)
69  << "\" low=\""
70  << assorted::Hex(j == 0 ? minipage_low : minipage.separators_[j - 1], 16)
71  << "\">" << minipage.pointers_[j] << "</Pointer>";
72  }
73  o << std::endl << " </Minipage>";
74  }
75  }
76  o << "</MasstreeIntermediatePage>";
77  return o;
78 }
void describe_masstree_page_common(std::ostream *o_ptr, const MasstreePage &v)
uint64_t KeySlice
Each key slice is an 8-byte integer.
friend struct SplitIntermediate
friend

Definition at line 264 of file masstree_page_impl.hpp.


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