libfoedus-core
FOEDUS Core Library
foedus::storage::masstree::MasstreeStorage Class Referencefinal

Represents a Masstree storage. More...

Detailed Description

Represents a Masstree storage.

Definition at line 43 of file masstree_storage.hpp.

#include <masstree_storage.hpp>

Inheritance diagram for foedus::storage::masstree::MasstreeStorage:
Collaboration diagram for foedus::storage::masstree::MasstreeStorage:

Classes

struct  PeekBoundariesArguments
 Arguments for peek_volatile_page_boundaries() More...
 

Public Types

typedef MasstreeStoragePimpl ThisPimpl
 
typedef MasstreeCreateLogType ThisCreateLogType
 
typedef MasstreeMetadata ThisMetadata
 

Public Member Functions

 MasstreeStorage ()
 
 MasstreeStorage (Engine *engine, MasstreeStorageControlBlock *control_block)
 
 MasstreeStorage (Engine *engine, StorageControlBlock *control_block)
 
 MasstreeStorage (Engine *engine, StorageId id)
 
 MasstreeStorage (Engine *engine, const StorageName &name)
 
 MasstreeStorage (const MasstreeStorage &other)
 
MasstreeStorageoperator= (const MasstreeStorage &other)
 
const MasstreeMetadataget_masstree_metadata () const
 
ErrorStack create (const Metadata &metadata)
 
ErrorStack load (const StorageControlBlock &snapshot_block)
 
ErrorStack drop ()
 
ErrorCode prefetch_pages_normalized (thread::Thread *context, bool install_volatile, bool cache_snapshot, KeySlice from=kInfimumSlice, KeySlice to=kSupremumSlice)
 Prefetch data pages in this storage. More...
 
xct::TrackMovedRecordResult track_moved_record (xct::RwLockableXctId *old_address, xct::WriteXctAccess *write_set)
 Resolves a "moved" record. More...
 
ErrorCode get_record (thread::Thread *context, const void *key, KeyLength key_length, void *payload, PayloadLength *payload_capacity, bool read_only)
 Retrieves an entire record of the given key in this Masstree. More...
 
ErrorCode get_record_part (thread::Thread *context, const void *key, KeyLength key_length, void *payload, PayloadLength payload_offset, PayloadLength payload_count, bool read_only)
 Retrieves a part of the given key in this Masstree. More...
 
template<typename PAYLOAD >
ErrorCode get_record_primitive (thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD *payload, PayloadLength payload_offset, bool read_only)
 Retrieves a part of the given key in this Masstree as a primitive value. More...
 
ErrorCode get_record_normalized (thread::Thread *context, KeySlice key, void *payload, PayloadLength *payload_capacity, bool read_only)
 Retrieves an entire record of the given primitive key in this Masstree. More...
 
ErrorCode get_record_part_normalized (thread::Thread *context, KeySlice key, void *payload, PayloadLength payload_offset, PayloadLength payload_count, bool read_only)
 Retrieves a part of the given primitive key in this Masstree. More...
 
template<typename PAYLOAD >
ErrorCode get_record_primitive_normalized (thread::Thread *context, KeySlice key, PAYLOAD *payload, PayloadLength payload_offset, bool read_only)
 Retrieves a part of the given primitive key in this Masstree as a primitive value. More...
 
