WiscKey Database
Embedded LSM-Tree Key-Value Database
Loading...
Searching...
No Matches
value_log.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Adam Bishop Comer
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef WISCKEY_VALUE_LOG_H
18#define WISCKEY_VALUE_LOG_H
19
20#include <stdio.h>
21
29
44{
45 FILE* file;
46 size_t head;
48 size_t tail;
50};
51
65struct ValueLog*
66ValueLog_new(const char* path, size_t head, size_t tail);
67
85int
86ValueLog_append(struct ValueLog* log,
87 size_t* pos,
88 const char* key,
89 size_t key_len,
90 const char* value,
91 size_t value_len);
92
108int
109ValueLog_get(const struct ValueLog* log,
110 char** value,
111 size_t* value_len,
112 size_t value_loc);
113
125int
126ValueLog_sync(const struct ValueLog* log);
127
136void
137ValueLog_free(struct ValueLog* log);
138
139#endif /* WISCKEY_VALUE_LOG_H */
Value Log of the Database.
Definition value_log.h:44
size_t tail
Definition value_log.h:48
FILE * file
The file that the values are written to.
Definition value_log.h:45
size_t head
Definition value_log.h:46
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.
Definition value_log.c:48
int ValueLog_sync(const struct ValueLog *log)
Syncs the ValueLog to the disk.
Definition value_log.c:135
struct ValueLog * ValueLog_new(const char *path, size_t head, size_t tail)
Creates a new ValueLog or loads an existing one from disk.
Definition value_log.c:25
void ValueLog_free(struct ValueLog *log)
Frees the ValueLog.
Definition value_log.c:152
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.
Definition value_log.c:92