18 #ifndef FOEDUS_STORAGE_ARRAY_ARRAY_ROUTE_HPP_
19 #define FOEDUS_STORAGE_ARRAY_ARRAY_ROUTE_HPP_
53 uint16_t payload_size,
59 for (uint16_t i = 1; i <= 8U; ++i) {
62 if (route[8U - i] != rhs.
route[8U - i]) {
63 return route[8U - i] < rhs.
route[8U - i];
92 interior_fanout_div_(1) {
97 leaf_fanout_div_(records_in_leaf_),
127 uint16_t records_in_leaf_;
138 offset = leaf_fanout_div_.
div64(offset);
139 ret.
route[0] = old - offset * records_in_leaf_;
140 for (uint8_t level = 1; level < levels_ - 1; ++level) {
142 offset = interior_fanout_div_.
div64(offset);
148 ret.
route[levels_ - 1] = offset;
161 offset = leaf_fanout_div_.
div64(offset);
162 *page_starts = offset * records_in_leaf_;
163 *page_ends = *page_starts + records_in_leaf_;
164 ret.
route[0] = old - (*page_starts);
165 for (uint8_t level = 1; level < levels_ - 1; ++level) {
167 offset = interior_fanout_div_.
div64(offset);
173 ret.
route[levels_ - 1] = offset;
181 uint8_t total_levels,
182 uint16_t payload_size,
188 uint64_t interval = records_in_leaf;
193 if (page_level == 0) {
194 ret.
end_ = records_in_leaf;
196 for (uint16_t level = 1; level < total_levels; ++level) {
197 if (level == page_level) {
201 }
else if (level > page_level) {
202 uint64_t shift = interval *
route[level];
210 if (ret.
end_ > array_size) {
211 ret.
end_ = array_size;
219 #endif // FOEDUS_STORAGE_ARRAY_ARRAY_ROUTE_HPP_
T align8(T value)
8-alignment.
const uint16_t kRecordOverhead
Byte size of system-managed region per each record.
uint8_t route[8]
[0] means record ordinal in leaf, [1] in its parent page, [2]...
Compactly represents the route to reach the given offset.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
uint64_t ArrayOffset
The only key type in array storage.
uint64_t word
This is a 64bit data.
The pre-calculated p-m pair for optimized integer division by constant.
const uint16_t kDataSize
Byte size of data region in each page of array storage.
bool operator<=(const LookupRoute &rhs) const
ArrayOffset begin_
Inclusive beginning of the offset range.
bool operator!=(const LookupRoute &rhs) const
ArrayOffset end_
Exclusive end of the offset range.
uint16_t to_records_in_leaf(uint16_t payload_size)
bool operator==(const LookupRoute &rhs) const
LookupRoute find_route(ArrayOffset offset) const __attribute__((always_inline))
uint8_t get_levels() const __attribute__((always_inline))
LookupRoute find_route_and_switch(ArrayOffset offset, ArrayOffset *page_starts, ArrayOffset *page_ends) const __attribute__((always_inline))
find_route() plus calculates where page switches.
ArrayRange calculate_page_range(uint8_t page_level, uint8_t total_levels, uint16_t payload_size, ArrayOffset array_size) const
Represents an offset range in an array storage.
Packages logic and required properties to calculate LookupRoute in array storage from offset...
uint16_t get_records_in_leaf() const __attribute__((always_inline))
bool operator<(const LookupRoute &rhs) const
Definitions of IDs in this package and a few related constant values.
LookupRouteFinder(uint8_t levels, uint16_t payload_size)
const uint16_t kInteriorFanout
Max number of entries in an interior page of array storage.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
uint64_t div64(uint64_t n) const
64-bit integer division that outputs both quotient and remainder.
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.