ErrorCode insert_record (thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
 Inserts a new record of the given key in this Masstree. More...
 
ErrorCode insert_record (thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count, PayloadLength physical_payload_hint)
 With this method, you can also specify physical_payload_hint, the physical size of the record's payload part. More...
 
ErrorCode insert_record (thread::Thread *context, const void *key, KeyLength key_length) __attribute__((always_inline))
 Inserts a new record without payload of the given key in this Masstree. More...
 
ErrorCode insert_record_normalized (thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
 Inserts a new record of the given primitive key in this Masstree. More...
 
ErrorCode insert_record_normalized (thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count, PayloadLength physical_payload_hint)
 With this method, you can also specify physical_payload_hint. More...
 
ErrorCode insert_record_normalized (thread::Thread *context, KeySlice key) __attribute__((always_inline))
 Inserts a new record without payload of the given primitive key in this Masstree. More...
 
ErrorCode delete_record (thread::Thread *context, const void *key, KeyLength key_length)
 Deletes a record of the given key from this Masstree. More...
 
ErrorCode delete_record_normalized (thread::Thread *context, KeySlice key)
 Deletes a record of the given primitive key from this Masstree. More...
 
ErrorCode upsert_record (thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
 Inserts a new record of the given key or replaces the existing one, or so-called upsert. More...
 
ErrorCode upsert_record (thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count, PayloadLength physical_payload_hint)
 With this method, you can also specify physical_payload_hint, the physical size of the record's payload part. More...
 
ErrorCode upsert_record (thread::Thread *context, const void *key, KeyLength key_length) __attribute__((always_inline))
 Upserts a new record without payload of the given key in this Masstree. More...
 
ErrorCode upsert_record_normalized (thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
 Upserts a new record of the given primitive key in this Masstree. More...
 
ErrorCode upsert_record_normalized (thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count, PayloadLength physical_payload_hint)
 With this method, you can also specify physical_payload_hint. More...
 
ErrorCode upsert_record_normalized (thread::Thread *context, KeySlice key) __attribute__((always_inline))
 Upserts a new record without payload of the given primitive key in this Masstree. More...
 
ErrorCode overwrite_record (thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
 Overwrites a part of one record of the given key in this Masstree. More...
 
template<typename PAYLOAD >
ErrorCode overwrite_record_primitive (thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD payload, PayloadLength payload_offset)
 Overwrites a part of one record of the given key in this Masstree as a primitive value. More...
 
ErrorCode overwrite_record_normalized (thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
 Overwrites a part of one record of the given primitive key in this Masstree. More...
 
template<typename PAYLOAD >
ErrorCode overwrite_record_primitive_normalized (thread::Thread *context, KeySlice key, PAYLOAD payload, PayloadLength payload_offset)
 Overwrites a part of one record of the given primitive key in this Masstree as a primitive value. More...
 
template<typename PAYLOAD >
ErrorCode increment_record (thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD *value, PayloadLength payload_offset)
 This one further optimizes overwrite methods for the frequent use case of incrementing some data in primitive type. More...
 
template<typename PAYLOAD >
ErrorCode increment_record_normalized (thread::Thread *context, KeySlice key, PAYLOAD *value, PayloadLength payload_offset)
 For primitive key. More...
 
ErrorStack verify_single_thread (thread::Thread *context)
 
ErrorStack debugout_single_thread (Engine *engine, bool volatile_only=false, uint32_t max_pages=1024U)
 A super-expensive and single-thread only debugging feature to write out gigantic human-readable texts to describe the Masstree in details. More...
 
ErrorStack hcc_reset_all_temperature_stat ()
 Resets all volatile pages' temperature stat to be zero in this storage. More...
 
ErrorCode peek_volatile_page_boundaries (Engine *engine, const PeekBoundariesArguments &args)
 Checks the volatile pages of this storage to give hints to decide page boundary keys. More...
 
ErrorStack fatify_first_root (thread::Thread *context, uint32_t desired_count, bool disable_no_record_split=true)
 Deliberately causes splits under the volatile root of first layer, or "fatify" it. More...
 
- Public Member Functions inherited from foedus::storage::Storage< MasstreeStorageControlBlock >
 Storage ()
 
 Storage (Engine *engine, MasstreeStorageControlBlock *control_block)
 
 Storage (Engine *engine, StorageControlBlock *control_block)
 
 Storage (Engine *engine, StorageId id)
 Shorthand for engine->get_storage_manager()->get_storage(id) More...
 
 Storage (Engine *engine, const StorageName &name)
 Shorthand for engine->get_storage_manager()->get_storage(name) More...
 
 Storage (const Storage &other)
 
Storageoperator= (const Storage &other)
 
StorageId get_id () const
 Returns the unique ID of this storage. More...
 
StorageType get_type () const
 Returns the type of this storage. More...
 
const StorageNameget_name () const
 Returns the unique name of this storage. More...
 
const Metadataget_metadata () const
 Returns the metadata of this storage. More...
 
bool exists () const
 Returns whether this storage is already created. More...
 
- Public Member Functions inherited from foedus::Attachable< MasstreeStorageControlBlock >
 Attachable ()
 
 Attachable (Engine *engine)
 
 Attachable (Engine *engine, MasstreeStorageControlBlock *control_block)
 
 Attachable (MasstreeStorageControlBlock *control_block)
 
 Attachable (const Attachable &other)
 
virtual ~Attachable ()
 
Attachableoperator= (const Attachable &other)
 
virtual void attach (MasstreeStorageControlBlock *control_block)
 Attaches to the given shared memory. More...
 
bool is_attached () const
 Returns whether the object has been already attached to some shared memory. More...
 
MasstreeStorageControlBlock * get_control_block () const
 
Engineget_engine () const
 
void set_engine (Engine *engine)
 

Static Public Member Functions

static SlotIndex estimate_records_per_page (Layer layer, KeyLength key_length, PayloadLength payload_length)
 

Friends

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

Additional Inherited Members

- Protected Attributes inherited from foedus::Attachable< MasstreeStorageControlBlock >
Engineengine_
 Most attachable object stores an engine pointer (local engine), so we define it here. More...
 
MasstreeStorageControlBlock * control_block_
 The shared data on shared memory that has been initialized in some SOC or master engine. More...
 

Member Typedef Documentation

Constructor & Destructor Documentation

foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( )

Definition at line 37 of file masstree_storage.cpp.

37 : Storage<MasstreeStorageControlBlock>() {}
foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( Engine engine,
MasstreeStorageControlBlock control_block 
)

Definition at line 38 of file masstree_storage.cpp.

References ASSERT_ND, foedus::storage::Storage< MasstreeStorageControlBlock >::exists(), foedus::storage::Storage< MasstreeStorageControlBlock >::get_type(), and foedus::storage::kMasstreeStorage.

39  : Storage<MasstreeStorageControlBlock>(engine, control_block) {
41 }
StorageType get_type() const
Returns the type of this storage.
Definition: storage.hpp:150
bool exists() const
Returns whether this storage is already created.
Definition: storage.hpp:169
#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:

foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( Engine engine,
StorageControlBlock control_block 
)

Definition at line 42 of file masstree_storage.cpp.

References ASSERT_ND, foedus::storage::Storage< MasstreeStorageControlBlock >::exists(), foedus::storage::Storage< MasstreeStorageControlBlock >::get_type(), and foedus::storage::kMasstreeStorage.

43  : Storage<MasstreeStorageControlBlock>(engine, control_block) {
45 }
StorageType get_type() const
Returns the type of this storage.
Definition: storage.hpp:150
bool exists() const
Returns whether this storage is already created.
Definition: storage.hpp:169
#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:

foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( Engine engine,
StorageId  id 
)

Definition at line 46 of file masstree_storage.cpp.

47  : Storage<MasstreeStorageControlBlock>(engine, id) {}
foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( Engine engine,
const StorageName name 
)

Definition at line 48 of file masstree_storage.cpp.

49  : Storage<MasstreeStorageControlBlock>(engine, name) {}
foedus::storage::masstree::MasstreeStorage::MasstreeStorage ( const MasstreeStorage other)

Definition at line 50 of file masstree_storage.cpp.

51  : Storage<MasstreeStorageControlBlock>(other.engine_, other.control_block_) {
52 }

Member Function Documentation

ErrorStack foedus::storage::masstree::MasstreeStorage::create ( const Metadata metadata)

Definition at line 63 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::create().

63  {
64  return MasstreeStoragePimpl(this).create(static_cast<const MasstreeMetadata&>(metadata));
65 }

Here is the call graph for this function:

ErrorStack foedus::storage::masstree::MasstreeStorage::debugout_single_thread ( Engine engine,
bool  volatile_only = false,
uint32_t  max_pages = 1024U 
)

A super-expensive and single-thread only debugging feature to write out gigantic human-readable texts to describe the Masstree in details.

Do not invoke this method for more than 100 pages, or in production use. This is for debugging.

Definition at line 579 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::debugout_single_thread().

582  {
583  return MasstreeStoragePimpl(this).debugout_single_thread(engine, volatile_only, max_pages);
584 }

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::delete_record ( thread::Thread context,
const void *  key,
KeyLength  key_length 
)

Deletes a record of the given key from this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.

When the key does not exist, it returns kErrorCodeStrKeyNotFound and also adds an appropriate record to range-lock read set because it is part of transactional information.

Definition at line 312 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::delete_general(), delete_record_normalized(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), and foedus::storage::masstree::normalize_be_bytes_full().

315  {
316  // Automatically switch to faster implementation for 8-byte keys
317  if (key_length == sizeof(KeySlice)) {
318  KeySlice slice = normalize_be_bytes_full(key);
319  return delete_record_normalized(context, slice);
320  }
321 
322  MasstreeStoragePimpl pimpl(this);
323  RecordLocation location;
324  CHECK_ERROR_CODE(pimpl.locate_record(
325  context,
326  key,
327  key_length,
328  true,
329  &location));
330  return pimpl.delete_general(context, location, key, key_length);
331 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
ErrorCode delete_record_normalized(thread::Thread *context, KeySlice key)
Deletes a record of the given primitive key from this Masstree.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::delete_record_normalized ( thread::Thread context,
KeySlice  key 
)

Deletes a record of the given primitive key from this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.

Definition at line 333 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::delete_general(), foedus::assorted::htobe< uint64_t >(), and foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized().

Referenced by delete_record().

335  {
336  MasstreeStoragePimpl pimpl(this);
337  RecordLocation location;
338  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
339  context,
340  key,
341  true,
342  &location));
343  uint64_t be_key = assorted::htobe<uint64_t>(key);
344  return pimpl.delete_general(context, location, &be_key, sizeof(be_key));
345 }
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::storage::masstree::MasstreeStorage::drop ( )

Definition at line 69 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::drop().

69 { return MasstreeStoragePimpl(this).drop(); }

Here is the call graph for this function:

SlotIndex foedus::storage::masstree::MasstreeStorage::estimate_records_per_page ( Layer  layer,
KeyLength  key_length,
PayloadLength  payload_length 
)
static
Parameters
[in]layerB-trie layer most border pages would be in.
[in]key_lengthestimated byte size of each key
[in]payload_lengthestimated byte size of each payload
Returns
Estimated number of records that fit in one border page.

Definition at line 612 of file masstree_storage.cpp.

References foedus::assorted::align8(), ASSERT_ND, foedus::storage::masstree::kBorderPageDataPartSize, foedus::storage::masstree::kBorderPageMaxSlots, and foedus::storage::masstree::kBorderPageSlotSize.

615  {
616  PayloadLength aligned_payload = assorted::align8(payload_length);
617  KeyLength aligned_suffix = 0;
618  if (key_length > (layer + 1U) * sizeof(KeySlice)) {
619  aligned_suffix = assorted::align8(key_length - (layer + 1U) * sizeof(KeySlice));
620  }
622  / (aligned_suffix + aligned_payload + kBorderPageSlotSize);
624  return ret;
625 }
T align8(T value)
8-alignment.
uint16_t PayloadLength
Represents a byte-length of a payload in this package.
Definition: masstree_id.hpp:92
uint16_t SlotIndex
Index of a record in a (border) page.
const uint32_t kBorderPageSlotSize
Byte size of one slot in MasstreeBorderPage excluding slice information.
uint64_t KeySlice
Each key slice is an 8-byte integer.
uint16_t KeyLength
Represents a byte-length of a key in this package.
Definition: masstree_id.hpp:69
const SlotIndex kBorderPageMaxSlots
Maximum number of slots in one MasstreeBorderPage.
const uint32_t kBorderPageDataPartSize
Byte size of the record data part (data_) in MasstreeBorderPage.
#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:

ErrorStack foedus::storage::masstree::MasstreeStorage::fatify_first_root ( thread::Thread context,
uint32_t  desired_count,
bool  disable_no_record_split = true 
)

Deliberately causes splits under the volatile root of first layer, or "fatify" it.

Parameters
[in]contextThread context
[in]desired_countDoes nothing if the root of first layer already has this many children.
[in]disable_no_record_splitwhen this method triggers page splits, whether to always split pages in half, ignoring chance for no-record-split. usually you should just leave the default value.

This is a special-purpose, physical-only method that does nothing logically. It increases the number of direct children in first root, which is useful when we partition based on children in first root. Fatifying beforehand shouldn't have any significant drawback, but we so far restrict the use of this method to performance benchmarks.

Todo:
testcase for this method. TDD? shut up.

Definition at line 604 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::fatify_first_root().

607  {
608  MasstreeStoragePimpl impl(this);
609  return impl.fatify_first_root(context, desired_count, disable_no_record_split);
610 }

Here is the call graph for this function:

const MasstreeMetadata * foedus::storage::masstree::MasstreeStorage::get_masstree_metadata ( ) const

Definition at line 59 of file masstree_storage.cpp.

References foedus::Attachable< MasstreeStorageControlBlock >::control_block_.

Referenced by foedus::storage::masstree::MasstreeComposer::drop_root_volatile(), and foedus::storage::masstree::MasstreeComposer::drop_volatiles().

59  {
60  return &control_block_->meta_;
61 }
MasstreeStorageControlBlock * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::get_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
void *  payload,
PayloadLength payload_capacity,
bool  read_only 
)

Retrieves an entire record of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[out]payloadBuffer to receive the payload of the record.
[in,out]payload_capacity[In] Byte size of the payload buffer, [Out] length of the payload. This is set whether the payload capacity was too small or not.
[in]read_onlyWhether this read will not be followed by writes. When MOCC triggers pessimistic lock, this guides us to take either read- or write-lock.

When payload_capacity is smaller than the actual payload, this method returns kErrorCodeStrTooSmallPayloadBuffer and payload_capacity is set to be the required length.

When the key is not found (kErrorCodeStrKeyNotFound), we also add an appropriate record to range-lock read set because it is part of a transactional information.

Definition at line 79 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, get_record_normalized(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::masstree::normalize_be_bytes_full(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_general().

85  {
86  // Automatically switch to faster implementation for 8-byte keys
87  if (key_length == sizeof(KeySlice)) {
88  KeySlice slice = normalize_be_bytes_full(key);
89  return get_record_normalized(context, slice, payload, payload_capacity, read_only);
90  }
91 
92  MasstreeStoragePimpl pimpl(this);
93  RecordLocation location;
94  CHECK_ERROR_CODE(pimpl.locate_record(
95  context,
96  key,
97  key_length,
98  !read_only,
99  &location));
100  return pimpl.retrieve_general(
101  context,
102  location,
103  payload,
104  payload_capacity);
105 }
ErrorCode get_record_normalized(thread::Thread *context, KeySlice key, void *payload, PayloadLength *payload_capacity, bool read_only)
Retrieves an entire record of the given primitive key in this Masstree.
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::get_record_normalized ( thread::Thread context,
KeySlice  key,
void *  payload,
PayloadLength payload_capacity,
bool  read_only 
)

Retrieves an entire record of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.
[out]payloadBuffer to receive the payload of the record.
[in,out]payload_capacity[In] Byte size of the payload buffer, [Out] length of the payload. This is set whether the payload capacity was too small or not.
[in]read_onlyWhether this read will not be followed by writes. When MOCC triggers pessimistic lock, this guides us to take either read- or write-lock.

Definition at line 169 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_general().

Referenced by get_record().

174  {
175  MasstreeStoragePimpl pimpl(this);
176  RecordLocation location;
177  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
178  context,
179  key,
180  !read_only,
181  &location));
182  return pimpl.retrieve_general(
183  context,
184  location,
185  payload,
186  payload_capacity);
187 }
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::get_record_part ( thread::Thread context,
const void *  key,
KeyLength  key_length,
void *  payload,
PayloadLength  payload_offset,
PayloadLength  payload_count,
bool  read_only 
)

Retrieves a part of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[out]payloadBuffer to receive the payload of the record.
[in]payload_offsetWe copy from this byte position of the record.
[in]payload_countHow many bytes we copy.
[in]read_onlyWhether this read will not be followed by writes. When MOCC triggers pessimistic lock, this guides us to take either read- or write-lock.
Precondition
payload_offset + payload_count must be within the record's actual payload size (returns kErrorCodeStrTooShortPayload if not)

Definition at line 107 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, get_record_part_normalized(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::masstree::normalize_be_bytes_full(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_part_general().

114  {
115  // Automatically switch to faster implementation for 8-byte keys
116  if (key_length == sizeof(KeySlice)) {
117  KeySlice slice = normalize_be_bytes_full(key);
119  context, slice, payload, payload_offset, payload_count, read_only);
120  }
121 
122  MasstreeStoragePimpl pimpl(this);
123  RecordLocation location;
124  CHECK_ERROR_CODE(pimpl.locate_record(
125  context,
126  key,
127  key_length,
128  !read_only,
129  &location));
130  return pimpl.retrieve_part_general(
131  context,
132  location,
133  payload,
134  payload_offset,
135  payload_count);
136 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
ErrorCode get_record_part_normalized(thread::Thread *context, KeySlice key, void *payload, PayloadLength payload_offset, PayloadLength payload_count, bool read_only)
Retrieves a part of the given primitive key in this Masstree.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::get_record_part_normalized ( thread::Thread context,
KeySlice  key,
void *  payload,
PayloadLength  payload_offset,
PayloadLength  payload_count,
bool  read_only 
)

Retrieves a part of the given primitive key in this Masstree.

See also
get_record_part()
get_record_normalized()

Definition at line 189 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_part_general().

Referenced by get_record_part().

195  {
196  MasstreeStoragePimpl pimpl(this);
197  RecordLocation location;
198  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
199  context,
200  key,
201  !read_only,
202  &location));
203  return pimpl.retrieve_part_general(
204  context,
205  location,
206  payload,
207  payload_offset,
208  payload_count);
209 }
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::get_record_primitive ( thread::Thread context,
const void *  key,
KeyLength  key_length,
PAYLOAD *  payload,
PayloadLength  payload_offset,
bool  read_only 
)

Retrieves a part of the given key in this Masstree as a primitive value.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[out]payloadReceive the payload of the record.
[in]payload_offsetWe copy from this byte position of the record.
[in]read_onlyWhether this read will not be followed by writes. When MOCC triggers pessimistic lock, this guides us to take either read- or write-lock.
Precondition
payload_offset + sizeof(PAYLOAD) must be within the record's actual payload size (returns kErrorCodeStrTooShortPayload if not)
Template Parameters
PAYLOADprimitive type of the payload. all integers and floats are allowed.

Definition at line 139 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::masstree::normalize_be_bytes_full(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_part_general().

145  {
146  // Automatically switch to faster implementation for 8-byte keys
147  if (key_length == sizeof(KeySlice)) {
148  KeySlice slice = normalize_be_bytes_full(key);
149  return get_record_primitive_normalized<PAYLOAD>(
150  context, slice, payload, payload_offset, read_only);
151  }
152 
153  MasstreeStoragePimpl pimpl(this);
154  RecordLocation location;
155  CHECK_ERROR_CODE(pimpl.locate_record(
156  context,
157  key,
158  key_length,
159  !read_only,
160  &location));
161  return pimpl.retrieve_part_general(
162  context,
163  location,
164  payload,
165  payload_offset,
166  sizeof(PAYLOAD));
167 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::get_record_primitive_normalized ( thread::Thread context,
KeySlice  key,
PAYLOAD *  payload,
PayloadLength  payload_offset,
bool  read_only 
)

Retrieves a part of the given primitive key in this Masstree as a primitive value.

See also
get_record_normalized()
get_record_primitive()

Definition at line 212 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), and foedus::storage::masstree::MasstreeStoragePimpl::retrieve_part_general().

217  {
218  MasstreeStoragePimpl pimpl(this);
219  RecordLocation location;
220  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
221  context,
222  key,
223  !read_only,
224  &location));
225  return pimpl.retrieve_part_general(
226  context,
227  location,
228  payload,
229  payload_offset,
230  sizeof(PAYLOAD));
231 }
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorStack foedus::storage::masstree::MasstreeStorage::hcc_reset_all_temperature_stat ( )

Resets all volatile pages' temperature stat to be zero in this storage.

Used only in HCC-branch.

Definition at line 586 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::hcc_reset_all_temperature_stat().

586  {
587  return MasstreeStoragePimpl(this).hcc_reset_all_temperature_stat();
588 }

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::increment_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
PAYLOAD *  value,
PayloadLength  payload_offset 
)

This one further optimizes overwrite methods for the frequent use case of incrementing some data in primitive type.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[in,out]value(in) addendum, (out) value after addition.
[in]payload_offsetWe overwrite to this byte position of the record.
Precondition
payload_offset + sizeof(PAYLOAD) must be within the record's actual payload size (returns kErrorCodeStrTooShortPayload if not)
Template Parameters
PAYLOADprimitive type of the payload. all integers and floats are allowed.

Definition at line 523 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::increment_general(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), and foedus::storage::masstree::normalize_be_bytes_full().

528  {
529  // Automatically switch to faster implementation for 8-byte keys
530  if (key_length == sizeof(KeySlice)) {
531  KeySlice slice = normalize_be_bytes_full(key);
532  return increment_record_normalized<PAYLOAD>(context, slice, value, payload_offset);
533  }
534 
535  MasstreeStoragePimpl pimpl(this);
536  RecordLocation location;
537  CHECK_ERROR_CODE(pimpl.locate_record(
538  context,
539  key,
540  key_length,
541  true,
542  &location));
543  return pimpl.increment_general<PAYLOAD>(
544  context,
545  location,
546  key,
547  key_length,
548  value,
549  payload_offset);
550 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::increment_record_normalized ( thread::Thread context,
KeySlice  key,
PAYLOAD *  value,
PayloadLength  payload_offset 
)

For primitive key.

See also
increment_record()

Definition at line 553 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::assorted::htobe< uint64_t >(), foedus::storage::masstree::MasstreeStoragePimpl::increment_general(), and foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized().

557  {
558  MasstreeStoragePimpl pimpl(this);
559  RecordLocation location;
560  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
561  context,
562  key,
563  true,
564  &location));
565  uint64_t be_key = assorted::htobe<uint64_t>(key);
566  return pimpl.increment_general<PAYLOAD>(
567  context,
568  location,
569  &be_key,
570  sizeof(be_key),
571  value,
572  payload_offset);
573 }
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
const void *  payload,
PayloadLength  payload_count 
)
inline

