libfoedus-core
FOEDUS Core Library
foedus::storage::hash::IntermediateRoute Union Reference

Compactly represents the route of intermediate pages to reach the given hash bin. More...

Detailed Description

Compactly represents the route of intermediate pages to reach the given hash bin.

Like array package, kHashIntermediatePageFanout is less than 256, so we have a similar route struct. The only difference is that this is about intermediate pages (bins). Data pages have no notion of route unlike array package.

Definition at line 196 of file hash_hashinate.hpp.

#include <hash_hashinate.hpp>

Public Member Functions

bool operator== (const IntermediateRoute &rhs) const
 
bool operator!= (const IntermediateRoute &rhs) const
 
bool operator< (const IntermediateRoute &rhs) const
 
bool operator<= (const IntermediateRoute &rhs) const
 
HashBin convert_back () const
 

Static Public Member Functions

static IntermediateRoute construct (HashBin bin)
 Calculates the rout for the given hash bin. More...
 

Public Attributes

uint64_t word
 This is a 64bit data. More...
 
uint8_t route [8]
 [0] means ordinal in level-0 intermediate page, [1] in its parent page, [2]... More...
 

Friends

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

Member Function Documentation

static IntermediateRoute foedus::storage::hash::IntermediateRoute::construct ( HashBin  bin)
inlinestatic

Calculates the rout for the given hash bin.

Definition at line 233 of file hash_hashinate.hpp.

References ASSERT_ND, convert_back(), foedus::storage::hash::kHashIntermediatePageFanout, route, and word.

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

233  {
234  IntermediateRoute ret;
235  ret.word = 0;
236  uint8_t level = 0;
237  HashBin remaining = bin;
238  while (remaining > 0) {
239  // in hash, fanout is always fixed, so no need for pre-calculated const_div. compiler does it.
240  ret.route[level] = remaining % kHashIntermediatePageFanout;
241  remaining /= kHashIntermediatePageFanout;
242  ++level;
243  ASSERT_ND(level < 8U);
244  }
245 
246  ASSERT_ND(ret.convert_back() == bin);
247  return ret;
248  }
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
#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:

HashBin foedus::storage::hash::IntermediateRoute::convert_back ( ) const
inline
Returns
the original hash bin for this route Probably used only for sanity checks.

Definition at line 224 of file hash_hashinate.hpp.

References foedus::storage::hash::kHashMaxBins, and foedus::storage::hash::kHashMaxLevels.

Referenced by construct().

224  {
225  HashBin bin = 0;
226  for (uint8_t level = 0; level < kHashMaxLevels; ++level) {
227  bin += route[level] * kHashMaxBins[level];
228  }
229  return bin;
230  }
const uint8_t kHashMaxLevels
Max level of intermediate pages.
Definition: hash_id.hpp:104
uint8_t route[8]
[0] means ordinal in level-0 intermediate page, [1] in its parent page, [2]...
uint64_t HashBin
Represents a bin of a hash value.
Definition: hash_id.hpp:142
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
Definition: hash_id.hpp:74

Here is the caller graph for this function:

bool foedus::storage::hash::IntermediateRoute::operator!= ( const IntermediateRoute rhs) const
inline

Definition at line 206 of file hash_hashinate.hpp.

References word.

206 { return word != rhs.word; }
uint64_t word
This is a 64bit data.
bool foedus::storage::hash::IntermediateRoute::operator< ( const IntermediateRoute rhs) const
inline

Definition at line 207 of file hash_hashinate.hpp.

References route.

207  {
208  for (uint16_t i = 1; i <= 8U; ++i) {
209  // compare the higher level first. if the machine is big-endian, we can just compare word.
210  // but, this method is not used in performance-sensitive place, so let's be explicit.
211  if (route[8U - i] != rhs.route[8U - i]) {
212  return route[8U - i] < rhs.route[8U - i];
213  }
214  }
215  return false;
216  }
uint8_t route[8]
[0] means ordinal in level-0 intermediate page, [1] in its parent page, [2]...
bool foedus::storage::hash::IntermediateRoute::operator<= ( const IntermediateRoute rhs) const
inline

Definition at line 217 of file hash_hashinate.hpp.

217 { return *this == rhs || *this < rhs; }
bool foedus::storage::hash::IntermediateRoute::operator== ( const IntermediateRoute rhs) const
inline

Definition at line 205 of file hash_hashinate.hpp.

References word.

205 { return word == rhs.word; }
uint64_t word
This is a 64bit data.

Friends And Related Function Documentation

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

Definition at line 64 of file hash_hashinate.cpp.

64  {
65  o << "<Route>";
66  for (uint8_t i = 0; i < 8U; ++i) {
67  o << assorted::Hex(v.route[i], 2) << " ";
68  }
69  o << "</Route>";
70  return o;
71 }

Member Data Documentation

uint8_t foedus::storage::hash::IntermediateRoute::route[8]

[0] means ordinal in level-0 intermediate page, [1] in its parent page, [2]...

[levels - 1] is the ordinal in root intermediate page.

Definition at line 203 of file hash_hashinate.hpp.

Referenced by construct(), foedus::storage::hash::HashStoragePimpl::locate_bin(), foedus::storage::hash::ComposedBinsMergedStream::open_path(), operator<(), and foedus::storage::hash::operator<<().

uint64_t foedus::storage::hash::IntermediateRoute::word

This is a 64bit data.

Definition at line 198 of file hash_hashinate.hpp.

Referenced by construct(), operator!=(), and operator==().


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