Non-volatile storage of the keys in the Database.
More...
#include <stdio.h>
#include "memtable.h"
Go to the source code of this file.
|
|
#define | SSTABLE_MIN_SIZE 1024 |
| | Minimum number of records in a SSTable index array.
|
| |
|
#define | SSTABLE_KEY_NOT_FOUND (-2) |
| | Return value if the value is not found.
|
| |
Non-volatile storage of the keys in the Database.
- Author
- Adam Comer adamb.nosp@m.come.nosp@m.r@gma.nosp@m.il.c.nosp@m.om
- Date
- May 15, 2020
- Copyright
- Apache-2.0 License
◆ SSTable_free()
| void SSTable_free |
( |
struct SSTable * | table | ) |
|
Frees the SSTable.
Note: This function won't delete the file or the underlying data in the SSTable. This function only frees the memory allocated to a SSTable.
- Parameters
-
◆ SSTable_get_value_loc()
| int64_t SSTable_get_value_loc |
( |
struct SSTable * | table, |
|
|
char * | key, |
|
|
size_t | key_len ) |
Gets the location of a value on the ValueLog from a key.
This function uses the in-memory index to seek each record on disk. This function uses binary search for a runtime of O(log(n)) seeks.
- Parameters
-
| table | The SSTable to search. |
| key | The key to search with. |
| key_len | The length of the key. |
- Returns
- This function returns the position in the ValueLog if the key is found. -2 if the key is not in the SSTable. -1 if there is an error reading the record.
◆ SSTable_in_key_range()
| int SSTable_in_key_range |
( |
struct SSTable * | table, |
|
|
char * | key, |
|
|
size_t | key_len ) |
Checks if the given key could be in this SSTable.
This function runs in constant time without any operations on disk.
- Parameters
-
| table | The SSTable to search. |
| key | The key in question. |
| key_len | The length of the key. |
- Returns
- This function returns 1 if the key is in the range and 0 if it is not.
◆ SSTable_new()
| struct SSTable * SSTable_new |
( |
char * | path | ) |
|
Loads a SSTable at a path.
Note: This operation scans the entire SSTable to build the index.
- Parameters
-
| path | The Path of the SSTable on the filesystem. |
- Returns
- A pointer to a new SSTable.
◆ SSTable_new_from_memtable()
| struct SSTable * SSTable_new_from_memtable |
( |
char * | path, |
|
|
struct MemTable * | memtable ) |
Creates a new SSTable from a full MemTable.
This function will create a new SSTable at a path. If a file already exists at this path, then the file will be overwritten.
Note: The MemTable will not be freed after creating a new SSTable. The caller is responsible for freeing the MemTable.
- Parameters
-
- Returns
- A pointer to the newly created SSTable.
◆ SSTable_parse_level()
| unsigned long SSTable_parse_level |
( |
char * | filename | ) |
|
Parses the compaction level from a SSTable filename.
This function expects the filename in the format of ll-ll.sstable
- Parameters
-
| filename | The filename of the SSTable to parse. |
- Returns
- The compaction level of the SSTable.
◆ SSTable_parse_timestamp()
| unsigned long SSTable_parse_timestamp |
( |
char * | filename | ) |
|
Parses the creation timestamp in microseconds from a SSTable filename.
This function expects the filename in the format of ll-ll.sstable
- Parameters
-
| filename | The filename of the SSTable to parse. |
- Returns
- The timestamp of when the SSTable was created.