Inserts a new record of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[in]payloadValue to insert.
[in]payload_countLength of payload.

If the key already exists, it returns kErrorCodeStrKeyAlreadyExists and also adds the found record to read set because it is part of transactional information.

Definition at line 252 of file masstree_storage.hpp.

Referenced by insert_record().

257  {
258  return insert_record(context, key, key_length, payload, payload_count, payload_count);
259  }
ErrorCode insert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key in this Masstree.

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
const void *  payload,
PayloadLength  payload_count,
PayloadLength  physical_payload_hint 
)

With this method, you can also specify physical_payload_hint, the physical size of the record's payload part.

If you will later expand the payload of this record, giving a larger value will avoid record migration. Default value (and minimal value) is same as the initial payload_count.

Definition at line 247 of file masstree_storage.cpp.

References foedus::storage::masstree::adjust_payload_hint(), ASSERT_ND, CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::insert_general(), insert_record_normalized(), foedus::storage::masstree::RecordLocation::is_found(), foedus::kErrorCodeStrTooLongPayload, foedus::storage::masstree::kMaxPayloadLength, foedus::storage::masstree::normalize_be_bytes_full(), foedus::storage::masstree::MasstreeStoragePimpl::reserve_record(), and UNLIKELY.

253  {
254  // Automatically switch to faster implementation for 8-byte keys
255  if (key_length == sizeof(KeySlice)) {
256  KeySlice slice = normalize_be_bytes_full(key);
257  return insert_record_normalized(context, slice, payload, payload_count, physical_payload_hint);
258  }
259 
260  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
262  }
263  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
264  MasstreeStoragePimpl pimpl(this);
265  RecordLocation location;
266  CHECK_ERROR_CODE(pimpl.reserve_record(
267  context,
268  key,
269  key_length,
270  payload_count,
271  physical_payload_hint,
272  &location));
273  ASSERT_ND(location.is_found()); // contract of reserve_record
274  return pimpl.insert_general(
275  context,
276  location,
277  key,
278  key_length,
279  payload,
280  payload_count);
281 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
0x0808 : "STORAGE: Payload of the record is too long" .
Definition: error_code.hpp:174
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
PayloadLength adjust_payload_hint(PayloadLength payload_count, PayloadLength physical_payload_hint)
const PayloadLength kMaxPayloadLength
Max length of a payload.
Definition: masstree_id.hpp:98
ErrorCode insert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given primitive key in this Masstree.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#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:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length 
)
inline

