libfoedus-core
FOEDUS Core Library
foedus::storage::hash::HashIntermediatePage Class Referencefinal

Represents an intermediate page in Hashtable Storage. More...

Detailed Description

Represents an intermediate page in Hashtable Storage.

This is one of the page types in hash. An intermediate page is simply a list of pointers to child pages, which might be intermediate or data pages.

Page Layout
Common PageHeaderHashRange (just for sanity check) DualPagePointerDualPagePointer...

Each page simply contains kHashIntermediatePageFanout pointers to lower level.

Note
Let's not use the word 'leaf' in hash storage. We previously called intermediate pages whose get_level()==0 as leaves, but it's confusing. A leaf page usually means a last-level page that contains tuple data. Here, such a page still points to lower level (data pages). So, we should call it something like "level-0 intermediate" or just "level-0".

Definition at line 64 of file hash_page_impl.hpp.

#include <hash_page_impl.hpp>

Public Member Functions

 HashIntermediatePage ()=delete
 
 HashIntermediatePage (const HashIntermediatePage &other)=delete
 
HashIntermediatePageoperator= (const HashIntermediatePage &other)=delete
 
PageHeaderheader ()
 
const PageHeaderheader () const
 
VolatilePagePointer get_volatile_page_id () const
 
SnapshotPagePointer get_snapshot_page_id () const
 
DualPagePointerget_pointer (uint16_t index)
 
const DualPagePointerget_pointer (uint16_t index) const
 
DualPagePointerget_pointer_address (uint16_t index)
 
const DualPagePointerget_pointer_address (uint16_t index) const
 
void initialize_volatile_page (StorageId storage_id, VolatilePagePointer page_id, const HashIntermediatePage *parent, uint8_t level, HashBin start_bin)
 Called only when this page is initialized. More...
 
void initialize_snapshot_page (StorageId storage_id, SnapshotPagePointer page_id, uint8_t level, HashBin start_bin)
 
void release_pages_recursive_parallel (Engine *engine)
 
