libfoedus-core
FOEDUS Core Library
foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo Struct Reference

Represents a minimal information to install a new snapshot page pointer. More...

Detailed Description

Represents a minimal information to install a new snapshot page pointer.

Definition at line 259 of file masstree_composer_impl.hpp.

#include <masstree_composer_impl.hpp>

Public Member Functions

 PageBoundaryInfo ()=delete
 This object must be reinterpreted. More...
 
 ~PageBoundaryInfo ()=delete
 
uint32_t dynamic_sizeof () const __attribute__((always_inline))
 
SnapshotLocalPageId get_local_page_id () const __attribute__((always_inline))
 
bool exact_match (uint8_t btree_level, uint8_t layer, const KeySlice *prefixes, KeySlice low, KeySlice high) const __attribute__((always_inline))
 returns whether the entry exactly matches with the page boundaries we look for. More...
 

Static Public Member Functions

static uint32_t calculate_hash (uint8_t btree_level, uint8_t layer, const KeySlice *prefixes, KeySlice low_fence, KeySlice high_fence) __attribute__((always_inline))
 

Public Attributes

uint8_t btree_level_
 B-tree level. More...
 
uint8_t removed_
 set to true when this page is closed/reopened so that only one entry matches exactly More...
 
uint8_t layer_
 B-trie layer of the new page. More...
 
uint8_t local_snapshot_pointer_high_
 high 8-bits of SnapshotLocalPageId of the new page. More...
 
uint32_t local_snapshot_pointer_low_
 low 32-bits of SnapshotLocalPageId of the new page. More...
 
KeySlice slices_ [2]
 actually of layer_+2. More...
 

Constructor & Destructor Documentation

foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::PageBoundaryInfo ( )
delete

This object must be reinterpreted.

Also, sizeof does not work.

foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::~PageBoundaryInfo ( )
delete

Member Function Documentation

static uint32_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::calculate_hash ( uint8_t  btree_level,
uint8_t  layer,
const KeySlice prefixes,
KeySlice  low_fence,
KeySlice  high_fence 
)
inlinestatic

Definition at line 292 of file masstree_composer_impl.hpp.

297  {
298  // good old multiply-hash
299  uint64_t hash = btree_level + (layer * 256U);
300  const uint64_t kMult = 0x7ada20dc734afb6fULL;
301  for (uint8_t i = 0; i < layer; ++i) {
302  hash = hash * kMult + prefixes[i];
303  }
304  hash = hash * kMult + low_fence;
305  hash = hash * kMult + high_fence;
306  uint32_t compressed = static_cast<uint32_t>(hash >> 32) ^ static_cast<uint32_t>(hash);
307  return compressed;
308  }
uint32_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::dynamic_sizeof ( ) const
inline

Definition at line 291 of file masstree_composer_impl.hpp.

291 { return (layer_ + 2U) * sizeof(KeySlice) + 8U; }
uint64_t KeySlice
Each key slice is an 8-byte integer.
bool foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::exact_match ( uint8_t  btree_level,
uint8_t  layer,
const KeySlice prefixes,
KeySlice  low,
KeySlice  high 
) const
inline

returns whether the entry exactly matches with the page boundaries we look for.

There must be only one entry that exactly matches. To guarantee this, we have to remove an old entry when we close/re-open the same page during this execution. It should happen rarely (when flush_buffer() is called).

See also
removed_

Definition at line 321 of file masstree_composer_impl.hpp.

References layer_.

326  {
327  if (layer != layer_ || btree_level != btree_level_ || removed_) {
328  return false;
329  }
330  for (uint8_t i = 0; i < layer_; ++i) {
331  if (prefixes[i] != slices_[i]) {
332  return false;
333  }
334  }
335  return low == slices_[layer_] && high == slices_[layer_ + 1];
336  }
uint8_t removed_
set to true when this page is closed/reopened so that only one entry matches exactly ...
SnapshotLocalPageId foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::get_local_page_id ( ) const
inline

Definition at line 309 of file masstree_composer_impl.hpp.

References local_snapshot_pointer_high_.

309  {
310  return static_cast<SnapshotLocalPageId>(local_snapshot_pointer_high_) << 32
311  | static_cast<SnapshotLocalPageId>(local_snapshot_pointer_low_);
312  }
uint64_t SnapshotLocalPageId
Represents a local page ID in each one snapshot file in some NUMA node.
Definition: storage_id.hpp:89
uint32_t local_snapshot_pointer_low_
low 32-bits of SnapshotLocalPageId of the new page.
uint8_t local_snapshot_pointer_high_
high 8-bits of SnapshotLocalPageId of the new page.

Member Data Documentation

uint8_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::btree_level_

B-tree level.

Note that it IS possible that we have two pages with the exact same prefix and fences, but in different levels. We hit the case as a rare bug like this: This happens when the tail page of the growing level has only one pointer. eg. Btree-level-0 : A, B, ... E, F, ..., X, Y, Z. We had 26 pages. and we closed it. Now the B-tree level-1 replaces the last level, which usually has much coarser keys. HOWEVER, unluckily, it's like this: A-E, E-K, ... V-Y, ***Y-Z***. Here, the intermediate page Y-Z only has one pointer. In this case, both the level-0 page (Z) and the level-1 page has Y-Z as the range.

Definition at line 270 of file masstree_composer_impl.hpp.

uint8_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::layer_

B-trie layer of the new page.

layer_+2 slices are stored.

Definition at line 274 of file masstree_composer_impl.hpp.

Referenced by exact_match().

uint8_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::local_snapshot_pointer_high_

high 8-bits of SnapshotLocalPageId of the new page.

Definition at line 276 of file masstree_composer_impl.hpp.

Referenced by get_local_page_id().

uint32_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::local_snapshot_pointer_low_

low 32-bits of SnapshotLocalPageId of the new page.

Definition at line 278 of file masstree_composer_impl.hpp.

uint8_t foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::removed_

set to true when this page is closed/reopened so that only one entry matches exactly

Definition at line 272 of file masstree_composer_impl.hpp.

KeySlice foedus::storage::masstree::MasstreeComposeContext::PageBoundaryInfo::slices_[2]

actually of layer_+2.

which is why sizeof does not work. slices_[0] to slices_[layer_-1] store prefix slices. slices_[layer_] is the low_fence, slices_[layer_+1] is the high fence of the new page.

Definition at line 285 of file masstree_composer_impl.hpp.


The documentation for this struct was generated from the following file: