libfoedus-core
FOEDUS Core Library
foedus::storage::hash::HashStorage Class Referencefinal

Represents a key-value store based on a dense and regular hash. More...

Detailed Description

Represents a key-value store based on a dense and regular hash.

Definition at line 43 of file hash_storage.hpp.

#include <hash_storage.hpp>

Inheritance diagram for foedus::storage::hash::HashStorage:
Collaboration diagram for foedus::storage::hash::HashStorage:

Public Types

typedef HashStoragePimpl ThisPimpl
 
typedef HashCreateLogType ThisCreateLogType
 
typedef HashMetadata ThisMetadata
 

Public Member Functions

 HashStorage ()
 
 HashStorage (Engine *engine, HashStorageControlBlock *control_block)
 
 HashStorage (Engine *engine, StorageControlBlock *control_block)
 
 HashStorage (Engine *engine, StorageId id)
 
 HashStorage (Engine *engine, const StorageName &name)
 
 HashStorage (const HashStorage &other)
 
HashStorageoperator= (const HashStorage &other)
 
const HashMetadataget_hash_metadata () const
 
uint8_t get_levels () const
 
HashBin get_bin_count () const
 
uint8_t get_bin_bits () const
 
uint8_t get_bin_shifts () const
 
uint16_t get_root_children () const
 
ErrorStack create (const Metadata &metadata)
 
ErrorStack load (const StorageControlBlock &snapshot_block)
 
ErrorStack drop ()
 
xct::TrackMovedRecordResult track_moved_record (xct::RwLockableXctId *old_address, xct::WriteXctAccess *write_set)
 Resolves a "moved" record. More...
 
ErrorStack verify_single_thread (Engine *engine)
 
ErrorStack verify_single_thread (thread::Thread *context)
 
ErrorStack hcc_reset_all_temperature_stat ()
 Resets all volatile pages' temperature stat to be zero in this storage. More...
 
ErrorStack debugout_single_thread (Engine *engine, bool volatile_only=false, bool intermediate_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 hash storage in details. More...
 
HashCombo combo (const void *key, uint16_t key_length) const
 Prepares a set of information that are used in many places, extracted from the given key. More...
 
template<typename KEY >
HashCombo combo (KEY *key) const
 Overlord to receive key as a primitive type. More...
 
ErrorCode get_record (thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t *payload_capacity, bool read_only)
 Retrieves an entire payload of the given key in this hash storage. More...
 
template<typename KEY >
ErrorCode get_record (thread::Thread *context, KEY key, void *payload, uint16_t *payload_capacity, bool read_only)
 Overlord to receive key as a primitive type. More...
 
ErrorCode get_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, void *payload, uint16_t *payload_capacity, bool read_only)
 If you have already computed HashCombo, use this. More...
 
ErrorCode get_record_part (thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t payload_offset, uint16_t payload_count, bool read_only)
 Retrieves a part of the given key in this hash storage. More...
 
template<typename KEY >
ErrorCode get_record_part (thread::Thread *context, KEY key, void *payload, uint16_t payload_offset, uint16_t payload_count, bool read_only)
 Overlord to receive key as a primitive type. More...
 
ErrorCode get_record_part (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, void *payload, uint16_t payload_offset, uint16_t payload_count, bool read_only)
 If you have already computed HashCombo, use this. More...
 
template<typename PAYLOAD >
ErrorCode get_record_primitive (thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD *payload, uint16_t payload_offset, bool read_only)
 Retrieves a part of the given key in this storage as a primitive value. More...
 
template<typename KEY , typename PAYLOAD >
ErrorCode get_record_primitive (thread::Thread *context, KEY key, PAYLOAD *payload, uint16_t payload_offset, bool read_only)
 Overlord to receive key as a primitive type. More...
 
template<typename PAYLOAD >
ErrorCode get_record_primitive (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, PAYLOAD *payload, uint16_t payload_offset, bool read_only)
 If you have already computed HashCombo, use this. More...
 
ErrorCode insert_record (thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
 Inserts a new record of the given key in this hash storage. More...
 
template<typename KEY >
ErrorCode insert_record (thread::Thread *context, KEY key, const void *payload, uint16_t payload_count)
 Overlord to receive key as a primitive type. More...
 
ErrorCode insert_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, const void *payload, uint16_t payload_count, uint16_t physical_payload_hint)
 If you have already computed HashCombo, use this. More...
 