Inserts a new record without payload of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.

If the key already exists, it returns kErrorCodeStrKeyAlreadyExists and also adds the found record to read set because it is part of transactional information.

Definition at line 284 of file masstree_storage.hpp.

References CXX11_NULLPTR, and insert_record().

287  {
288  return insert_record(context, key, key_length, CXX11_NULLPTR, 0U);
289  }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
ErrorCode insert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key in this Masstree.

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record_normalized ( thread::Thread context,
KeySlice  key,
const void *  payload,
PayloadLength  payload_count 
)
inline

Inserts a new record of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.
[in]payloadValue to insert.
[in]payload_countLength of payload.

Definition at line 298 of file masstree_storage.hpp.

Referenced by insert_record(), and insert_record_normalized().

302  {
303  return insert_record_normalized(context, key, payload, payload_count, payload_count);
304  }
ErrorCode insert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given primitive key in this Masstree.

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record_normalized ( thread::Thread context,
KeySlice  key,
const void *  payload,
PayloadLength  payload_count,
PayloadLength  physical_payload_hint 
)

With this method, you can also specify physical_payload_hint.

Definition at line 283 of file masstree_storage.cpp.

References foedus::storage::masstree::adjust_payload_hint(), ASSERT_ND, CHECK_ERROR_CODE, foedus::assorted::htobe< uint64_t >(), foedus::storage::masstree::MasstreeStoragePimpl::insert_general(), foedus::storage::masstree::RecordLocation::is_found(), foedus::kErrorCodeStrTooLongPayload, foedus::storage::masstree::kMaxPayloadLength, foedus::storage::masstree::MasstreeStoragePimpl::reserve_record_normalized(), and UNLIKELY.

