|
WiscKey Database
Embedded LSM-Tree Key-Value Database
|
Log file of the key-value pairs. More...
#include <stdio.h>Go to the source code of this file.
Data Structures | |
| struct | ValueLog |
| Value Log of the Database. More... | |
Functions | |
| struct ValueLog * | ValueLog_new (const char *path, size_t head, size_t tail) |
| Creates a new ValueLog or loads an existing one from disk. | |
| int | ValueLog_append (struct ValueLog *log, size_t *pos, const char *key, size_t key_len, const char *value, size_t value_len) |
| Appends a new key-value pair to the ValueLog. | |
| int | ValueLog_get (const struct ValueLog *log, char **value, size_t *value_len, size_t value_loc) |
| Fetches a value from the ValueLog at a given position. | |
| int | ValueLog_sync (const struct ValueLog *log) |
| Syncs the ValueLog to the disk. | |
| void | ValueLog_free (struct ValueLog *log) |
| Frees the ValueLog. | |
Log file of the key-value pairs.
| int ValueLog_append | ( | struct ValueLog * | log, |
| size_t * | pos, | ||
| const char * | key, | ||
| size_t | key_len, | ||
| const char * | value, | ||
| size_t | value_len ) |
Appends a new key-value pair to the ValueLog.
In the event that the write was unsuccessful, the ValueLog won't shift the head forward. Therefore, writes can be retried without the risk of polluting the ValueLog or corrupting past entries.
| log | The ValueLog to write to. |
| pos | A pointer that is assigned to the location on the where the key-value pair was written to. |
| key | The key being written. |
| key_len | The length of the key. |
| value | The value that is being written. |
| value_len | The length of the value. |
| void ValueLog_free | ( | struct ValueLog * | log | ) |
| int ValueLog_get | ( | const struct ValueLog * | log, |
| char ** | value, | ||
| size_t * | value_len, | ||
| size_t | value_loc ) |
Fetches a value from the ValueLog at a given position.
Note: The value pointer will allocate memory to hold the value that is being requested. The caller is responsible for freeing the memory.
| log | The ValueLog to read from. |
| value | A double-pointer for the value. This pointer will set with a newly allocated block of memory with the value that the caller can access. |
| value_len | A pointer that is assigned to the the length of the value pointer. |
| value_loc | The location on the ValueLog that this value resides in. |
| struct ValueLog * ValueLog_new | ( | const char * | path, |
| size_t | head, | ||
| size_t | tail ) |
Creates a new ValueLog or loads an existing one from disk.
If the ValueLog file already exists, this function will only open the file without scanning it. This function doesn't check if file has been corrupted.
Note: Free this ValueLog with ValueLog_free.
| path | Path to the ValueLog. The path must be be null-terminated. |
| head | The head of the ValueLog. Set to 0 for a new ValueLog. |
| tail | The tail of the ValueLog. Set to 0 for a new ValueLog. |
| int ValueLog_sync | ( | const struct ValueLog * | log | ) |
Syncs the ValueLog to the disk.
This function forcefully flushes the changes to the ValueLog to disk. Use this function sparingly as is will heavily reduce the write throughput of the ValueLog.
| log | The ValueLog to flush to disk. |