ErrorCode delete_record (thread::Thread *context, const void *key, uint16_t key_length)
 Deletes a record of the given key from this hash storage. More...
 
template<typename KEY >
ErrorCode delete_record (thread::Thread *context, KEY key)
 Overlord to receive key as a primitive type. More...
 
ErrorCode delete_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo)
 If you have already computed HashCombo, use this. More...
 
ErrorCode upsert_record (thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
 Inserts a new record of the given key or replaces the existing one in this hash storage, or so-called upsert. More...
 
template<typename KEY >
ErrorCode upsert_record (thread::Thread *context, KEY key, const void *payload, uint16_t payload_count)
 Overlord to receive key as a primitive type. More...
 
ErrorCode upsert_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, const void *payload, uint16_t payload_count, uint16_t physical_payload_hint)
 If you have already computed HashCombo, use this. More...
 
ErrorCode overwrite_record (thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_offset, uint16_t payload_count)
 Overwrites a part of one record of the given key in this hash storage. More...
 
template<typename KEY >
ErrorCode overwrite_record (thread::Thread *context, KEY key, const void *payload, uint16_t payload_offset, uint16_t payload_count)
 Overlord to receive key as a primitive type. More...
 
ErrorCode overwrite_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, const void *payload, uint16_t payload_offset, uint16_t payload_count)
 If you have already computed HashCombo, use this. More...
 
template<typename PAYLOAD >
ErrorCode overwrite_record_primitive (thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD payload, uint16_t payload_offset)
 Overwrites a part of one record of the given key in this storage as a primitive value. More...
 
template<typename KEY , typename PAYLOAD >
ErrorCode overwrite_record_primitive (thread::Thread *context, KEY key, PAYLOAD payload, uint16_t payload_offset)
 Overlord to receive key as a primitive type. More...
 
template<typename PAYLOAD >
ErrorCode overwrite_record_primitive (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, PAYLOAD payload, uint16_t payload_offset)
 If you have already computed HashCombo, use this. More...
 
template<typename PAYLOAD >
ErrorCode increment_record (thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD *value, uint16_t payload_offset)
 This one further optimizes overwrite methods for the frequent use case of incrementing some data in primitive type. More...
 
template<typename KEY , typename PAYLOAD >
ErrorCode increment_record (thread::Thread *context, KEY key, PAYLOAD *value, uint16_t payload_offset)
 Overlord to receive key as a primitive type. More...
 
template<typename PAYLOAD >
ErrorCode increment_record (thread::Thread *context, const void *key, uint16_t key_length, const HashCombo &combo, PAYLOAD *value, uint16_t payload_offset)
 If you have already computed HashCombo, use this. More...
 