288  {
289  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
291  }
292  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
293  MasstreeStoragePimpl pimpl(this);
294  RecordLocation location;
295  CHECK_ERROR_CODE(pimpl.reserve_record_normalized(
296  context,
297  key,
298  payload_count,
299  physical_payload_hint,
300  &location));
301  ASSERT_ND(location.is_found()); // contract of reserve_record
302  uint64_t be_key = assorted::htobe<uint64_t>(key);
303  return pimpl.insert_general(
304  context,
305  location,
306  &be_key,
307  sizeof(be_key),
308  payload,
309  payload_count);
310 }
0x0808 : "STORAGE: Payload of the record is too long" .
Definition: error_code.hpp:174
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
PayloadLength adjust_payload_hint(PayloadLength payload_count, PayloadLength physical_payload_hint)
const PayloadLength kMaxPayloadLength
Max length of a payload.
Definition: masstree_id.hpp:98
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#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:

ErrorCode foedus::storage::masstree::MasstreeStorage::insert_record_normalized ( thread::Thread context,
KeySlice  key 
)
inline

Inserts a new record without payload of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.

Definition at line 321 of file masstree_storage.hpp.

References CXX11_NULLPTR, and insert_record_normalized().

321  {
322  return insert_record_normalized(context, key, CXX11_NULLPTR, 0U);
323  }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
ErrorCode insert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given primitive key in this Masstree.

