18 #ifndef FOEDUS_STORAGE_HASH_HASH_TMPBIN_HPP_
19 #define FOEDUS_STORAGE_HASH_HASH_TMPBIN_HPP_
94 return enclosure->get_record(next_);
106 key_length_ = key_length;
107 payload_length_ = payload_length;
113 std::memcpy(
get_key(), key, key_length);
114 if (key_length != aligned_key_length_) {
115 std::memset(
get_key() + key_length, 0, aligned_key_length_ - key_length);
118 std::memcpy(
get_payload(), payload, payload_length);
119 if (payload_length != aligned_payload_length_) {
120 std::memset(
get_payload() + payload_length, 0, aligned_payload_length_ - payload_length);
125 payload_length_ = payload_length;
128 std::memcpy(
get_payload(), payload, payload_length);
129 if (payload_length != aligned_payload_length_) {
130 std::memset(
get_payload() + payload_length, 0, aligned_payload_length_ - payload_length);
135 uint16_t payload_offset,
137 std::memcpy(
get_payload() + payload_offset, payload, payload_count);
200 return records_ + index;
213 return buckets_[bucket];
231 uint16_t payload_length);
257 uint16_t payload_offset,
258 uint16_t payload_count);
274 uint16_t payload_length);
290 RecordIndex records_capacity_;
296 RecordIndex records_consumed_;
302 RecordIndex* buckets_;
314 void on_memory_set();
317 inline static uint16_t extract_bucket(
HashValue hash) ALWAYS_INLINE {
318 return hash & 0xFFFFU;
322 struct SearchResult {
323 SearchResult(RecordIndex found, RecordIndex tail) : found_(found), tail_(tail) {}
329 SearchResult search_bucket(
338 #endif // FOEDUS_STORAGE_HASH_HASH_TMPBIN_HPP_
T align8(T value)
8-alignment.
Represents one record in our key-value store.
ErrorCode create_memory(uint16_t numa_node, uint64_t initial_size=kDefaultInitialSize)
Allocates the memory to use by this object.
uint16_t aligned_key_length_
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
uint32_t RecordIndex
Pointer to Record.
void clean()
Removes all tuple data for the current bin.
ErrorCode update_record(xct::XctId xct_id, const void *key, uint16_t key_length, HashValue hash, const void *payload, uint16_t payload_length)
Updates a record of the given key with the given payload, which might change length.
void set_all(xct::XctId xct_id, const void *key, uint16_t key_length, HashValue hash, const void *payload, uint16_t payload_length) __attribute__((always_inline))
void steal_memory(memory::AlignedMemory *provider)
This is a special version of create_memory() where this object steals the memory ownership from the r...
char data_[kPageSize-32]
key and payload, like the log entry, key part is 8-byte aligned.
An in-memory single-threaded data structure to compose tuples in a hash bin.
Persistent status part of Transaction ID.
friend std::ostream & operator<<(std::ostream &o, const HashTmpBin &v)
void clean_quick()
This version selectively clears buckets_ by seeing individual records.
HashTmpBin()
Constructor doesn't do any initialization.
Let's be super generous, assuming that we are reusing memories.
Independent utility methods/classes for hashination, or hash functions.
void overwrite_payload(const void *payload, uint16_t payload_offset, uint16_t payload_count) __attribute__((always_inline))
RecordIndex get_records_consumed() const
Definitions of IDs in this package and a few related constant values.
char * get_payload() __attribute__((always_inline))
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
uint16_t aligned_payload_length_
This is a per-bin data structure.
char * get_key() __attribute__((always_inline))
uint32_t get_physical_record_count() const
ErrorCode delete_record(xct::XctId xct_id, const void *key, uint16_t key_length, HashValue hash)
Logically deletes a record of the given key.
Record * get_record(RecordIndex index) const
void set_payload(const void *payload, uint16_t payload_length) __attribute__((always_inline))
ErrorCode insert_record(xct::XctId xct_id, const void *key, uint16_t key_length, HashValue hash, const void *payload, uint16_t payload_length)
Inserts a new record of the given key and payload.
ErrorCode overwrite_record(xct::XctId xct_id, const void *key, uint16_t key_length, HashValue hash, const void *payload, uint16_t payload_offset, uint16_t payload_count)
Overwrites a part of the record of the given key.
void give_memory(memory::AlignedMemory *recipient)
This is a special version of release_memory() where this object moves the memory ownership to the rec...
Represents one memory block aligned to actual OS/hardware pages.
RecordIndex next_
constitutes a singly-linked list in each bucket
RecordIndex get_records_capacity() const
Represents a record with a unique key.
void release_memory()
Destructor automatically releases everything, but you can use this to do it earlier.
RecordIndex get_first_record() const
RecordIndex get_bucket_head(uint32_t bucket) const
Record * get_record_next(const HashTmpBin *enclosure) 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'...
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.
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Forward declarations of classes in hash storage package.
uint64_t HashValue
Represents a full 64-bit hash value calculated from a key.