libfoedus-core
FOEDUS Core Library
|
Represents a cursor object for Masstree storage. More...
Represents a cursor object for Masstree storage.
Definition at line 75 of file masstree_cursor.hpp.
#include <masstree_cursor.hpp>
Classes | |
struct | Route |
Represents one page in the current search path from layer0-root. More... | |
Public Types | |
enum | SearchType { kForwardInclusive = 0, kForwardExclusive, kBackwardInclusive, kBackwardExclusive } |
enum | KeyCompareResult { kCurKeySmaller, kCurKeyEquals, kCurKeyLarger, kCurKeyBeingsWith, kCurKeyContains } |
enum | Constants { kMaxRecords = kBorderPageMaxSlots, kMaxRoutes = kPageSize / sizeof(Route), kKeyLengthExtremum = 0 } |
Public Member Functions | |
MasstreeCursor (MasstreeStorage storage, thread::Thread *context) | |
thread::Thread * | get_context () |
MasstreeStorage & | get_storage () |
bool | is_for_writes () const |
bool | is_forward_cursor () const |
ErrorCode | open (const char *begin_key=nullptr, KeyLength begin_key_length=kKeyLengthExtremum, const char *end_key=nullptr, KeyLength end_key_length=kKeyLengthExtremum, bool forward_cursor=true, bool for_writes=false, bool begin_inclusive=true, bool end_inclusive=false) |
ErrorCode | open_normalized (KeySlice begin_key, KeySlice end_key, bool forward_cursor=true, bool for_writes=false, bool begin_inclusive=true, bool end_inclusive=false) |
bool | is_valid_record () const __attribute__((always_inline)) |
KeyLength | get_key_length () const __attribute__((always_inline)) |
Returns the length of the whole key we are currently pointing to. More... | |
const KeySlice * | get_cur_route_prefix_slices () const __attribute__((always_inline)) |
Returns the prefix slices upto the current page. More... | |
const char * | get_cur_route_prefix_be () const __attribute__((always_inline)) |
Big-endian version. More... | |
KeySlice | get_key_in_layer_slice () const __attribute__((always_inline)) |
Returns only the slice of the key in the layer of the current page. More... | |
const char * | get_key_suffix () const __attribute__((always_inline)) |
Returns the suffix part of the key in the page. More... | |
KeySlice | get_normalized_key () const __attribute__((always_inline)) |
This method assumes the key length is at most 8 bytes. More... | |
void | copy_combined_key (char *buffer) const |
Copies the entire big-endian key of the current record to the given buffer. More... | |
void | copy_combined_key_part (KeyLength offset, KeyLength len, char *buffer) const |
Another version to get a part of the key, from the offset for len bytes. More... | |
std::string | get_combined_key () const __attribute__((always_inline)) |
For even handier use, it returns std::string. More... | |
const char * | get_payload () const __attribute__((always_inline)) |
PayloadLength | get_payload_length () const __attribute__((always_inline)) |
ErrorCode | next () |
Moves the cursor to next record. More... | |
ErrorCode | delete_record () |
ErrorCode | overwrite_record (const void *payload, PayloadLength payload_offset, PayloadLength payload_count) |
template<typename PAYLOAD > | |
ErrorCode | overwrite_record_primitive (PAYLOAD payload, PayloadLength payload_offset) |
template<typename PAYLOAD > | |
ErrorCode | increment_record (PAYLOAD *value, PayloadLength payload_offset) |
Enumerator | |
---|---|
kMaxRecords | |
kMaxRoutes | |
kKeyLengthExtremum |
Definition at line 178 of file masstree_cursor.hpp.
Enumerator | |
---|---|
kCurKeySmaller | |
kCurKeyEquals | |
kCurKeyLarger | |
kCurKeyBeingsWith | |
kCurKeyContains |
Definition at line 170 of file masstree_cursor.hpp.
Enumerator | |
---|---|
kForwardInclusive | |
kForwardExclusive | |
kBackwardInclusive | |
kBackwardExclusive |
Definition at line 164 of file masstree_cursor.hpp.
foedus::storage::masstree::MasstreeCursor::MasstreeCursor | ( | MasstreeStorage | storage, |
thread::Thread * | context | ||
) |
Definition at line 41 of file masstree_cursor.cpp.
References foedus::storage::masstree::RecordLocation::clear().
void foedus::storage::masstree::MasstreeCursor::copy_combined_key | ( | char * | buffer | ) | const |
Copies the entire big-endian key of the current record to the given buffer.
[out] | buffer | to receive the combined big-endian key. must be get_key_length() or longer. |
In other words, this combines get_cur_route_prefixes(), get_key_in_layer_slice() and get_key_suffix(). This method is handy to get a whole key as one char array, but it must copy something, so remember that it's a bit costly.
Definition at line 77 of file masstree_cursor.cpp.
References ASSERT_ND, ASSUME_ALIGNED, foedus::storage::masstree::calculate_suffix_length(), foedus::storage::masstree::MasstreePage::get_layer(), is_valid_record(), foedus::storage::masstree::kInitiallyNextLayer, foedus::storage::masstree::MasstreeCursor::Route::layer_, and foedus::storage::masstree::MasstreeCursor::Route::page_.
Referenced by delete_record(), get_combined_key(), increment_record(), overwrite_record(), and overwrite_record_primitive().
void foedus::storage::masstree::MasstreeCursor::copy_combined_key_part | ( | KeyLength | offset, |
KeyLength | len, | ||
char * | buffer | ||
) | const |
Another version to get a part of the key, from the offset for len bytes.
Definition at line 95 of file masstree_cursor.cpp.
References ASSERT_ND, foedus::storage::masstree::calculate_suffix_length(), foedus::storage::masstree::MasstreePage::get_layer(), is_valid_record(), foedus::storage::masstree::kInitiallyNextLayer, foedus::storage::masstree::MasstreeCursor::Route::layer_, and foedus::storage::masstree::MasstreeCursor::Route::page_.
ErrorCode foedus::storage::masstree::MasstreeCursor::delete_record | ( | ) |
Definition at line 1305 of file masstree_cursor.cpp.
References copy_combined_key(), foedus::storage::masstree::MasstreeStoragePimpl::delete_general(), and foedus::storage::masstree::kMaxKeyLength.
|
inline |
For even handier use, it returns std::string.
It's SLOOOW. So use it as such.
Definition at line 280 of file masstree_cursor.hpp.
References copy_combined_key(), and foedus::storage::masstree::kMaxKeyLength.
|
inline |
Definition at line 186 of file masstree_cursor.hpp.
|
inline |
Big-endian version.
Definition at line 239 of file masstree_cursor.hpp.
|
inline |
Returns the prefix slices upto the current page.
When the current page is in layer-n, first n slices are set.
Definition at line 235 of file masstree_cursor.hpp.
|
inline |
Returns only the slice of the key in the layer of the current page.
Mostly internal use
Definition at line 243 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
Returns the length of the whole key we are currently pointing to.
Definition at line 227 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
Returns the suffix part of the key in the page.
Mostly internal use
Definition at line 248 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
This method assumes the key length is at most 8 bytes.
Instead, it's fast and handy.
Definition at line 253 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
Definition at line 286 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
Definition at line 290 of file masstree_cursor.hpp.
References ASSERT_ND, and is_valid_record().
|
inline |
Definition at line 187 of file masstree_cursor.hpp.
ErrorCode foedus::storage::masstree::MasstreeCursor::increment_record | ( | PAYLOAD * | value, |
PayloadLength | payload_offset | ||
) |
Definition at line 1317 of file masstree_cursor.cpp.
References copy_combined_key(), foedus::storage::masstree::MasstreeStoragePimpl::increment_general(), and foedus::storage::masstree::kMaxKeyLength.
|
inline |
Definition at line 188 of file masstree_cursor.hpp.
|
inline |
Definition at line 189 of file masstree_cursor.hpp.
|
inline |
Definition at line 223 of file masstree_cursor.hpp.
References foedus::storage::masstree::MasstreeCursor::Route::is_valid_record().
Referenced by copy_combined_key(), copy_combined_key_part(), get_key_in_layer_slice(), get_key_length(), get_key_suffix(), get_normalized_key(), get_payload(), get_payload_length(), next(), and open().
ErrorCode foedus::storage::masstree::MasstreeCursor::next | ( | ) |
Moves the cursor to next record.
When the cursor already reached the end, it does nothing.
Definition at line 174 of file masstree_cursor.cpp.
References ASSERT_ND, CHECK_ERROR_CODE, foedus::xct::XctId::is_deleted(), is_valid_record(), foedus::kErrorCodeOk, and foedus::storage::masstree::RecordLocation::observed_.
ErrorCode foedus::storage::masstree::MasstreeCursor::open | ( | const char * | begin_key = nullptr , |
KeyLength | begin_key_length = kKeyLengthExtremum , |
||
const char * | end_key = nullptr , |
||
KeyLength | end_key_length = kKeyLengthExtremum , |
||
bool | forward_cursor = true , |
||
bool | for_writes = false , |
||
bool | begin_inclusive = true , |
||
bool | end_inclusive = false |
||
) |
Definition at line 932 of file masstree_cursor.cpp.
References ASSERT_ND, CHECK_ERROR_CODE, foedus::storage::masstree::copy_input_key(), foedus::storage::masstree::MasstreeStoragePimpl::get_first_root(), foedus::xct::Xct::is_active(), foedus::xct::XctId::is_deleted(), is_valid_record(), kBackwardExclusive, kBackwardInclusive, foedus::kErrorCodeOk, foedus::kErrorCodeXctNoXct, kForwardExclusive, kForwardInclusive, and foedus::storage::masstree::RecordLocation::observed_.
Referenced by open_normalized().
|
inline |
Definition at line 201 of file masstree_cursor.hpp.
References ASSERT_ND, and open().
ErrorCode foedus::storage::masstree::MasstreeCursor::overwrite_record | ( | const void * | payload, |
PayloadLength | payload_offset, | ||
PayloadLength | payload_count | ||
) |
Definition at line 1271 of file masstree_cursor.cpp.
References copy_combined_key(), foedus::storage::masstree::kMaxKeyLength, and foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general().
ErrorCode foedus::storage::masstree::MasstreeCursor::overwrite_record_primitive | ( | PAYLOAD | payload, |
PayloadLength | payload_offset | ||
) |
Definition at line 1289 of file masstree_cursor.cpp.
References copy_combined_key(), foedus::storage::masstree::kMaxKeyLength, and foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general().