Here is the call graph for this function:

ErrorStack foedus::storage::masstree::MasstreeStorage::load ( const StorageControlBlock snapshot_block)

Definition at line 66 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::load().

66  {
67  return MasstreeStoragePimpl(this).load(snapshot_block);
68 }

Here is the call graph for this function:

MasstreeStorage & foedus::storage::masstree::MasstreeStorage::operator= ( const MasstreeStorage other)

Definition at line 53 of file masstree_storage.cpp.

References foedus::Attachable< MasstreeStorageControlBlock >::control_block_, foedus::Attachable< CONTROL_BLOCK >::control_block_, foedus::Attachable< MasstreeStorageControlBlock >::engine_, and foedus::Attachable< CONTROL_BLOCK >::engine_.

53  {
54  engine_ = other.engine_;
55  control_block_ = other.control_block_;
56  return *this;
57 }
Engine * engine_
Most attachable object stores an engine pointer (local engine), so we define it here.
Definition: attachable.hpp:107
MasstreeStorageControlBlock * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111
ErrorCode foedus::storage::masstree::MasstreeStorage::overwrite_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
const void *  payload,
PayloadLength  payload_offset,
PayloadLength  payload_count 
)

Overwrites a part of one record of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[in]payloadWe copy from this buffer. Must be at least payload_count.
[in]payload_offsetWe overwrite to this byte position of the record.
[in]payload_countHow many bytes we overwrite.

When payload_offset+payload_count is larger than the actual payload, this method returns kErrorCodeStrTooShortPayload. Just like get_record(), this adds to range-lock read set even when key is not found.

Definition at line 412 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::masstree::normalize_be_bytes_full(), foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general(), and overwrite_record_normalized().

418  {
419  // Automatically switch to faster implementation for 8-byte keys
420  if (key_length == sizeof(KeySlice)) {
421  KeySlice slice = normalize_be_bytes_full(key);
422  return overwrite_record_normalized(context, slice, payload, payload_offset, payload_count);
423  }
424 
425  MasstreeStoragePimpl pimpl(this);
426  RecordLocation location;
427  CHECK_ERROR_CODE(pimpl.locate_record(
428  context,
429  key,
430  key_length,
431  true,
432  &location));
433  return pimpl.overwrite_general(
434  context,
435  location,
436  key,
437  key_length,
438  payload,
439  payload_offset,
440  payload_count);
441 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
ErrorCode overwrite_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
Overwrites a part of one record of the given primitive key in this Masstree.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::overwrite_record_normalized ( thread::Thread context,
KeySlice  key,
const void *  payload,
PayloadLength  payload_offset,
PayloadLength  payload_count 
)

Overwrites a part of one record of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.
[in]payloadWe copy from this buffer. Must be at least payload_count.
[in]payload_offsetWe overwrite to this byte position of the record.
[in]payload_countHow many bytes we overwrite.
See also
get_record_normalized()

Definition at line 474 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::assorted::htobe< uint64_t >(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), and foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general().

Referenced by overwrite_record().

479  {
480  MasstreeStoragePimpl pimpl(this);
481  RecordLocation location;
482  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
483  context,
484  key,
485  true,
486  &location));
487  uint64_t be_key = assorted::htobe<uint64_t>(key);
488  return pimpl.overwrite_general(
489  context,
490  location,
491  &be_key,
492  sizeof(be_key),
493  payload,
494  payload_offset,
495  payload_count);
496 }
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::overwrite_record_primitive ( thread::Thread context,
const void *  key,
KeyLength  key_length,
PAYLOAD  payload,
PayloadLength  payload_offset 
)

Overwrites a part of one record of the given key in this Masstree as a primitive value.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[in]payloadWe copy this value.
[in]payload_offsetWe overwrite to this byte position of the record.
Precondition
payload_offset + sizeof(PAYLOAD) must be within the record's actual payload size (returns kErrorCodeStrTooShortPayload if not)
Template Parameters
PAYLOADprimitive type of the payload. all integers and floats are allowed.

Definition at line 444 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::masstree::normalize_be_bytes_full(), and foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general().

