libfoedus-core
FOEDUS Core Library
|
Array Storage, a dense and regular array. More...
Array Storage, a dense and regular array.
Our array-storage is an extremely simple data structure at the cost of limited applicability (fix-sized, regular, dense arrays). The page layout has little per-page information that is dynamic, meaning that most data never changes after the array storage is created. Further, as everything is pre-allocated, no phantoms, no insertion/splits, nor anything complex. Thus, little synchronization hassles.
Array storage allows very few data operations.
In other words, the following operations are NOT supported.
If these limitations do not cause an issue, array storage is a best choice as it's extremely efficient and scalable thanks to the simplicity.
Despite the name of this storage type, we do have a page hierarchy, which is required to handle switches between volatile/snapshot pages. Hence, a more precise description of this storage type is a fix-sized pre-allocated tree that has only integer-keys from 0 to array_size-1.
All data (payload) are stored in leaf pages and interior pages contain only pointers to its children. There is only one root page per array, which may or may not be a leaf page. Just like B-trees in many sense.
Fix-Sized HEADER (kHeaderSize bytes) | DATA |
---|
InteriorRecord | InteriorRecord | ... |
---|
Record | Padding | Record | Padding | ... |
---|
We do a bit special concurrency control for this storage type. Because everything is pre-allocated and no split/physical-delete/merge whatsoever, we can do the ModCount concurrency control per Record, not per page. We store ModCount for each record, instead stores no ModCount in page header. Thus, individual transactions that update records in same page have no contention except they update the exact same record. We even don't track node-set; only record-set is checked at commit.
This simplifies and increases concurrency for most data accesses, but we have to be careful when the page eviction thread drops the volatile page. We need to know the largest Epoch of records in the page at the point, but concurrent transactions might be modifying records at the same time. Thus, we do two-path optimistic concurrency control similar to our commit protocol for Masstree Storage.
![]() |
Files | |
file | array_id.hpp |
Definitions of IDs in this package and a few related constant values. | |
file | array_log_types.hpp |
Declares all log types used in this storage type. | |
file | fwd.hpp |
Forward declarations of classes in array storage package. | |
Classes | |
class | foedus::storage::array::ArrayComposer |
Composer for an array storage. More... | |
struct | foedus::storage::array::ArrayRange |
Represents an offset range in an array storage. More... | |
struct | foedus::storage::array::ArrayCreateLogType |
Log type of CREATE ARRAY STORAGE operation. More... | |
struct | foedus::storage::array::ArrayCommonUpdateLogType |
A base class for ArrayOverwriteLogType/ArrayIncrementLogType. More... | |
struct | foedus::storage::array::ArrayOverwriteLogType |
Log type of array-storage's overwrite operation. More... | |
struct | foedus::storage::array::ArrayIncrementLogType |
Log type of array-storage's increment operation. More... | |
struct | foedus::storage::array::ArrayMetadata |
Metadata of an array storage. More... | |
union | foedus::storage::array::ArrayPage::Data |
Data union for either leaf (dynamic size) or interior (fixed size). More... | |
class | foedus::storage::array::ArrayPage |
Represents one data page in Array Storage. More... | |
class | foedus::storage::array::ArrayPartitioner |
Partitioner for an array storage. More... | |
union | foedus::storage::array::LookupRoute |
Compactly represents the route to reach the given offset. More... | |
class | foedus::storage::array::LookupRouteFinder |
Packages logic and required properties to calculate LookupRoute in array storage from offset. More... | |
class | foedus::storage::array::ArrayStorage |
Represents a key-value store based on a dense and regular array. More... | |
class | foedus::storage::array::ArrayStoragePimpl |
Pimpl object of ArrayStorage. More... | |
struct | foedus::storage::sequential::SequentialAppendLogType |
Log type of sequential-storage's append operation. More... | |
Typedefs | |
typedef uint64_t | foedus::storage::array::ArrayOffset |
The only key type in array storage. More... | |
Functions | |
void | foedus::storage::array::array_volatile_page_init (const VolatilePageInitArguments &args) |
volatile page initialize callback for ArrayPage. More... | |
void | foedus::storage::hash::hash_intermediate_volatile_page_init (const VolatilePageInitArguments &args) |
volatile page initialize callback for HashIntermediatePage. More... | |
void | foedus::storage::hash::hash_data_volatile_page_init (const VolatilePageInitArguments &args) |
volatile page initialize callback for HashDataPage. More... | |
Variables | |
const ArrayOffset | foedus::storage::array::kMaxArrayOffset = (1ULL << 48) - 1ULL |
The maximum value allowed for ArrayOffset. More... | |
const uint16_t | foedus::storage::array::kHeaderSize = 64 |
Byte size of header in each page of array storage. More... | |
const uint16_t | foedus::storage::array::kDataSize = foedus::storage::kPageSize - kHeaderSize |
Byte size of data region in each page of array storage. More... | |
const uint16_t | foedus::storage::array::kInteriorSize = 16 |
Byte size of an entry in interior page of array storage. More... | |
const uint16_t | foedus::storage::array::kInteriorFanout = (foedus::storage::kPageSize - kHeaderSize) / kInteriorSize |
Max number of entries in an interior page of array storage. More... | |
const uint8_t | foedus::storage::array::kMaxLevels = 8 |
Code in array storage assumes this number as the maximum number of levels. More... | |
const uint16_t | foedus::storage::kRecordOverhead = sizeof(xct::RwLockableXctId) |
Byte size of system-managed region per each record. More... | |
union foedus::storage::array::ArrayPage::Data |
Data union for either leaf (dynamic size) or interior (fixed size).
Definition at line 51 of file array_page_impl.hpp.
Class Members | ||
---|---|---|
DualPagePointer | interior_data[kInteriorFanout] | |
char | leaf_data[kInteriorFanout *sizeof(DualPagePointer)] |
typedef uint64_t foedus::storage::array::ArrayOffset |
The only key type in array storage.
The key in array storage is offset, or an integer starting from zero. This means we don't support multi-dimensional, dynamic, sparse, nor any other fancy arrays. However, those arrays can be provided by the relational layer based on this array storage. The offset-conversion is fairly straightforward.
Definition at line 48 of file array_id.hpp.
void foedus::storage::array::array_volatile_page_init | ( | const VolatilePageInitArguments & | args | ) |
volatile page initialize callback for ArrayPage.
Definition at line 78 of file array_page_impl.cpp.
References ASSERT_ND, foedus::storage::array::ArrayRange::begin_, foedus::storage::VolatilePageInitArguments::context_, foedus::storage::array::ArrayRange::end_, foedus::storage::Storage< CONTROL_BLOCK >::exists(), foedus::storage::array::ArrayPage::get_array_range(), foedus::storage::array::ArrayStorage::get_array_size(), foedus::Attachable< CONTROL_BLOCK >::get_control_block(), foedus::thread::Thread::get_engine(), foedus::savepoint::SavepointManager::get_initial_current_epoch(), foedus::storage::array::ArrayPage::get_level(), foedus::storage::array::ArrayStorage::get_payload_size(), foedus::Engine::get_savepoint_manager(), foedus::storage::array::ArrayPage::get_storage_id(), foedus::storage::VolatilePageInitArguments::index_in_parent_, foedus::storage::array::ArrayPage::initialize_volatile_page(), foedus::storage::array::kInteriorFanout, foedus::storage::VolatilePageInitArguments::page_, foedus::storage::VolatilePageInitArguments::page_id, and foedus::storage::VolatilePageInitArguments::parent_.
Referenced by foedus::storage::array::ArrayStoragePimpl::follow_pointer(), foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_read_batch(), and foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_write_batch().
void foedus::storage::hash::hash_data_volatile_page_init | ( | const VolatilePageInitArguments & | args | ) |
volatile page initialize callback for HashDataPage.
Definition at line 232 of file hash_page_impl.cpp.
References ASSERT_ND, foedus::storage::hash::HashBinRange::begin_, foedus::storage::VolatilePageInitArguments::context_, foedus::storage::hash::HashDataPage::get_bin(), foedus::storage::hash::HashIntermediatePage::get_bin_range(), foedus::storage::hash::HashStorage::get_bin_shifts(), foedus::thread::Thread::get_engine(), foedus::storage::Page::get_header(), foedus::storage::hash::HashIntermediatePage::get_level(), foedus::storage::PageHeader::get_page_type(), foedus::storage::VolatilePageInitArguments::index_in_parent_, foedus::storage::hash::HashDataPage::initialize_volatile_page(), foedus::storage::kHashDataPageType, foedus::storage::hash::kHashIntermediatePageFanout, foedus::storage::kHashIntermediatePageType, foedus::storage::hash::HashBinRange::length(), foedus::storage::VolatilePageInitArguments::page_, foedus::storage::VolatilePageInitArguments::page_id, foedus::storage::VolatilePageInitArguments::parent_, and foedus::storage::PageHeader::storage_id_.
Referenced by foedus::storage::hash::HashStoragePimpl::follow_page_bin_head().
void foedus::storage::hash::hash_intermediate_volatile_page_init | ( | const VolatilePageInitArguments & | args | ) |
volatile page initialize callback for HashIntermediatePage.
Definition at line 213 of file hash_page_impl.cpp.
References ASSERT_ND, foedus::storage::Page::get_header(), foedus::storage::PageHeader::get_page_type(), foedus::storage::VolatilePageInitArguments::index_in_parent_, foedus::storage::hash::HashIntermediatePage::initialize_volatile_page(), foedus::storage::hash::kHashIntermediatePageFanout, foedus::storage::kHashIntermediatePageType, foedus::storage::hash::kHashMaxBins, foedus::storage::VolatilePageInitArguments::page_, foedus::storage::VolatilePageInitArguments::page_id, foedus::storage::VolatilePageInitArguments::parent_, and foedus::storage::PageHeader::storage_id_.
Referenced by foedus::storage::hash::HashStoragePimpl::follow_page().
const uint16_t foedus::storage::array::kDataSize = foedus::storage::kPageSize - kHeaderSize |
Byte size of data region in each page of array storage.
Definition at line 100 of file array_id.hpp.
Referenced by foedus::storage::array::ArrayOverwriteLogType::apply_record(), foedus::storage::array::calculate_levels(), foedus::storage::array::ArrayStoragePimpl::calculate_offset_intervals(), foedus::storage::array::ArrayStoragePimpl::calculate_required_pages(), foedus::storage::array::ArrayPage::get_leaf_record(), foedus::storage::array::ArrayPage::get_leaf_record_count(), and foedus::storage::array::to_records_in_leaf().
const uint16_t foedus::storage::array::kHeaderSize = 64 |
Byte size of header in each page of array storage.
Definition at line 95 of file array_id.hpp.
const uint16_t foedus::storage::array::kInteriorFanout = (foedus::storage::kPageSize - kHeaderSize) / kInteriorSize |
Max number of entries in an interior page of array storage.
Definition at line 110 of file array_id.hpp.
Referenced by foedus::storage::array::array_volatile_page_init(), foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::array::calculate_levels(), foedus::storage::array::ArrayStoragePimpl::calculate_offset_intervals(), foedus::storage::array::LookupRoute::calculate_page_range(), foedus::storage::array::ArrayStoragePimpl::calculate_required_pages(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::array::ArrayPartitioner::design_partition(), foedus::storage::array::ArrayComposer::drop_volatiles(), foedus::storage::array::ArrayComposeContext::execute(), foedus::storage::array::LookupRouteFinder::find_route(), foedus::storage::array::LookupRouteFinder::find_route_and_switch(), foedus::storage::array::ArrayPage::get_interior_record(), foedus::storage::array::ArrayStoragePimpl::hcc_reset_all_temperature_stat_intermediate(), foedus::storage::array::ArrayStoragePimpl::load_empty(), foedus::storage::array::operator<<(), foedus::storage::array::ArrayPartitioner::partition_batch(), foedus::storage::array::ArrayStoragePimpl::prefetch_pages_recurse(), foedus::storage::array::ArrayStoragePimpl::release_pages_recursive(), and foedus::storage::array::ArrayStoragePimpl::verify_single_thread().
const uint16_t foedus::storage::array::kInteriorSize = 16 |
Byte size of an entry in interior page of array storage.
Definition at line 105 of file array_id.hpp.
const ArrayOffset foedus::storage::array::kMaxArrayOffset = (1ULL << 48) - 1ULL |
The maximum value allowed for ArrayOffset.
Definition at line 54 of file array_id.hpp.
Referenced by foedus::storage::array::ArrayStoragePimpl::load_empty(), and foedus::storage::array::SortEntry::set().
const uint8_t foedus::storage::array::kMaxLevels = 8 |
Code in array storage assumes this number as the maximum number of levels.
Interior page always has a big fanout close to 256, so 8 levels are more than enough.
Definition at line 118 of file array_id.hpp.
Referenced by foedus::storage::array::ArrayComposer::compose().
const uint16_t foedus::storage::kRecordOverhead = sizeof(xct::RwLockableXctId) |
Byte size of system-managed region per each record.
Definition at line 56 of file record.hpp.
Referenced by foedus::storage::sequential::SequentialPage::append_record_nosync(), foedus::storage::array::calculate_levels(), foedus::storage::array::ArrayStoragePimpl::calculate_offset_intervals(), foedus::storage::array::ArrayStoragePimpl::calculate_required_pages(), foedus::storage::sequential::SequentialPage::can_insert_record(), foedus::storage::sequential::SequentialPage::get_all_records_nosync(), foedus::storage::array::ArrayPage::get_leaf_record(), foedus::storage::array::ArrayPage::get_leaf_record_count(), foedus::storage::sequential::SequentialPage::get_record_length(), foedus::storage::sequential::SequentialPage::get_record_offset(), foedus::storage::array::ArrayStoragePimpl::get_record_primitive_batch(), and foedus::storage::array::to_records_in_leaf().