libfoedus-core
FOEDUS Core Library
foedus::storage::array::LookupRoute Union Reference

Compactly represents the route to reach the given offset. More...

Detailed Description

Compactly represents the route to reach the given offset.

Fanout cannot exceed 256 (as empty-payload is not allowed, minimal entry size is 16 bytes in both leaf and interior, 4096/16=256), uint8_t is enough to represent the route. Also, interior page always has a big fanout close to 256, so 8 levels are more than enough.

Definition at line 41 of file array_route.hpp.

#include <array_route.hpp>

Public Member Functions

ArrayRange calculate_page_range (uint8_t page_level, uint8_t total_levels, uint16_t payload_size, ArrayOffset array_size) const
 
bool operator== (const LookupRoute &rhs) const
 
bool operator!= (const LookupRoute &rhs) const
 
bool operator< (const LookupRoute &rhs) const
 
bool operator<= (const LookupRoute &rhs) const
 

Public Attributes

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

Member Function Documentation

ArrayRange foedus::storage::array::LookupRoute::calculate_page_range ( uint8_t  page_level,
uint8_t  total_levels,
uint16_t  payload_size,
ArrayOffset  array_size 
) const
inline

Definition at line 179 of file array_route.hpp.

References ASSERT_ND, foedus::storage::array::ArrayRange::begin_, foedus::storage::array::ArrayRange::end_, foedus::storage::array::kInteriorFanout, route, and foedus::storage::array::to_records_in_leaf().

183  {
184  ASSERT_ND(total_levels > page_level);
185  ASSERT_ND(payload_size > 0);
186  ASSERT_ND(array_size > 0);
187  uint16_t records_in_leaf = to_records_in_leaf(payload_size);
188  uint64_t interval = records_in_leaf;
189  // for example:
190  // page_level==0, route={xxx, 3, 4} (levels=3): r*3 + r*kInteriorFanout*4 ~ +r
191  // page_level==1, route={xxx, yyy, 4} (levels=3): r*kInteriorFanout*4 ~ +r*kInteriorFanout
192  ArrayRange ret(0, 0);
193  if (page_level == 0) {
194  ret.end_ = records_in_leaf;
195  }
196  for (uint16_t level = 1; level < total_levels; ++level) {
197  if (level == page_level) {
198  ASSERT_ND(ret.begin_ == 0);
199  ASSERT_ND(ret.end_ == 0);
200  ret.end_ = interval * kInteriorFanout;
201  } else if (level > page_level) {
202  uint64_t shift = interval * route[level];
203  ret.begin_ += shift;
204  ret.end_ += shift;
205  }
206  interval *= kInteriorFanout;
207  }
208  ASSERT_ND(ret.begin_ < ret.end_);
209  ASSERT_ND(ret.begin_ < array_size);
210  if (ret.end_ > array_size) {
211  ret.end_ = array_size;
212  }
213  return ret;
214 }
uint8_t route[8]
[0] means record ordinal in leaf, [1] in its parent page, [2]...
Definition: array_route.hpp:48
uint16_t to_records_in_leaf(uint16_t payload_size)
Definition: array_route.hpp:71
const uint16_t kInteriorFanout
Max number of entries in an interior page of array storage.
Definition: array_id.hpp:110
#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:

bool foedus::storage::array::LookupRoute::operator!= ( const LookupRoute rhs) const
inline

Definition at line 57 of file array_route.hpp.

References word.

57 { return word != rhs.word; }
uint64_t word
This is a 64bit data.
Definition: array_route.hpp:43
bool foedus::storage::array::LookupRoute::operator< ( const LookupRoute rhs) const
inline

Definition at line 58 of file array_route.hpp.

References route.

58  {
59  for (uint16_t i = 1; i <= 8U; ++i) {
60  // compare the higher level first. if the machine is big-endian, we can just compare word.
61  // but, this method is not used in performance-sensitive place, so let's be explicit.
62  if (route[8U - i] != rhs.route[8U - i]) {
63  return route[8U - i] < rhs.route[8U - i];
64  }
65  }
66  return false;
67  }
uint8_t route[8]
[0] means record ordinal in leaf, [1] in its parent page, [2]...
Definition: array_route.hpp:48
bool foedus::storage::array::LookupRoute::operator<= ( const LookupRoute rhs) const
inline

Definition at line 68 of file array_route.hpp.

68 { return *this == rhs || *this < rhs; }
bool foedus::storage::array::LookupRoute::operator== ( const LookupRoute rhs) const
inline

Definition at line 56 of file array_route.hpp.

References word.

56 { return word == rhs.word; }
uint64_t word
This is a 64bit data.
Definition: array_route.hpp:43

Member Data Documentation

uint8_t foedus::storage::array::LookupRoute::route[8]
uint64_t foedus::storage::array::LookupRoute::word

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