449  {
450  // Automatically switch to faster implementation for 8-byte keys
451  if (key_length == sizeof(KeySlice)) {
452  KeySlice slice = normalize_be_bytes_full(key);
453  return overwrite_record_primitive_normalized<PAYLOAD>(context, slice, payload, payload_offset);
454  }
455 
456  MasstreeStoragePimpl pimpl(this);
457  RecordLocation location;
458  CHECK_ERROR_CODE(pimpl.locate_record(
459  context,
460  key,
461  key_length,
462  true,
463  &location));
464  return pimpl.overwrite_general(
465  context,
466  location,
467  key,
468  key_length,
469  &payload,
470  payload_offset,
471  sizeof(payload));
472 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::masstree::MasstreeStorage::overwrite_record_primitive_normalized ( thread::Thread context,
KeySlice  key,
PAYLOAD  payload,
PayloadLength  payload_offset 
)

Overwrites a part of one record of the given primitive key in this Masstree as a primitive value.

See also
overwrite_record_primitive()
overwrite_record_normalized()

Definition at line 499 of file masstree_storage.cpp.

References CHECK_ERROR_CODE, foedus::assorted::htobe< uint64_t >(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), and foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general().

503  {
504  MasstreeStoragePimpl pimpl(this);
505  RecordLocation location;
506  CHECK_ERROR_CODE(pimpl.locate_record_normalized(
507  context,
508  key,
509  true,
510  &location));
511  uint64_t be_key = assorted::htobe<uint64_t>(key);
512  return pimpl.overwrite_general(
513  context,
514  location,
515  &be_key,
516  sizeof(be_key),
517  &payload,
518  payload_offset,
519  sizeof(payload));
520 }
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::peek_volatile_page_boundaries ( Engine engine,
const PeekBoundariesArguments args 
)

Checks the volatile pages of this storage to give hints to decide page boundary keys.

This method is used from the composer to make page boundaries in snapshot pages better aligned with those of volatile pages so that we can drop more volatile pages at the end. This method is opportunistic, meaning the result is not guaranteed to be transactionally correct, but that's fine because these are just hints. If the page boundary is not aligned well with volatile pages, we just have to keep more volatile pages for a while. In fact, the composer might ignore these hints in some cases (eg. a page has too few tuples). Defined in masstree_storage_peek.cpp

Definition at line 31 of file masstree_storage_peek.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries().

32  {
33  MasstreeStoragePimpl pimpl(this);
34  return pimpl.peek_volatile_page_boundaries(engine, args);
35 }

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::prefetch_pages_normalized ( thread::Thread context,
bool  install_volatile,
bool  cache_snapshot,
KeySlice  from = kInfimumSlice,
KeySlice  to = kSupremumSlice 
)

Prefetch data pages in this storage.

Key Slice version (from/to are 8 bytes or less).

Parameters
[in]contextThread context.
[in]install_volatileWhether to install/prefetch volatile pages based on the recent snapshot page if there is none.
[in]cache_snapshotWhether to cache/prefetch snapshot pages if exists.
[in]frominclusive begin slice of records that are specifically prefetched even in data pages.
[in]toinclusive end slice of records that are specifically prefetched even in data pages.

This is to warmup the storage for the current core. Data pages are prefetched within from/to. So far prefetches only volatile pages, but it will also cache and prefetch snapshot pages.

Definition at line 590 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::prefetch_pages_normalized().

595  {
596  return MasstreeStoragePimpl(this).prefetch_pages_normalized(
597  context,
598  install_volatile,
599  cache_snapshot,
600  from,
601  to);
602 }

Here is the call graph for this function:

xct::TrackMovedRecordResult foedus::storage::masstree::MasstreeStorage::track_moved_record ( xct::RwLockableXctId old_address,
xct::WriteXctAccess write_set 
)

Resolves a "moved" record.

This is the core of the moved-bit protocol. Receiving a xct_id address that points to a moved record, track the physical record in another page. This method does not take lock, so it is possible that concurrent threads again move the record after this. The only case it fails to track is the record moved to deeper layers. If the write-set is supplied, we use the key information in it to track even in that case.

Note
Implementation note and limitation Master-tree (masstree) does use moved bit, so this storage implements this method to handle moved record. There are a few design choices worth noting.

In the new_mpage git branch, we significantly changed the page layout in this package. One purpose was to allow tracking the moved record in all circumstances.

When the record is moved within the same B-trie layer, it is anyway easy to track down the new location. When the record is moved to next layer, however, we have to know the entire key to track the record. Previous page layout didn't allow it unless we have the write_set. When there is a standalone read-access, we could not track to next layer.

The new page layout always leaves the original key of the record in page, thus the issue completely went away. This also simplified concurrency control in this package. See Remainder vs Remaining Key.

However, this came with the price of wasted space in page. To ameliorate it, we made a few improvements to reduce wasted space.

  • First, now we have a flag that says the record is initially a next-layer. When this is set, we do not put suffix, thus the price is gone.
  • Second, we also added a configuration to aggressively create next-layer to make most high-layer records as initially next-layer. See MasstreeMetadata::min_layer_hint_.
  • Third, we also overhauled the way we expand records in page.

Thanks to these improvements, we now allow more records, not less, in a page. Previously it was 64, but now kBorderPageMaxSlots is 100 for 4kb pages.

Definition at line 842 of file masstree_storage_pimpl.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::track_moved_record().

Referenced by foedus::storage::StorageManagerPimpl::track_moved_record().

844  {
845  return MasstreeStoragePimpl(this).track_moved_record(old_address, write_set);
846 }

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
const void *  payload,
PayloadLength  payload_count 
)
inline

Inserts a new record of the given key or replaces the existing one, or so-called upsert.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.
[in]payloadValue to upsert.
[in]payload_countLength of payload.

This method puts the record whether the key already exists or not, which is handy in many usecases. Internally, the Implementation comes with a bit of complexity. If there is an existing record of the key (whether logically deleted or not) that is spacious enough, then we simply replace the record. If the key doesn't exist or the existing record is no big enough, we create/migrate the record in a system transaction then install the record.

Definition at line 363 of file masstree_storage.hpp.

Referenced by upsert_record().

368  {
369  return upsert_record(context, key, key_length, payload, payload_count, payload_count);
370  }
ErrorCode upsert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key or replaces the existing one, or so-called upsert.

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length,
const void *  payload,
PayloadLength  payload_count,
PayloadLength  physical_payload_hint 
)