void release_pages_recursive (const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
 
const HashBinRangeget_bin_range () const
 
uint8_t get_level () const
 
void assert_bin (HashBin bin) const __attribute__((always_inline))
 
void assert_range () const __attribute__((always_inline))
 
uint64_t get_dummy_padding_unused () const
 

Friends

std::ostream & operator<< (std::ostream &o, const HashIntermediatePage &v)
 defined in hash_page_debug.cpp. More...
 

Constructor & Destructor Documentation

foedus::storage::hash::HashIntermediatePage::HashIntermediatePage ( )
delete
foedus::storage::hash::HashIntermediatePage::HashIntermediatePage ( const HashIntermediatePage other)
delete

Member Function Documentation

void foedus::storage::hash::HashIntermediatePage::assert_bin ( HashBin  bin) const
inline

Definition at line 107 of file hash_page_impl.hpp.

References ASSERT_ND, and foedus::storage::hash::HashBinRange::contains().

107  {
108  ASSERT_ND(bin_range_.contains(bin));
109  }
bool contains(HashBin hash) const
Definition: hash_id.hpp:176
#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::hash::HashIntermediatePage::assert_range ( ) const
inline

Definition at line 110 of file hash_page_impl.hpp.

References ASSERT_ND, get_level(), foedus::storage::hash::kHashMaxBins, and foedus::storage::hash::HashBinRange::length().

Referenced by foedus::storage::hash::HashStoragePimpl::create().

110  {
111  ASSERT_ND(bin_range_.length() == kHashMaxBins[get_level() + 1U]);
112  }
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
Definition: hash_id.hpp:74
#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:

uint64_t foedus::storage::hash::HashIntermediatePage::get_dummy_padding_unused ( ) const
inline

Definition at line 117 of file hash_page_impl.hpp.

117 { return padding_; }
uint8_t foedus::storage::hash::HashIntermediatePage::get_level ( ) const
inline
const DualPagePointer& foedus::storage::hash::HashIntermediatePage::get_pointer ( uint16_t  index) const
inline

Definition at line 81 of file hash_page_impl.hpp.

81 { return pointers_[index]; }
DualPagePointer* foedus::storage::hash::HashIntermediatePage::get_pointer_address ( uint16_t  index)
inline

Definition at line 82 of file hash_page_impl.hpp.

Referenced by foedus::storage::hash::HashStoragePimpl::follow_page_bin_head(), and foedus::storage::hash::ComposedBinsMergedStream::process_a_bin().

82 { return pointers_ + index; }

Here is the caller graph for this function:

const DualPagePointer* foedus::storage::hash::HashIntermediatePage::get_pointer_address ( uint16_t  index) const
inline

Definition at line 83 of file hash_page_impl.hpp.

83 { return pointers_ + index; }
SnapshotPagePointer foedus::storage::hash::HashIntermediatePage::get_snapshot_page_id ( ) const
inline

Definition at line 76 of file hash_page_impl.hpp.

References ASSERT_ND, foedus::storage::PageHeader::page_id_, and foedus::storage::PageHeader::snapshot_.

76  {
77  ASSERT_ND(header_.snapshot_);
78  return static_cast<SnapshotPagePointer>(header_.page_id_);
79  }
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Definition: storage_id.hpp:79
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
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191
VolatilePagePointer foedus::storage::hash::HashIntermediatePage::get_volatile_page_id ( ) const
inline

Definition at line 72 of file hash_page_impl.hpp.

References ASSERT_ND, foedus::storage::PageHeader::page_id_, and foedus::storage::PageHeader::snapshot_.

72  {
73  ASSERT_ND(!header_.snapshot_);
74  return VolatilePagePointer(header_.page_id_);
75  }
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
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191
const PageHeader& foedus::storage::hash::HashIntermediatePage::header ( ) const
inline

Definition at line 71 of file hash_page_impl.hpp.

71 { return header_; }
void foedus::storage::hash::HashIntermediatePage::initialize_snapshot_page ( StorageId  storage_id,
SnapshotPagePointer  page_id,
uint8_t  level,
HashBin  start_bin 
)

Definition at line 58 of file hash_page_impl.cpp.

References foedus::storage::hash::HashBinRange::begin_, foedus::storage::hash::HashBinRange::end_, foedus::storage::PageHeader::init_snapshot(), foedus::storage::kHashIntermediatePageType, foedus::storage::hash::kHashMaxBins, foedus::storage::kPageSize, and foedus::storage::PageHeader::set_in_layer_level().

Referenced by foedus::storage::hash::HashComposer::construct_root(), and foedus::storage::hash::ComposedBinsMergedStream::open_path().

62  {
63  std::memset(this, 0, kPageSize);
64  header_.init_snapshot(page_id, storage_id, kHashIntermediatePageType);
65  bin_range_.begin_ = start_bin;
66  bin_range_.end_ = bin_range_.begin_ + kHashMaxBins[level + 1U];
67  header_.set_in_layer_level(level);
68 }
HashBin begin_
Inclusive beginning of the range.
Definition: hash_id.hpp:191
HashBin end_
Exclusive end of the range.
Definition: hash_id.hpp:193
void init_snapshot(SnapshotPagePointer page_id, StorageId storage_id, PageType page_type) __attribute__((always_inline))
Definition: page.hpp:301
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
Definition: hash_id.hpp:74
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
Definition: storage_id.hpp:45
void set_in_layer_level(uint8_t level)
Definition: page.hpp:282

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::hash::HashIntermediatePage::initialize_volatile_page ( StorageId  storage_id,
VolatilePagePointer  page_id,
const HashIntermediatePage parent,
uint8_t  level,
HashBin  start_bin 
)

Called only when this page is initialized.

Definition at line 40 of file hash_page_impl.cpp.

References ASSERT_ND, foedus::storage::hash::HashBinRange::begin_, foedus::storage::hash::HashBinRange::contains(), foedus::storage::hash::HashBinRange::end_, get_level(), foedus::storage::PageHeader::init_volatile(), foedus::storage::kHashIntermediatePageType, foedus::storage::hash::kHashMaxBins, foedus::storage::kPageSize, and foedus::storage::PageHeader::set_in_layer_level().

Referenced by foedus::storage::hash::HashStoragePimpl::create(), and foedus::storage::hash::hash_intermediate_volatile_page_init().

45  {
46  std::memset(this, 0, kPageSize);
47  header_.init_volatile(page_id, storage_id, kHashIntermediatePageType);
48  bin_range_.begin_ = start_bin;
49  bin_range_.end_ = bin_range_.begin_ + kHashMaxBins[level + 1U];
50  header_.set_in_layer_level(level);
51  if (parent) {
52  ASSERT_ND(parent->get_level() > 0);
53  ASSERT_ND(level + 1U == parent->get_level());
54  ASSERT_ND(parent->bin_range_.contains(bin_range_));
55  }
56 }
void init_volatile(VolatilePagePointer page_id, StorageId storage_id, PageType page_type) __attribute__((always_inline))
Definition: page.hpp:284
HashBin begin_
Inclusive beginning of the range.
Definition: hash_id.hpp:191
HashBin end_
Exclusive end of the range.
Definition: hash_id.hpp:193
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
Definition: hash_id.hpp:74
#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
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
Definition: storage_id.hpp:45
void set_in_layer_level(uint8_t level)
Definition: page.hpp:282

Here is the call graph for this function:

Here is the caller graph for this function:

HashIntermediatePage& foedus::storage::hash::HashIntermediatePage::operator= ( const HashIntermediatePage other)
delete
void foedus::storage::hash::HashIntermediatePage::release_pages_recursive ( const memory::GlobalVolatilePageResolver page_resolver,
memory::PageReleaseBatch batch 
)

Definition at line 302 of file hash_page_impl.cpp.

References ASSERT_ND, foedus::storage::VolatilePagePointer::clear(), foedus::storage::PageHeader::get_in_layer_level(), get_level(), foedus::storage::PageHeader::get_page_type(), header(), foedus::storage::hash::HashDataPage::header(), foedus::storage::VolatilePagePointer::is_null(), foedus::storage::kHashDataPageType, foedus::storage::hash::kHashIntermediatePageFanout, foedus::storage::kHashIntermediatePageType, foedus::storage::PageHeader::page_id_, foedus::memory::PageReleaseBatch::release(), release_pages_recursive(), foedus::storage::hash::HashDataPage::release_pages_recursive(), foedus::memory::GlobalVolatilePageResolver::resolve_offset(), foedus::storage::DualPagePointer::volatile_pointer_, and foedus::storage::VolatilePagePointer::word.

Referenced by release_pages_recursive(), release_pages_recursive_parallel(), and foedus::storage::hash::release_parallel().

304  {
305  for (uint8_t i = 0; i < kHashIntermediatePageFanout; ++i) {
306  VolatilePagePointer pointer = pointers_[i].volatile_pointer_;
307  if (!pointer.is_null()) {
308  Page* page = page_resolver.resolve_offset(pointer);
309  if (get_level() == 0) {
310  HashDataPage* child = reinterpret_cast<HashDataPage*>(page);
311  ASSERT_ND(child->header().get_page_type() == kHashDataPageType);
312  ASSERT_ND(child->header().get_in_layer_level() == 0);
313  child->release_pages_recursive(page_resolver, batch);
314  } else {
315  HashIntermediatePage* child = reinterpret_cast<HashIntermediatePage*>(page);
316  ASSERT_ND(child->header().get_page_type() == kHashIntermediatePageType);
317  ASSERT_ND(child->get_level() + 1U == get_level());
318  child->release_pages_recursive(page_resolver, batch);
319  }
320  pointer.clear();
321  }
322  }
323 
324  VolatilePagePointer volatile_id;
325  volatile_id.word = header().page_id_;
326  batch->release(volatile_id);
327 }
VolatilePagePointer volatile_pointer_
Definition: storage_id.hpp:308
const uint8_t kHashIntermediatePageFanout
Number of pointers in an intermediate page of hash storage.
Definition: hash_id.hpp:49
#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::hash::HashIntermediatePage::release_pages_recursive_parallel ( Engine engine)

Definition at line 271 of file hash_page_impl.cpp.

References foedus::memory::EngineMemory::get_global_volatile_page_resolver(), get_level(), foedus::Engine::get_memory_manager(), foedus::memory::EngineMemory::get_node_memory(), foedus::storage::VolatilePagePointer::get_numa_node(), foedus::storage::VolatilePagePointer::get_offset(), header(), foedus::storage::VolatilePagePointer::is_null(), foedus::storage::hash::kHashIntermediatePageFanout, foedus::storage::PageHeader::page_id_, foedus::memory::PageReleaseBatch::release_all(), foedus::memory::PagePool::release_one(), release_pages_recursive(), foedus::storage::hash::release_parallel(), foedus::storage::DualPagePointer::volatile_pointer_, and foedus::storage::VolatilePagePointer::word.

Referenced by foedus::storage::hash::HashStoragePimpl::drop().

271  {
272  if (get_level() == 0) {
273  // root page is a leaf page.. don't bother parallelize.
274  const memory::GlobalVolatilePageResolver& page_resolver
275  = engine->get_memory_manager()->get_global_volatile_page_resolver();
276  memory::PageReleaseBatch release_batch(engine);
277  release_pages_recursive(page_resolver, &release_batch);
278  release_batch.release_all();
279  } else {
280  // so far, we spawn a thread for every single pointer.
281  // it might be an oversubscription, but not a big issue.
282  std::vector<std::thread> threads;
283  for (uint8_t i = 0; i < kHashIntermediatePageFanout; ++i) {
284  VolatilePagePointer pointer = pointers_[i].volatile_pointer_;
285  if (!pointer.is_null()) {
286  threads.emplace_back(release_parallel, engine, pointer);
287  }
288  }
289 
290  for (auto& t : threads) {
291  t.join();
292  }
293 
294  VolatilePagePointer volatile_id;
295  volatile_id.word = header().page_id_;
296  memory::PagePool* pool = engine->get_memory_manager()->get_node_memory(
297  volatile_id.get_numa_node())->get_volatile_pool();
298  pool->release_one(volatile_id.get_offset());
299  }
300 }
VolatilePagePointer volatile_pointer_
Definition: storage_id.hpp:308
void release_parallel(Engine *engine, VolatilePagePointer pointer)
const uint8_t kHashIntermediatePageFanout
Number of pointers in an intermediate page of hash storage.
Definition: hash_id.hpp:49
void release_pages_recursive(const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
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:

Friends And Related Function Documentation

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

defined in hash_page_debug.cpp.

Definition at line 31 of file hash_page_debug.cpp.

31  {
32  o << "<HashIntermediatePage>";
33  o << std::endl << " <vaddr>" << assorted::Hex(reinterpret_cast<uintptr_t>(&v), 16) << "</vaddr>";
34  o << std::endl << " " << v.header();
35  o << std::endl << " <level>" << static_cast<int>(v.get_level()) << "</level>";
36  o << std::endl << " " << v.get_bin_range();
37  HashBin total_begin = v.get_bin_range().begin_;
38  HashBin interval = kHashMaxBins[v.get_level()];
39  for (uint16_t i = 0; i < kHashIntermediatePageFanout; ++i) {
40  DualPagePointer pointer = v.get_pointer(i);
41  if (pointer.is_both_null()) {
42  continue;
43  }
44  o << std::endl << " <Pointer index=\"" << static_cast<int>(i)
45  << "\" bin_begin=\"" << (total_begin + i * interval)
46  << "\">" << pointer << "</Pointer>";
47  }
48  o << "</HashIntermediatePage>";
49  return o;
50 }
uint64_t HashBin
Represents a bin of a hash value.
Definition: hash_id.hpp:142
const uint8_t kHashIntermediatePageFanout
Number of pointers in an intermediate page of hash storage.
Definition: hash_id.hpp:49
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
Definition: hash_id.hpp:74

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