Key and value record structure in the file skip database.
More...
#include <tkrzw_dbm_skip_impl.h>
|
| SkipRecord (File *file, int32_t offset_width, int32_t step_unit, int32_t max_level) |
| Constructor. More...
|
|
| ~SkipRecord () |
| Destructor. More...
|
|
SkipRecord & | operator= (SkipRecord &&rhs) |
| Assigns the internal state from another moved record object. More...
|
|
Status | ReadMetadataKey (int64_t offset, int64_t index) |
| Reads the metadata and the key. More...
|
|
Status | ReadBody () |
| Reads the body data and fill all the properties. More...
|
|
std::string_view | GetKey () const |
| Gets the key data. More...
|
|
std::string_view | GetValue () const |
| Gets the value data. More...
|
|
const std::vector< int64_t > & | GetStepOffsets () const |
| Gets the offsets of the records to skip to. More...
|
|
int32_t | GetLevel () const |
| Gets the level of the record. More...
|
|
int64_t | GetIndex () const |
| Gets the index of the record. More...
|
|
int64_t | GetOffset () const |
| Gets the offset of the record. More...
|
|
int32_t | GetWholeSize () const |
| Gets the whole size of the record. More...
|
|
void | SetData (int64_t index, const char *key_ptr, int32_t key_size, const char *value_ptr, int32_t value_size) |
| Sets the actual data of the record. More...
|
|
Status | Write () |
| Writes the record in the file. More...
|
|
Status | UpdatePastRecords (int64_t index, int64_t offset, std::vector< int64_t > *past_offsets) const |
| Updates past records which refer to this record. More...
|
|
Status | Search (int64_t record_base, SkipRecordCache *cache, std::string_view key, bool upper) |
| Searches records for the one with the same key. More...
|
|
Status | SearchByIndex (int64_t record_base, SkipRecordCache *cache, int64_t index) |
| Searches records for the one with the same index. More...
|
|
File * | GetFile () const |
| Gets the file object. More...
|
|
char * | Serialize () const |
| Searializes the internal data. More...
|
|
void | Deserialize (int64_t index, const char *serialized) |
| Deserializes a string and prepare the internal data. More...
|
|
Key and value record structure in the file skip database.
◆ SkipRecord()
tkrzw::SkipRecord::SkipRecord |
( |
File * |
file, |
|
|
int32_t |
offset_width, |
|
|
int32_t |
step_unit, |
|
|
int32_t |
max_level |
|
) |
| |
Constructor.
- Parameters
-
file | The pointer to the file object. |
offset_width | The width of the offset data. |
step_unit | The unit of stepping. |
max_level | The maximum level of the skip list. |
◆ ~SkipRecord()
tkrzw::SkipRecord::~SkipRecord |
( |
| ) |
|
◆ operator=()
Assigns the internal state from another moved record object.
- Parameters
-
rhs | The other record object. |
◆ ReadMetadataKey()
Status tkrzw::SkipRecord::ReadMetadataKey |
( |
int64_t |
offset, |
|
|
int64_t |
index |
|
) |
| |
Reads the metadata and the key.
- Parameters
-
offset | The offset of the record. |
index | The index of the record. |
- Returns
- The result status.
If successful, the key data is always read. However the value data is not always read. To read it, call ReadBody.
◆ ReadBody()
Status tkrzw::SkipRecord::ReadBody |
( |
| ) |
|
Reads the body data and fill all the properties.
- Returns
- The result status.
◆ GetKey()
std::string_view tkrzw::SkipRecord::GetKey |
( |
| ) |
const |
Gets the key data.
- Returns
- The key data.
◆ GetValue()
std::string_view tkrzw::SkipRecord::GetValue |
( |
| ) |
const |
Gets the value data.
- Returns
- The value data. The data might be nullptr if the body hasn't been read.
◆ GetStepOffsets()
const std::vector<int64_t>& tkrzw::SkipRecord::GetStepOffsets |
( |
| ) |
const |
Gets the offsets of the records to skip to.
- Returns
- The offsets of the records to skip to.
◆ GetLevel()
int32_t tkrzw::SkipRecord::GetLevel |
( |
| ) |
const |
Gets the level of the record.
- Returns
- The level of the record.
◆ GetIndex()
int64_t tkrzw::SkipRecord::GetIndex |
( |
| ) |
const |
Gets the index of the record.
- Returns
- The index of the record.
◆ GetOffset()
int64_t tkrzw::SkipRecord::GetOffset |
( |
| ) |
const |
Gets the offset of the record.
- Returns
- The offset of the record.
◆ GetWholeSize()
int32_t tkrzw::SkipRecord::GetWholeSize |
( |
| ) |
const |
Gets the whole size of the record.
- Returns
- The whole size of the record.
◆ SetData()
void tkrzw::SkipRecord::SetData |
( |
int64_t |
index, |
|
|
const char * |
key_ptr, |
|
|
int32_t |
key_size, |
|
|
const char * |
value_ptr, |
|
|
int32_t |
value_size |
|
) |
| |
Sets the actual data of the record.
- Parameters
-
index | The index of the record. |
key_ptr | The pointer to a key buffer. |
key_size | The size of the key buffer. |
value_ptr | The pointer to a value buffer. |
value_size | The size of the value buffer. |
◆ Write()
Status tkrzw::SkipRecord::Write |
( |
| ) |
|
Writes the record in the file.
- Returns
- The result status.
◆ UpdatePastRecords()
Status tkrzw::SkipRecord::UpdatePastRecords |
( |
int64_t |
index, |
|
|
int64_t |
offset, |
|
|
std::vector< int64_t > * |
past_offsets |
|
) |
| const |
Updates past records which refer to this record.
- Parameters
-
index | The index of the record. |
offset | The offset of the record. |
past_offsets | The pointer to a vector of offsets of the past records, whose size must be the same as the maximum level. |
- Returns
- The result status.
◆ Search()
Status tkrzw::SkipRecord::Search |
( |
int64_t |
record_base, |
|
|
SkipRecordCache * |
cache, |
|
|
std::string_view |
key, |
|
|
bool |
upper |
|
) |
| |
Searches records for the one with the same key.
- Parameters
-
record_base | The record base offset. |
cache | The cache for skip records. |
key | The key to match with. |
upper | If true, the first upper record is retrieved if there's no record matching. |
- Returns
- The result status.
◆ SearchByIndex()
Searches records for the one with the same index.
- Parameters
-
record_base | The record base offset. |
cache | The cache for skip records. |
index | The index of the target record. |
- Returns
- The result status.
◆ GetFile()
File* tkrzw::SkipRecord::GetFile |
( |
| ) |
const |
Gets the file object.
- Returns
- The pointer to the file object.
◆ Serialize()
char* tkrzw::SkipRecord::Serialize |
( |
| ) |
const |
Searializes the internal data.
- Returns
- The result string. The caller has the ownership.
◆ Deserialize()
void tkrzw::SkipRecord::Deserialize |
( |
int64_t |
index, |
|
|
const char * |
serialized |
|
) |
| |
Deserializes a string and prepare the internal data.
- Parameters
-
index | The index of the serialized record. |
serialized | The serialized string. Ownership is not taken. |