With this method, you can also specify physical_payload_hint, the physical size of the record's payload part.

If you will later expand the payload of this record, giving a larger value will avoid record migration. Default value (and minimal value) is same as the initial payload_count.

Definition at line 347 of file masstree_storage.cpp.

References foedus::storage::masstree::adjust_payload_hint(), ASSERT_ND, CHECK_ERROR_CODE, foedus::storage::masstree::RecordLocation::is_found(), foedus::kErrorCodeStrTooLongPayload, foedus::storage::masstree::kMaxPayloadLength, foedus::storage::masstree::normalize_be_bytes_full(), foedus::storage::masstree::MasstreeStoragePimpl::reserve_record(), UNLIKELY, foedus::storage::masstree::MasstreeStoragePimpl::upsert_general(), and upsert_record_normalized().

353  {
354  // Automatically switch to faster implementation for 8-byte keys
355  if (key_length == sizeof(KeySlice)) {
356  KeySlice slice = normalize_be_bytes_full(key);
357  return upsert_record_normalized(context, slice, payload, payload_count, physical_payload_hint);
358  }
359 
360  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
362  }
363  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
364  MasstreeStoragePimpl pimpl(this);
365  RecordLocation location;
366  CHECK_ERROR_CODE(pimpl.reserve_record(
367  context,
368  key,
369  key_length,
370  payload_count,
371  physical_payload_hint,
372  &location));
373  ASSERT_ND(location.is_found()); // contract of reserve_record
374  return pimpl.upsert_general(
375  context,
376  location,
377  key,
378  key_length,
379  payload,
380  payload_count);
381 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
0x0808 : "STORAGE: Payload of the record is too long" .
Definition: error_code.hpp:174
ErrorCode upsert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Upserts a new record of the given primitive key in this Masstree.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
PayloadLength adjust_payload_hint(PayloadLength payload_count, PayloadLength physical_payload_hint)
const PayloadLength kMaxPayloadLength
Max length of a payload.
Definition: masstree_id.hpp:98
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#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:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record ( thread::Thread context,
const void *  key,
KeyLength  key_length 
)
inline

Upserts a new record without payload of the given key in this Masstree.

Parameters
[in]contextThread context
[in]keyArbitrary length of key that is lexicographically (big-endian) evaluated.
[in]key_lengthByte size of key.

Definition at line 392 of file masstree_storage.hpp.

References CXX11_NULLPTR, and upsert_record().

395  {
396  return upsert_record(context, key, key_length, CXX11_NULLPTR, 0U);
397  }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
ErrorCode upsert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key or replaces the existing one, or so-called upsert.

Here is the call graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record_normalized ( thread::Thread context,
KeySlice  key,
const void *  payload,
PayloadLength  payload_count 
)
inline

Upserts a new record of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.
[in]payloadValue to upsert.
[in]payload_countLength of payload.

Definition at line 406 of file masstree_storage.hpp.

Referenced by upsert_record(), and upsert_record_normalized().

410  {
411  return upsert_record_normalized(context, key, payload, payload_count, payload_count);
412  }
ErrorCode upsert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Upserts a new record of the given primitive key in this Masstree.

Here is the caller graph for this function:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record_normalized ( thread::Thread context,
KeySlice  key,
const void *  payload,
PayloadLength  payload_count,
PayloadLength  physical_payload_hint 
)

With this method, you can also specify physical_payload_hint.

Definition at line 383 of file masstree_storage.cpp.

References foedus::storage::masstree::adjust_payload_hint(), ASSERT_ND, CHECK_ERROR_CODE, foedus::assorted::htobe< uint64_t >(), foedus::storage::masstree::RecordLocation::is_found(), foedus::kErrorCodeStrTooLongPayload, foedus::storage::masstree::kMaxPayloadLength, foedus::storage::masstree::MasstreeStoragePimpl::reserve_record_normalized(), UNLIKELY, and foedus::storage::masstree::MasstreeStoragePimpl::upsert_general().

388  {
389  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
391  }
392  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
393  MasstreeStoragePimpl pimpl(this);
394  RecordLocation location;
395  CHECK_ERROR_CODE(pimpl.reserve_record_normalized(
396  context,
397  key,
398  payload_count,
399  physical_payload_hint,
400  &location));
401  ASSERT_ND(location.is_found()); // contract of reserve_record
402  uint64_t be_key = assorted::htobe<uint64_t>(key);
403  return pimpl.upsert_general(
404  context,
405  location,
406  &be_key,
407  sizeof(be_key),
408  payload,
409  payload_count);
410 }
0x0808 : "STORAGE: Payload of the record is too long" .
Definition: error_code.hpp:174
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
PayloadLength adjust_payload_hint(PayloadLength payload_count, PayloadLength physical_payload_hint)
const PayloadLength kMaxPayloadLength
Max length of a payload.
Definition: masstree_id.hpp:98
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#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:

ErrorCode foedus::storage::masstree::MasstreeStorage::upsert_record_normalized ( thread::Thread context,
KeySlice  key 
)
inline

Upserts a new record without payload of the given primitive key in this Masstree.

Parameters
[in]contextThread context
[in]keyPrimitive key that is evaluated in the primitive type's comparison rule.

Definition at line 429 of file masstree_storage.hpp.

References CXX11_NULLPTR, and upsert_record_normalized().

429  {
430  return upsert_record_normalized(context, key, CXX11_NULLPTR, 0U);
431  }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
ErrorCode upsert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Upserts a new record of the given primitive key in this Masstree.

Here is the call graph for this function:

ErrorStack foedus::storage::masstree::MasstreeStorage::verify_single_thread ( thread::Thread context)

Definition at line 575 of file masstree_storage.cpp.

References foedus::storage::masstree::MasstreeStoragePimpl::verify_single_thread().

575  {
576  return MasstreeStoragePimpl(this).verify_single_thread(context);
577 }

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 71 of file masstree_storage.cpp.

71  {
72  o << "<MasstreeStorage>"
73  << "<id>" << v.get_id() << "</id>"
74  << "<name>" << v.get_name() << "</name>"
75  << "</MasstreeStorage>";
76  return o;
77 }

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