- Public Member Functions inherited from foedus::storage::Storage< HashStorageControlBlock >
 Storage ()
 
 Storage (Engine *engine, HashStorageControlBlock *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< HashStorageControlBlock >
 Attachable ()
 
 Attachable (Engine *engine)
 
 Attachable (Engine *engine, HashStorageControlBlock *control_block)
 
 Attachable (HashStorageControlBlock *control_block)
 
 Attachable (const Attachable &other)
 
virtual ~Attachable ()
 
Attachableoperator= (const Attachable &other)
 
virtual void attach (HashStorageControlBlock *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...
 
HashStorageControlBlock * get_control_block () const
 
Engineget_engine () const
 
void set_engine (Engine *engine)
 

Friends

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

Additional Inherited Members

- Protected Attributes inherited from foedus::Attachable< HashStorageControlBlock >
Engineengine_
 Most attachable object stores an engine pointer (local engine), so we define it here. More...
 
HashStorageControlBlock * 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::hash::HashStorage::HashStorage ( )

Definition at line 37 of file hash_storage.cpp.

37 : Storage<HashStorageControlBlock>() {}
foedus::storage::hash::HashStorage::HashStorage ( Engine engine,
HashStorageControlBlock control_block 
)

Definition at line 38 of file hash_storage.cpp.

References ASSERT_ND, foedus::storage::Storage< HashStorageControlBlock >::exists(), foedus::storage::Storage< HashStorageControlBlock >::get_type(), and foedus::storage::kHashStorage.

39  : Storage<HashStorageControlBlock>(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::hash::HashStorage::HashStorage ( Engine engine,
StorageControlBlock control_block 
)

Definition at line 42 of file hash_storage.cpp.

References ASSERT_ND, foedus::storage::Storage< HashStorageControlBlock >::exists(), foedus::storage::Storage< HashStorageControlBlock >::get_type(), and foedus::storage::kHashStorage.

43  : Storage<HashStorageControlBlock>(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::hash::HashStorage::HashStorage ( Engine engine,
StorageId  id 
)

Definition at line 46 of file hash_storage.cpp.

47  : Storage<HashStorageControlBlock>(engine, id) {}
foedus::storage::hash::HashStorage::HashStorage ( Engine engine,
const StorageName name 
)

Definition at line 48 of file hash_storage.cpp.

49  : Storage<HashStorageControlBlock>(engine, name) {}
foedus::storage::hash::HashStorage::HashStorage ( const HashStorage other)

Definition at line 50 of file hash_storage.cpp.

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

Member Function Documentation

HashCombo foedus::storage::hash::HashStorage::combo ( const void *  key,
uint16_t  key_length 
) const
inline

Prepares a set of information that are used in many places, extracted from the given key.

Definition at line 120 of file hash_storage.hpp.

References get_hash_metadata().

Referenced by delete_record(), get_record(), get_record_part(), get_record_primitive(), increment_record(), insert_record(), overwrite_record(), overwrite_record_primitive(), and upsert_record().

120  {
121  return HashCombo(key, key_length, *get_hash_metadata());
122  }
const HashMetadata * get_hash_metadata() const

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
HashCombo foedus::storage::hash::HashStorage::combo ( KEY *  key) const
inline

Overlord to receive key as a primitive type.

Attention
Here we receive a pointer because HashCombo remembers the point to key. In other words, the caller must make sure the primitive variable doesn't get out of scope while it might reuse the returned HashCombo.

Definition at line 130 of file hash_storage.hpp.

References get_hash_metadata().

130  {
131  return HashCombo(key, sizeof(KEY), *get_hash_metadata());
132  }
const HashMetadata * get_hash_metadata() const

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::create ( const Metadata metadata)

Definition at line 65 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::create().

65  {
66  HashStoragePimpl pimpl(this);
67  return pimpl.create(static_cast<const HashMetadata&>(metadata));
68 }

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::debugout_single_thread ( Engine engine,
bool  volatile_only = false,
bool  intermediate_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 hash storage in details.

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

Definition at line 279 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::debugout_single_thread().

283  {
284  HashStoragePimpl pimpl(this);
285  return pimpl.debugout_single_thread(engine, volatile_only, intermediate_only, max_pages);
286 }

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::delete_record ( thread::Thread context,
const void *  key,
uint16_t  key_length 
)
inline

Deletes a record of the given key from this hash storage.

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[in]key_lengthByte size of key.

When the key does not exist, it returns kErrorCodeStrKeyNotFound and we add an appropriate page-version set because it is part of a transactional information.

Definition at line 375 of file hash_storage.hpp.

References combo().

Referenced by delete_record().

375  {
376  HashCombo c(combo(key, key_length));
377  return delete_record(context, key, key_length, c);
378  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode delete_record(thread::Thread *context, const void *key, uint16_t key_length)
Deletes a record of the given key from this hash storage.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::delete_record ( thread::Thread context,
KEY  key 
)
inline

Overlord to receive key as a primitive type.

Definition at line 382 of file hash_storage.hpp.

References delete_record().

382  {
383  HashCombo c(combo<KEY>(&key));
384  return delete_record(context, &key, sizeof(key), c);
385  }
ErrorCode delete_record(thread::Thread *context, const void *key, uint16_t key_length)
Deletes a record of the given key from this hash storage.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::delete_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo 
)

If you have already computed HashCombo, use this.

Definition at line 179 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::delete_record().

183  {
184  HashStoragePimpl pimpl(this);
185  return pimpl.delete_record(
186  context,
187  key,
188  key_length,
189  combo);
190 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::drop ( )

Definition at line 73 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::drop().

73  {
74  HashStoragePimpl pimpl(this);
75  return pimpl.drop();
76 }

Here is the call graph for this function:

uint8_t foedus::storage::hash::HashStorage::get_bin_bits ( ) const
Returns
the number of bits to represent hash bins in this storage

Definition at line 61 of file hash_storage.cpp.

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

Referenced by foedus::storage::hash::HashPartitioner::design_partition().

61 { return control_block_->meta_.bin_bits_; }
HashStorageControlBlock * 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:

HashBin foedus::storage::hash::HashStorage::get_bin_count ( ) const
Returns
the total number of hash bins in this storage

Definition at line 60 of file hash_storage.cpp.

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

Referenced by foedus::storage::hash::HashPartitioner::design_partition(), foedus::storage::hash::HashComposeContext::execute(), and foedus::storage::hash::HashPartitioner::partition_batch().

60 { return control_block_->bin_count_; }
HashStorageControlBlock * 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:

uint8_t foedus::storage::hash::HashStorage::get_bin_shifts ( ) const
Returns
the number of bit shifts to extract bins from hashes for this storage

Definition at line 62 of file hash_storage.cpp.

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

Referenced by foedus::storage::hash::HashPartitioner::design_partition(), foedus::storage::hash::hash_data_volatile_page_init(), and foedus::storage::hash::HashPartitioner::partition_batch().

62 { return control_block_->meta_.get_bin_shifts(); }
HashStorageControlBlock * 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:

const HashMetadata * foedus::storage::hash::HashStorage::get_hash_metadata ( ) const

Definition at line 78 of file hash_storage.cpp.

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

Referenced by combo(), foedus::storage::hash::HashComposer::drop_root_volatile(), and foedus::storage::hash::HashComposer::drop_volatiles().

78 { return &control_block_->meta_; }
HashStorageControlBlock * 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:

uint8_t foedus::storage::hash::HashStorage::get_levels ( ) const
Returns
levels of intermediate pages in this storage

Definition at line 59 of file hash_storage.cpp.

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

Referenced by foedus::storage::hash::HashComposer::construct_root(), foedus::storage::hash::HashPartitioner::design_partition(), foedus::storage::hash::HashPartitioner::design_partition_task(), foedus::storage::hash::HashComposer::drop_root_volatile(), and foedus::storage::hash::HashComposer::drop_volatiles().

59 { return control_block_->levels_; }
HashStorageControlBlock * 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::hash::HashStorage::get_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
void *  payload,
uint16_t *  payload_capacity,
bool  read_only 
)
inline

Retrieves an entire payload of the given key in this hash storage.

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[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 add an appropriate page-version set because it is part of a transactional information.

Definition at line 154 of file hash_storage.hpp.

References combo().

Referenced by get_record().

160  {
161  HashCombo c(combo(key, key_length));
162  return get_record(context, key, key_length, c, payload, payload_capacity, read_only);
163  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode get_record(thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t *payload_capacity, bool read_only)
Retrieves an entire payload of the given key in this hash storage.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::get_record ( thread::Thread context,
KEY  key,
void *  payload,
uint16_t *  payload_capacity,
bool  read_only 
)
inline

Overlord to receive key as a primitive type.

Definition at line 167 of file hash_storage.hpp.

References get_record().

172  {
173  HashCombo c(combo<KEY>(&key));
174  return get_record(context, &key, sizeof(key), c, payload, payload_capacity, read_only);
175  }
ErrorCode get_record(thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t *payload_capacity, bool read_only)
Retrieves an entire payload of the given key in this hash storage.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::get_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
void *  payload,
uint16_t *  payload_capacity,
bool  read_only 
)

If you have already computed HashCombo, use this.

Definition at line 80 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::get_record().

87  {
88  HashStoragePimpl pimpl(this);
89  return pimpl.get_record(
90  context,
91  key,
92  key_length,
93  combo,
94  payload,
95  payload_capacity,
96  read_only);
97 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::get_record_part ( thread::Thread context,
const void *  key,
uint16_t  key_length,
void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count,
bool  read_only 
)
inline

Retrieves a part of the given key in this hash storage.

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[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 200 of file hash_storage.hpp.

References combo().

Referenced by get_record_part().

207  {
208  HashCombo c(combo(key, key_length));
209  return get_record_part(
210  context,
211  key,
212  key_length,
213  c,
214  payload,
215  payload_offset,
216  payload_count,
217  read_only);
218  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode get_record_part(thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t payload_offset, uint16_t payload_count, bool read_only)
Retrieves a part of the given key in this hash storage.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::get_record_part ( thread::Thread context,
KEY  key,
void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count,
bool  read_only 
)
inline

Overlord to receive key as a primitive type.

Definition at line 222 of file hash_storage.hpp.

References get_record_part().

228  {
229  HashCombo c(combo<KEY>(&key));
230  return get_record_part(
231  context,
232  &key,
233  sizeof(key),
234  c,
235  payload,
236  payload_offset,
237  payload_count,
238  read_only);
239  }
ErrorCode get_record_part(thread::Thread *context, const void *key, uint16_t key_length, void *payload, uint16_t payload_offset, uint16_t payload_count, bool read_only)
Retrieves a part of the given key in this hash storage.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::get_record_part ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count,
bool  read_only 
)

If you have already computed HashCombo, use this.

Definition at line 99 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::get_record_part().

107  {
108  HashStoragePimpl pimpl(this);
109  return pimpl.get_record_part(
110  context,
111  key,
112  key_length,
113  combo,
114  payload,
115  payload_offset,
116  payload_count,
117  read_only);
118 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::get_record_primitive ( thread::Thread context,
const void *  key,
uint16_t  key_length,
PAYLOAD *  payload,
uint16_t  payload_offset,
bool  read_only 
)
inline

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

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[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 266 of file hash_storage.hpp.

References combo().

272  {
273  HashCombo c(combo(key, key_length));
274  return get_record_primitive<PAYLOAD>(
275  context,
276  key,
277  key_length,
278  c,
279  payload,
280  payload_offset,
281  read_only);
282  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

template<typename KEY , typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::get_record_primitive ( thread::Thread context,
KEY  key,
PAYLOAD *  payload,
uint16_t  payload_offset,
bool  read_only 
)
inline

Overlord to receive key as a primitive type.

Definition at line 286 of file hash_storage.hpp.

291  {
292  HashCombo c(combo<KEY>(&key));
293  return get_record_primitive<PAYLOAD>(
294  context,
295  &key,
296  sizeof(key),
297  c,
298  payload,
299  payload_offset,
300  read_only);
301  }
template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::get_record_primitive ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
PAYLOAD *  payload,
uint16_t  payload_offset,
bool  read_only 
)

If you have already computed HashCombo, use this.

Definition at line 121 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::get_record_primitive().

128  {
129  HashStoragePimpl pimpl(this);
130  return pimpl.get_record_primitive(
131  context,
132  key,
133  key_length,
134  combo,
135  payload,
136  payload_offset,
137  read_only);
138 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

uint16_t foedus::storage::hash::HashStorage::get_root_children ( ) const
Returns
the number of child pointers in the root page for this storage

Definition at line 63 of file hash_storage.cpp.

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

Referenced by foedus::storage::hash::HashComposer::drop_volatiles().

63 { return control_block_->get_root_children(); }
HashStorageControlBlock * 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:

ErrorStack foedus::storage::hash::HashStorage::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 273 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::hcc_reset_all_temperature_stat().

273  {
274  HashStoragePimpl pimpl(this);
275  return pimpl.hcc_reset_all_temperature_stat();
276 }

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::increment_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
PAYLOAD *  value,
uint16_t  payload_offset 
)
inline

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.
[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 557 of file hash_storage.hpp.

References combo().

Referenced by increment_record().

562  {
563  HashCombo c(combo(key, key_length));
564  return increment_record(context, key, key_length, c, value, payload_offset);
565  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode increment_record(thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD *value, uint16_t payload_offset)
This one further optimizes overwrite methods for the frequent use case of incrementing some data in p...

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY , typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::increment_record ( thread::Thread context,
KEY  key,
PAYLOAD *  value,
uint16_t  payload_offset 
)
inline

Overlord to receive key as a primitive type.

Definition at line 569 of file hash_storage.hpp.

References increment_record().

573  {
574  HashCombo c(combo<KEY>(&key));
575  return increment_record(context, &key, sizeof(key), c, value, payload_offset);
576  }
ErrorCode increment_record(thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD *value, uint16_t payload_offset)
This one further optimizes overwrite methods for the frequent use case of incrementing some data in p...

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::increment_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
PAYLOAD *  value,
uint16_t  payload_offset 
)

If you have already computed HashCombo, use this.

Definition at line 230 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::increment_record().

236  {
237  HashStoragePimpl pimpl(this);
238  return pimpl.increment_record(
239  context,
240  key,
241  key_length,
242  combo,
243  value,
244  payload_offset);
245 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::insert_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const void *  payload,
uint16_t  payload_count 
)
inline

Inserts a new record of the given key in this hash storage.

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[in]key_lengthByte size of key.
[in]payloadValue to insert.
[in]payload_countLength of payload.

If the key already exists, it returns kErrorCodeStrKeyAlreadyExists and we add an appropriate page-version set because it is part of a transactional information.

Definition at line 327 of file hash_storage.hpp.

References combo().

Referenced by insert_record().

332  {
333  HashCombo c(combo(key, key_length));
334  return insert_record(context, key, key_length, c, payload, payload_count, payload_count);
335  }
ErrorCode insert_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
Inserts a new record of the given key in this hash storage.
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::insert_record ( thread::Thread context,
KEY  key,
const void *  payload,
uint16_t  payload_count 
)
inline

Overlord to receive key as a primitive type.

Definition at line 339 of file hash_storage.hpp.

References insert_record().

343  {
344  HashCombo c(combo<KEY>(&key));
345  return insert_record(context, &key, sizeof(key), c, payload, payload_count, payload_count);
346  }
ErrorCode insert_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
Inserts a new record of the given key in this hash storage.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::insert_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
const void *  payload,
uint16_t  payload_count,
uint16_t  physical_payload_hint 
)

If you have already computed HashCombo, use this.

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 140 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::insert_record().

147  {
148  HashStoragePimpl pimpl(this);
149  return pimpl.insert_record(
150  context,
151  key,
152  key_length,
153  combo,
154  payload,
155  payload_count,
156  physical_payload_hint);
157 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::load ( const StorageControlBlock snapshot_block)

Definition at line 69 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::load().

69  {
70  HashStoragePimpl pimpl(this);
71  return pimpl.load(snapshot_block);
72 }

Here is the call graph for this function:

HashStorage & foedus::storage::hash::HashStorage::operator= ( const HashStorage other)

Definition at line 53 of file hash_storage.cpp.

References foedus::Attachable< HashStorageControlBlock >::control_block_, foedus::Attachable< CONTROL_BLOCK >::control_block_, foedus::Attachable< HashStorageControlBlock >::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
HashStorageControlBlock * 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::hash::HashStorage::overwrite_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count 
)
inline

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

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[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 others, when the key does not exist, it returns kErrorCodeStrKeyNotFound and we add an appropriate page-version set because it is part of a transactional information.

Definition at line 459 of file hash_storage.hpp.

References combo().

Referenced by overwrite_record().

465  {
466  HashCombo c(combo(key, key_length));
467  return overwrite_record(
468  context,
469  key,
470  key_length,
471  c,
472  payload,
473  payload_offset,
474  payload_count);
475  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode overwrite_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_offset, uint16_t payload_count)
Overwrites a part of one record of the given key in this hash storage.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::overwrite_record ( thread::Thread context,
KEY  key,
const void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count 
)
inline

Overlord to receive key as a primitive type.

Definition at line 479 of file hash_storage.hpp.

References overwrite_record().

484  {
485  HashCombo c(combo<KEY>(&key));
486  return overwrite_record(context, &key, sizeof(key), c, payload, payload_offset, payload_count);
487  }
ErrorCode overwrite_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_offset, uint16_t payload_count)
Overwrites a part of one record of the given key in this hash storage.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::overwrite_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
const void *  payload,
uint16_t  payload_offset,
uint16_t  payload_count 
)

If you have already computed HashCombo, use this.

Definition at line 192 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::overwrite_record().

199  {
200  HashStoragePimpl pimpl(this);
201  return pimpl.overwrite_record(
202  context,
203  key,
204  key_length,
205  combo,
206  payload,
207  payload_offset,
208  payload_count);
209 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::overwrite_record_primitive ( thread::Thread context,
const void *  key,
uint16_t  key_length,
PAYLOAD  payload,
uint16_t  payload_offset 
)
inline

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

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[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 511 of file hash_storage.hpp.

References combo().

Referenced by overwrite_record_primitive().

516  {
517  HashCombo c(combo(key, key_length));
518  return overwrite_record_primitive(context, key, key_length, c, payload, payload_offset);
519  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode overwrite_record_primitive(thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD payload, uint16_t payload_offset)
Overwrites a part of one record of the given key in this storage as a primitive value.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY , typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::overwrite_record_primitive ( thread::Thread context,
KEY  key,
PAYLOAD  payload,
uint16_t  payload_offset 
)
inline

Overlord to receive key as a primitive type.

Definition at line 523 of file hash_storage.hpp.

References overwrite_record_primitive().

527  {
528  HashCombo c(combo<KEY>(&key));
529  return overwrite_record_primitive(context, &key, sizeof(key), c, payload, payload_offset);
530  }
ErrorCode overwrite_record_primitive(thread::Thread *context, const void *key, uint16_t key_length, PAYLOAD payload, uint16_t payload_offset)
Overwrites a part of one record of the given key in this storage as a primitive value.

Here is the call graph for this function:

template<typename PAYLOAD >
ErrorCode foedus::storage::hash::HashStorage::overwrite_record_primitive ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
PAYLOAD  payload,
uint16_t  payload_offset 
)

If you have already computed HashCombo, use this.

Definition at line 212 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::overwrite_record_primitive().

218  {
219  HashStoragePimpl pimpl(this);
220  return pimpl.overwrite_record_primitive(
221  context,
222  key,
223  key_length,
224  combo,
225  payload,
226  payload_offset);
227 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

xct::TrackMovedRecordResult foedus::storage::hash::HashStorage::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 Hash storage also uses the moved bit for record expansion. The basic idea and protocol are same as the masstree package, but it's easier here!

When we migrate records for expansion, we only move it to a later position, either a larger slot index in the same page or somewhere in next-page linked-list. Further, we keep the full key in the original place. So, tracking the moved record is fairly simple and efficient. Also, no chance of cannot-track case.

Definition at line 256 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::track_moved_record().

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

258  {
259  HashStoragePimpl pimpl(this);
260  return pimpl.track_moved_record(old_address, write_set);
261 }

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::storage::hash::HashStorage::upsert_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const void *  payload,
uint16_t  payload_count 
)
inline

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

Parameters
[in]contextThread context
[in]keyArbitrary length of key.
[in]key_lengthByte size of key.
[in]payloadValue to insert.
[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 412 of file hash_storage.hpp.

References combo().

Referenced by upsert_record().

417  {
418  HashCombo c(combo(key, key_length));
419  return upsert_record(context, key, key_length, c, payload, payload_count, payload_count);
420  }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...
ErrorCode upsert_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
Inserts a new record of the given key or replaces the existing one in this hash storage, or so-called upsert.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename KEY >
ErrorCode foedus::storage::hash::HashStorage::upsert_record ( thread::Thread context,
KEY  key,
const void *  payload,
uint16_t  payload_count 
)
inline

Overlord to receive key as a primitive type.

Definition at line 424 of file hash_storage.hpp.

References upsert_record().

428  {
429  HashCombo c(combo<KEY>(&key));
430  return upsert_record(context, &key, sizeof(key), c, payload, payload_count, payload_count);
431  }
ErrorCode upsert_record(thread::Thread *context, const void *key, uint16_t key_length, const void *payload, uint16_t payload_count)
Inserts a new record of the given key or replaces the existing one in this hash storage, or so-called upsert.

Here is the call graph for this function:

ErrorCode foedus::storage::hash::HashStorage::upsert_record ( thread::Thread context,
const void *  key,
uint16_t  key_length,
const HashCombo combo,
const void *  payload,
uint16_t  payload_count,
uint16_t  physical_payload_hint 
)

If you have already computed HashCombo, use this.

Definition at line 159 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::upsert_record().

166  {
167  HashStoragePimpl pimpl(this);
168  return pimpl.upsert_record(
169  context,
170  key,
171  key_length,
172  combo,
173  payload,
174  payload_count,
175  physical_payload_hint);
176 }
HashCombo combo(const void *key, uint16_t key_length) const
Prepares a set of information that are used in many places, extracted from the given key...

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::verify_single_thread ( Engine engine)

Definition at line 263 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::verify_single_thread().

263  {
264  HashStoragePimpl pimpl(this);
265  return pimpl.verify_single_thread(engine);
266 }

Here is the call graph for this function:

ErrorStack foedus::storage::hash::HashStorage::verify_single_thread ( thread::Thread context)

Definition at line 268 of file hash_storage.cpp.

References foedus::storage::hash::HashStoragePimpl::verify_single_thread().

268  {
269  HashStoragePimpl pimpl(this);
270  return pimpl.verify_single_thread(context);
271 }

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 247 of file hash_storage.cpp.

247  {
248  o << "<HashStorage>"
249  << "<id>" << v.get_id() << "</id>"
250  << "<name>" << v.get_name() << "</name>"
251  << "<bin_bits>" << static_cast<int>(v.control_block_->meta_.bin_bits_) << "</bin_bits>"
252  << "</HashStorage>";
253  return o;
254 }

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