18 #ifndef FOEDUS_STORAGE_HASH_HASH_PAGE_HPP_
19 #define FOEDUS_STORAGE_HASH_HASH_PAGE_HPP_
249 return reinterpret_cast<const Slot*
>(
this + 1)[-record - 1];
252 return reinterpret_cast<Slot*
>(
this + 1)[-record - 1];
256 return reinterpret_cast<Slot*
>(
this + 1)[-record - 1];
260 return reinterpret_cast<const Slot*
>(
this + 1) - record - 1;
263 return reinterpret_cast<Slot*
>(
this + 1) - record - 1;
269 int64_t index =
reinterpret_cast<const Slot*
>(
this + 1) - slot - 1;
271 ASSERT_ND(index < static_cast<int64_t>(
sizeof(data_) /
sizeof(
Slot)));
284 if (consumed >
sizeof(data_)) {
287 return sizeof(data_) - consumed;
302 inline static uint16_t
required_space(uint16_t key_length, uint16_t payload_length) {
329 uint16_t payload_length);
400 uint16_t key_length)
const {
409 return std::memcmp(data, key, key_length) == 0;
486 const void* payload_arg,
487 uint16_t payload_length) {
491 ASSERT_ND(reinterpret_cast<uintptr_t>(key_arg) % 8 == 0);
492 ASSERT_ND(reinterpret_cast<uintptr_t>(payload_arg) % 8 == 0);
510 std::memcpy(record, key, key_length);
511 if (key_length != aligned_key_length) {
512 std::memset(record + key_length, 0, aligned_key_length - key_length % 8);
515 if (payload_length > 0) {
516 char* dest =
reinterpret_cast<char*
>(
ASSUME_ALIGNED(record + aligned_key_length, 8U));
518 std::memcpy(dest, payload, payload_length);
519 if (key_length != aligned_payload_length) {
520 std::memset(dest + payload_length, 0, aligned_payload_length - payload_length);
524 bloom_filter_.
add(fingerprint);
532 "sizeof(HashIntermediatePage) is not kPageSize");
536 "sizeof(HashDataPage) is not kPageSize");
541 #endif // FOEDUS_STORAGE_HASH_HASH_PAGE_HPP_
Slot * get_slot_address(DataPageSlotIndex record) __attribute__((always_inline))
DualPagePointer * next_page_address() __attribute__((always_inline))
uint8_t get_bin_shifts() const
T align8(T value)
8-alignment.
HashIntermediatePage()=delete
Represents a pointer to another page (usually a child page).
const DataPageBloomFilter & bloom_filter() const __attribute__((always_inline))
Definitions of IDs in this package and a few related constant values.
friend std::ostream & operator<<(std::ostream &o, const HashDataPage &v)
defined in hash_page_debug.cpp.
uint16_t next_offset() const
Returns offset of a next record.
uint32_t StorageId
Unique ID for storage.
const HashBinRange & get_bin_range() const
xct::RwLockableXctId tid_
TID of the record.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
uint16_t payload_length_
Byte length of the payload.
void assert_entries() const __attribute__((always_inline))
void create_record_in_snapshot(xct::XctId xct_id, HashValue hash, const BloomFilterFingerprint &fingerprint, const void *key, uint16_t key_length, const void *payload, uint16_t payload_length) __attribute__((always_inline))
A simplified/efficient version to insert an active record, which must be used only in snapshot pages...
const char * record_from_offset(uint16_t offset) const
Represents a pointer to a volatile page with modification count for preventing ABA.
Forward declarations of classes in root package.
Persistent status part of Transaction ID.
bool compare_slot_key(DataPageSlotIndex index, HashValue hash, const void *key, uint16_t key_length) const
returns whether the slot contains the exact key specified
XctId xct_id_
the second 64bit: Persistent status part of TID.
SnapshotPagePointer get_snapshot_page_id() const
DataPageSlotIndex reserve_record(HashValue hash, const BloomFilterFingerprint &fingerprint, const void *key, uint16_t key_length, uint16_t payload_length)
A system transaction that creates a logically deleted record in this page for the given key...
void assert_entries_impl() const
defined in hash_page_debug.cpp.
#define ASSUME_ALIGNED(x, y)
Wraps GCC's __builtin_assume_aligned.
void assert_bin(HashBin bin) const __attribute__((always_inline))
void initialize_snapshot_page(StorageId storage_id, SnapshotPagePointer page_id, HashBin bin, uint8_t bin_bits, uint8_t bin_shifts)
const Slot & get_slot(DataPageSlotIndex record) const __attribute__((always_inline))
uint16_t get_aligned_key_length() const
uint16_t key_length_
Byte length of key of the record.
friend std::ostream & operator<<(std::ostream &o, const HashIntermediatePage &v)
defined in hash_page_debug.cpp.
bool contains(HashBin hash) const
const DualPagePointer * next_page_address() const __attribute__((always_inline))
DualPagePointer & next_page() __attribute__((always_inline))
HashValue hash_
Full hash of the key of the record.
The MCS reader-writer lock variant of LockableXctId.
const Slot * get_slot_address(DataPageSlotIndex record) const __attribute__((always_inline))
same as &get_slot(), but this is more explicit and easier to understand/maintain
Independent utility methods/classes for hashination, or hash functions.
HashValue hashinate(const void *key, uint16_t key_length)
Calculates hash value for general input.
void protected_set_bin_shifts(uint8_t bin_shifts)
this method should be called only in page creation.
HashIntermediatePage & operator=(const HashIntermediatePage &other)=delete
Definitions of IDs in this package and a few related constant values.
const DualPagePointer & get_pointer(uint16_t index) const
SnapshotPagePointer get_snapshot_page_id() const
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Database engine object that holds all resources and provides APIs.
A system transaction to reserve a physical record(s) in a hash data page.
Fix-sized slot for each record, which is placed at the end of data region.
Set of arguments, both inputs and outputs, given to each volatile page initializer.
Just a marker to denote that the memory region represents a data page.
Represents a range of hash bins in a hash storage, such as what an intermediate page is responsible f...
uint64_t get_dummy_padding_unused() const
uint16_t DataPageSlotIndex
void release_pages_recursive_parallel(Engine *engine)
uint16_t physical_record_length_
Byte count this record occupies.
void release_pages_recursive(const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
DualPagePointer * get_pointer_address(uint16_t index)
HashDataPage & operator=(const HashDataPage &other)=delete
void initialize_volatile_page(StorageId storage_id, VolatilePagePointer page_id, const HashIntermediatePage *parent, uint8_t level, HashBin start_bin)
Called only when this page is initialized.
void assert_range() const __attribute__((always_inline))
void assert_bin(HashBin bin) const __attribute__((always_inline))
Slot & get_new_slot(DataPageSlotIndex record) __attribute__((always_inline))
Forward declarations of classes in memory package.
Represents an intermediate page in Hashtable Storage.
void initialize_snapshot_page(StorageId storage_id, SnapshotPagePointer page_id, uint8_t level, HashBin start_bin)
static uint16_t required_space(uint16_t key_length, uint16_t payload_length)
returns physical_record_length_ for a new record
const DualPagePointer * get_pointer_address(uint16_t index) const
uint16_t get_max_payload() const
VolatilePagePointer get_volatile_page_id() const
void hash_intermediate_volatile_page_init(const VolatilePageInitArguments &args)
volatile page initialize callback for HashIntermediatePage.
char * record_from_offset(uint16_t offset)
Slot & get_slot(DataPageSlotIndex record) __attribute__((always_inline))
uint64_t HashBin
Represents a bin of a hash value.
void add(const BloomFilterFingerprint &fingerprint) __attribute__((always_inline))
Adds the fingerprint to this bloom filter.
Represents an individual data page in Hashtable Storage.
uint16_t available_space() const
Returns usable space in bytes.
const DualPagePointer & next_page() const __attribute__((always_inline))
void hash_data_volatile_page_init(const VolatilePageInitArguments &args)
volatile page initialize callback for HashDataPage.
A fingerprint for bloom filter in each HashDataPage.
DataPageSlotIndex to_slot_index(const Slot *slot) const __attribute__((always_inline))
void initialize_volatile_page(StorageId storage_id, VolatilePagePointer page_id, const Page *parent, HashBin bin, uint8_t bin_shifts)
uint16_t KeyLength
Represents a byte-length of a key in this package.
To quickly check whether a HashDataPage might contain a specific hash value, we maintain a non-counti...
uint8_t get_level() const
const uint8_t kHashIntermediatePageFanout
Number of pointers in an intermediate page of hash storage.
const PageHeader & header() const
const uint64_t kHashMaxBins[]
kHashTotalBins[n] gives the maximum number of hash bins n-level hash can hold.
uint16_t get_record_count() const __attribute__((always_inline))
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
bool is_locked() const __attribute__((always_inline))
Definitions of IDs in this package and a few related constant values.
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
VolatilePagePointer get_volatile_page_id() const
DualPagePointer & get_pointer(uint16_t index)
const PageHeader & header() const
void release_pages_recursive(const memory::GlobalVolatilePageResolver &page_resolver, memory::PageReleaseBatch *batch)
const uint16_t kHashDataPageDataSize
Body data byte size in data page of hash storage.
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
DataPageSlotIndex search_key_physical(HashValue hash, const BloomFilterFingerprint &fingerprint, const void *key, KeyLength key_length, DataPageSlotIndex record_count, DataPageSlotIndex check_from=0) const
Search for a physical slot that exactly contains the given key.
uint16_t offset_
Byte offset in data_ where this record starts.
uint64_t HashValue
Represents a full 64-bit hash value calculated from a key.
DataPageBloomFilter & bloom_filter() __attribute__((always_inline))