libfoedus-core
FOEDUS Core Library
|
Represents a key-value store based on a dense and regular array. More...
Represents a key-value store based on a dense and regular array.
Definition at line 47 of file array_storage.hpp.
#include <array_storage.hpp>
Public Types | |
typedef ArrayStoragePimpl | ThisPimpl |
typedef ArrayCreateLogType | ThisCreateLogType |
typedef ArrayMetadata | ThisMetadata |
Public Member Functions | |
ArrayStorage () | |
ArrayStorage (Engine *engine, ArrayStorageControlBlock *control_block) | |
ArrayStorage (Engine *engine, StorageControlBlock *control_block) | |
ArrayStorage (Engine *engine, StorageId id) | |
ArrayStorage (Engine *engine, const StorageName &name) | |
ArrayStorage (const ArrayStorage &other) | |
ArrayStorage & | operator= (const ArrayStorage &other) |
const ArrayMetadata * | get_array_metadata () const |
ErrorStack | create (const Metadata &metadata) |
ErrorStack | load (const StorageControlBlock &snapshot_block) |
ErrorStack | drop () |
ErrorCode | prefetch_pages (thread::Thread *context, bool install_volatile, bool cache_snapshot, ArrayOffset from, ArrayOffset to) |
Prefetch data pages in this storage. More... | |
uint16_t | get_payload_size () const |
Returns byte size of one record in this array storage without internal overheads. More... | |
ArrayOffset | get_array_size () const |
Returns the size of this array. More... | |
uint8_t | get_levels () const |
Returns the number of levels. More... | |
ErrorCode | get_record (thread::Thread *context, ArrayOffset offset, void *payload) |
Retrieves one record of the given offset in this array storage. More... | |
ErrorCode | get_record (thread::Thread *context, ArrayOffset offset, void *payload, uint16_t payload_offset, uint16_t payload_count) |
Retrieves a part of record of the given offset in this array storage. More... | |
template<typename T > | |
ErrorCode | get_record_primitive (thread::Thread *context, ArrayOffset offset, T *payload, uint16_t payload_offset) |
Retrieves a part of record of the given offset as a primitive type in this array storage. More... | |
ErrorCode | get_record_payload (thread::Thread *context, ArrayOffset offset, const void **payload) |
Retrieves a pointer to the entire payload. More... | |
ErrorCode | get_record_for_write (thread::Thread *context, ArrayOffset offset, Record **record) |
Retrieves a pointer to the entire record for write (thus always in volatile page). More... | |
template<typename T > | |
ErrorCode | get_record_primitive_batch (thread::Thread *context, uint16_t payload_offset, uint16_t batch_size, const ArrayOffset *offset_batch, T *payload) |
batched interface More... | |
ErrorCode | get_record_payload_batch (thread::Thread *context, uint16_t batch_size, const ArrayOffset *offset_batch, const void **payload_batch) |
ErrorCode | get_record_for_write_batch (thread::Thread *context, uint16_t batch_size, const ArrayOffset *offset_batch, Record **record_batch) |
ErrorCode | overwrite_record (thread::Thread *context, ArrayOffset offset, const void *payload) |
Overwrites one record of the given offset in this array storage. More... | |
ErrorCode | overwrite_record (thread::Thread *context, ArrayOffset offset, const void *payload, uint16_t payload_offset, uint16_t payload_count) |
Overwrites a part of one record of the given offset in this array storage. More... | |
template<typename T > | |
ErrorCode | overwrite_record_primitive (thread::Thread *context, ArrayOffset offset, T payload, uint16_t payload_offset) |
Overwrites a part of record of the given offset as a primitive type in this array storage. More... | |
ErrorCode | overwrite_record (thread::Thread *context, ArrayOffset offset, Record *record, const void *payload, uint16_t payload_offset, uint16_t payload_count) |
Overwrites a part of the pre-searched record in this array storage. More... | |
template<typename T > | |
ErrorCode | overwrite_record_primitive (thread::Thread *context, ArrayOffset offset, Record *record, T payload, uint16_t payload_offset) |
Overwrites a part of pre-searched record as a primitive type in this array storage. More... | |
template<typename T > | |
ErrorCode | increment_record (thread::Thread *context, ArrayOffset offset, T *value, uint16_t payload_offset) |
This one further optimizes overwrite_record_primitive() for the frequent use case of incrementing some data in primitive type. More... | |
template<typename T > | |
ErrorCode | increment_record_oneshot (thread::Thread *context, ArrayOffset offset, T value, uint16_t payload_offset) |
This is a faster increment that does not return the value after increment. More... | |
ErrorStack | hcc_reset_all_temperature_stat () |
Resets all volatile pages' temperature stat to be zero in this storage. More... | |
ErrorStack | verify_single_thread (thread::Thread *context) |
![]() | |
Storage () | |
Storage (Engine *engine, ArrayStorageControlBlock *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) | |
Storage & | operator= (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 StorageName & | get_name () const |
Returns the unique name of this storage. More... | |
const Metadata * | get_metadata () const |
Returns the metadata of this storage. More... | |
bool | exists () const |
Returns whether this storage is already created. More... | |
![]() | |
Attachable () | |
Attachable (Engine *engine) | |
Attachable (Engine *engine, ArrayStorageControlBlock *control_block) | |
Attachable (ArrayStorageControlBlock *control_block) | |
Attachable (const Attachable &other) | |
virtual | ~Attachable () |
Attachable & | operator= (const Attachable &other) |
virtual void | attach (ArrayStorageControlBlock *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... | |
ArrayStorageControlBlock * | get_control_block () const |
Engine * | get_engine () const |
void | set_engine (Engine *engine) |
Friends | |
std::ostream & | operator<< (std::ostream &o, const ArrayStorage &v) |
Additional Inherited Members | |
![]() | |
Engine * | engine_ |
Most attachable object stores an engine pointer (local engine), so we define it here. More... | |
ArrayStorageControlBlock * | control_block_ |
The shared data on shared memory that has been initialized in some SOC or master engine. More... | |
Definition at line 50 of file array_storage.hpp.
Definition at line 51 of file array_storage.hpp.
Definition at line 49 of file array_storage.hpp.
foedus::storage::array::ArrayStorage::ArrayStorage | ( | ) |
Definition at line 31 of file array_storage.cpp.
foedus::storage::array::ArrayStorage::ArrayStorage | ( | Engine * | engine, |
ArrayStorageControlBlock * | control_block | ||
) |
Definition at line 32 of file array_storage.cpp.
References ASSERT_ND, foedus::storage::Storage< ArrayStorageControlBlock >::exists(), foedus::storage::Storage< ArrayStorageControlBlock >::get_type(), and foedus::storage::kArrayStorage.
foedus::storage::array::ArrayStorage::ArrayStorage | ( | Engine * | engine, |
StorageControlBlock * | control_block | ||
) |
Definition at line 36 of file array_storage.cpp.
References ASSERT_ND, foedus::storage::Storage< ArrayStorageControlBlock >::exists(), foedus::storage::Storage< ArrayStorageControlBlock >::get_type(), and foedus::storage::kArrayStorage.
Definition at line 40 of file array_storage.cpp.
foedus::storage::array::ArrayStorage::ArrayStorage | ( | Engine * | engine, |
const StorageName & | name | ||
) |
Definition at line 42 of file array_storage.cpp.
foedus::storage::array::ArrayStorage::ArrayStorage | ( | const ArrayStorage & | other | ) |
Definition at line 44 of file array_storage.cpp.
ErrorStack foedus::storage::array::ArrayStorage::create | ( | const Metadata & | metadata | ) |
Definition at line 52 of file array_storage.cpp.
References foedus::storage::array::ArrayStoragePimpl::create().
ErrorStack foedus::storage::array::ArrayStorage::drop | ( | ) |
Definition at line 227 of file array_storage_pimpl.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_, foedus::Attachable< ArrayStorageControlBlock >::engine_, foedus::memory::EngineMemory::get_global_volatile_page_resolver(), foedus::Engine::get_memory_manager(), foedus::kRetOk, foedus::memory::PageReleaseBatch::release_all(), and foedus::storage::array::ArrayStoragePimpl::release_pages_recursive().
const ArrayMetadata * foedus::storage::array::ArrayStorage::get_array_metadata | ( | ) | const |
Definition at line 59 of file array_storage_pimpl.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_.
Referenced by foedus::storage::array::ArrayComposer::drop_root_volatile(), and foedus::storage::array::ArrayComposer::drop_volatiles().
ArrayOffset foedus::storage::array::ArrayStorage::get_array_size | ( | ) | const |
Returns the size of this array.
Definition at line 57 of file array_storage_pimpl.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_.
Referenced by foedus::storage::array::array_volatile_page_init(), foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::array::ArrayPartitioner::design_partition(), foedus::storage::array::ArrayComposer::drop_root_volatile(), foedus::storage::array::operator<<(), and prefetch_pages().
uint8_t foedus::storage::array::ArrayStorage::get_levels | ( | ) | const |
Returns the number of levels.
Definition at line 58 of file array_storage_pimpl.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_.
Referenced by foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::array::ArrayPartitioner::design_partition(), and foedus::storage::array::ArrayComposer::drop_root_volatile().
uint16_t foedus::storage::array::ArrayStorage::get_payload_size | ( | ) | const |
Returns byte size of one record in this array storage without internal overheads.
ArrayStorage is a fix-sized storage, thus we have this interface in storage level rather than in record level.
Definition at line 56 of file array_storage_pimpl.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_.
Referenced by foedus::storage::array::array_volatile_page_init(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::array::ArrayComposer::drop_root_volatile(), get_record(), foedus::storage::array::operator<<(), and overwrite_record().
ErrorCode foedus::storage::array::ArrayStorage::get_record | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
void * | payload | ||
) |
Retrieves one record of the given offset in this array storage.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[out] | payload | We copy the record to this address. Must be at least get_payload_size(). |
Equivalent to get_record(context, offset, payload, 0, get_payload_size()).
Definition at line 65 of file array_storage_pimpl.cpp.
References get_payload_size().
ErrorCode foedus::storage::array::ArrayStorage::get_record | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
void * | payload, | ||
uint16_t | payload_offset, | ||
uint16_t | payload_count | ||
) |
Retrieves a part of record of the given offset in this array storage.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[out] | payload | We copy the record to this address. Must be at least payload_count. |
[in] | payload_offset | We copy from this byte position of the record. |
[in] | payload_count | How many bytes we copy. |
Definition at line 70 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::get_record().
ErrorCode foedus::storage::array::ArrayStorage::get_record_for_write | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
Record ** | record | ||
) |
Retrieves a pointer to the entire record for write (thus always in volatile page).
[in] | context | Thread context |
[in] | offset | The offset in this array |
[out] | record | Sets the pointer to the record in a volatile page. |
This is used to retrieve entire record without copying and also to prepare for writes. Though "record" is a non-const pointer, of course don't directly write to it. Use overwrite_xxx etc which does the pre-commit protocol to write. This also adds to read-set.
Definition at line 89 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::get_record_for_write().
ErrorCode foedus::storage::array::ArrayStorage::get_record_for_write_batch | ( | thread::Thread * | context, |
uint16_t | batch_size, | ||
const ArrayOffset * | offset_batch, | ||
Record ** | record_batch | ||
) |
Definition at line 655 of file array_storage_pimpl.cpp.
References CHECK_ERROR_CODE, foedus::storage::array::ArrayStoragePimpl::get_record_for_write_batch(), foedus::storage::array::ArrayStoragePimpl::kBatchMax, and foedus::kErrorCodeOk.
ErrorCode foedus::storage::array::ArrayStorage::get_record_payload | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
const void ** | payload | ||
) |
Retrieves a pointer to the entire payload.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[out] | payload | Sets the pointer to the payload. |
This is used to retrieve entire record without copying. The record is protected by read-set (if there is any change, it will abort at pre-commit). However, we might read a half-changed value in the meantime.
Definition at line 82 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::get_record_payload().
ErrorCode foedus::storage::array::ArrayStorage::get_record_payload_batch | ( | thread::Thread * | context, |
uint16_t | batch_size, | ||
const ArrayOffset * | offset_batch, | ||
const void ** | payload_batch | ||
) |
Definition at line 634 of file array_storage_pimpl.cpp.
References CHECK_ERROR_CODE, foedus::storage::array::ArrayStoragePimpl::get_record_payload_batch(), foedus::storage::array::ArrayStoragePimpl::kBatchMax, and foedus::kErrorCodeOk.
ErrorCode foedus::storage::array::ArrayStorage::get_record_primitive | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
T * | payload, | ||
uint16_t | payload_offset | ||
) |
Retrieves a part of record of the given offset as a primitive type in this array storage.
A bit more efficient than get_record().
[in] | context | Thread context |
[in] | offset | The offset in this array |
[out] | payload | We copy the record to this address. |
[in] | payload_offset | We copy from this byte position of the record. |
T | primitive type. All integers and floats are allowed. |
Definition at line 77 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::get_record_primitive().
ErrorCode foedus::storage::array::ArrayStorage::get_record_primitive_batch | ( | thread::Thread * | context, |
uint16_t | payload_offset, | ||
uint16_t | batch_size, | ||
const ArrayOffset * | offset_batch, | ||
T * | payload | ||
) |
batched interface
Definition at line 611 of file array_storage_pimpl.cpp.
References CHECK_ERROR_CODE, foedus::storage::array::ArrayStoragePimpl::get_record_primitive_batch(), foedus::storage::array::ArrayStoragePimpl::kBatchMax, and foedus::kErrorCodeOk.
ErrorStack foedus::storage::array::ArrayStorage::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 964 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::hcc_reset_all_temperature_stat().
ErrorCode foedus::storage::array::ArrayStorage::increment_record | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
T * | value, | ||
uint16_t | payload_offset | ||
) |
This one further optimizes overwrite_record_primitive() for the frequent use case of incrementing some data in primitive type.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[in,out] | value | (in) addendum, (out) value after addition. |
[in] | payload_offset | We write to this byte position of the record. |
T | primitive type. All integers and floats are allowed. |
This method combines get and overwrite, so it can halve the number of tree lookup. This method can be only provided with template, so we omit "_primitive".
Definition at line 148 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::increment_record().
ErrorCode foedus::storage::array::ArrayStorage::increment_record_oneshot | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
T | value, | ||
uint16_t | payload_offset | ||
) |
This is a faster increment that does not return the value after increment.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[in] | value | addendum |
[in] | payload_offset | We write to this byte position of the record. |
T | primitive type. All integers and floats are allowed. |
This method is faster than increment_record because it doesn't rely on the current value. This uses a rare "write-set only" log. other increments have to check deletion bit at least.
Definition at line 154 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::increment_record_oneshot().
ErrorStack foedus::storage::array::ArrayStorage::load | ( | const StorageControlBlock & | snapshot_block | ) |
Definition at line 56 of file array_storage.cpp.
References foedus::storage::array::ArrayStoragePimpl::load().
ArrayStorage & foedus::storage::array::ArrayStorage::operator= | ( | const ArrayStorage & | other | ) |
Definition at line 47 of file array_storage.cpp.
References foedus::Attachable< ArrayStorageControlBlock >::control_block_, foedus::Attachable< CONTROL_BLOCK >::control_block_, foedus::Attachable< ArrayStorageControlBlock >::engine_, and foedus::Attachable< CONTROL_BLOCK >::engine_.
|
inline |
Overwrites one record of the given offset in this array storage.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[in] | payload | We copy from this buffer. Must be at least get_payload_size(). |
Equivalent to overwrite_record(context, offset, payload, 0, get_payload_size()).
Definition at line 198 of file array_storage.hpp.
References get_payload_size().
ErrorCode foedus::storage::array::ArrayStorage::overwrite_record | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
const void * | payload, | ||
uint16_t | payload_offset, | ||
uint16_t | payload_count | ||
) |
Overwrites a part of one record of the given offset in this array storage.
[in] | context | Thread context |
[in] | offset | The offset in this array |
[in] | payload | We copy from this buffer. Must be at least get_payload_size(). |
[in] | payload_offset | We copy to this byte position of the record. |
[in] | payload_count | How many bytes we copy. |
Definition at line 96 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::overwrite_record().
ErrorCode foedus::storage::array::ArrayStorage::overwrite_record | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
Record * | record, | ||
const void * | payload, | ||
uint16_t | payload_offset, | ||
uint16_t | payload_count | ||
) |
Overwrites a part of the pre-searched record in this array storage.
[in] | context | Thread context |
[in] | offset | The offset in this array. Used for logging. |
[in] | record | Pointer to the record. |
[in] | payload | We copy from this buffer. |
[in] | payload_offset | We copy to this byte position of the record. |
[in] | payload_count | How many bytes we copy. |
Definition at line 116 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::overwrite_record().
ErrorCode foedus::storage::array::ArrayStorage::overwrite_record_primitive | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
T | payload, | ||
uint16_t | payload_offset | ||
) |
Overwrites a part of record of the given offset as a primitive type in this array storage.
A bit more efficient than overwrite_record().
[in] | context | Thread context |
[in] | offset | The offset in this array |
[in] | payload | The value as primitive type. |
[in] | payload_offset | We copy to this byte position of the record. |
T | primitive type. All integers and floats are allowed. |
Definition at line 107 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::overwrite_record_primitive().
ErrorCode foedus::storage::array::ArrayStorage::overwrite_record_primitive | ( | thread::Thread * | context, |
ArrayOffset | offset, | ||
Record * | record, | ||
T | payload, | ||
uint16_t | payload_offset | ||
) |
Overwrites a part of pre-searched record as a primitive type in this array storage.
A bit more efficient than overwrite_record().
[in] | context | Thread context |
[in] | offset | The offset in this array. Used for logging. |
[in] | record | Pointer to the record. |
[in] | payload | The value as primitive type. |
[in] | payload_offset | We copy to this byte position of the record. |
T | primitive type. All integers and floats are allowed. |
Definition at line 133 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::overwrite_record_primitive().
ErrorCode foedus::storage::array::ArrayStorage::prefetch_pages | ( | thread::Thread * | context, |
bool | install_volatile, | ||
bool | cache_snapshot, | ||
ArrayOffset | from, | ||
ArrayOffset | to | ||
) |
Prefetch data pages in this storage.
[in] | context | Thread context. |
[in] | install_volatile | Whether to install/prefetch volatile pages based on the recent snapshot page if there is none. |
[in] | cache_snapshot | Whether to cache/prefetch snapshot pages if exists. |
[in] | from | inclusive begin offset of records that are specifically prefetched even in data pages. |
[in] | to | exclusive end offset of records that are specifically prefetched even in data pages. 0 means up to the end of the storage. |
This is to warmup the storage for the current core. Data pages are prefetched within from/to.
Definition at line 71 of file array_storage.cpp.
References get_array_size(), and foedus::storage::array::ArrayStoragePimpl::prefetch_pages().
ErrorStack foedus::storage::array::ArrayStorage::verify_single_thread | ( | thread::Thread * | context | ) |
Definition at line 61 of file array_storage_pimpl.cpp.
References foedus::storage::array::ArrayStoragePimpl::verify_single_thread().
|
friend |
Definition at line 60 of file array_storage.cpp.