WiscKey Database
Embedded LSM-Tree Key-Value Database
Loading...
Searching...
No Matches
wal.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_WAL_H
18#define WISCKEY_WAL_H
19
20#include <stdint.h>
21#include <stdio.h>
22
23#include "memtable.h"
24
32
40struct WAL
41{
42 FILE* file;
43 char* path;
44};
45
54struct WAL*
55WAL_new(char* path);
56
68int
69WAL_load_memtable(struct WAL* wal, struct MemTable* memtable);
70
86int
87WAL_append(struct WAL* wal, const char* key, size_t key_len, int64_t value_loc);
88
99int
100WAL_sync(const struct WAL* wal);
101
110void
111WAL_free(struct WAL* wal);
112
113#endif /* WISCKEY_WAL_H */
In-memory table of the records that have been modified most recently.
MemTable of the Database.
Definition memtable.h:55
Write-Ahead Log(WAL) of the Database.
Definition wal.h:41
char * path
The path of the WAL file.
Definition wal.h:43
FILE * file
The file that the WAL writes the keys to.
Definition wal.h:42
struct WAL * WAL_new(char *path)
Creates a new emtpy WAL.
Definition wal.c:26
int WAL_sync(const struct WAL *wal)
Syncs the WAl to the disk.
Definition wal.c:114
int WAL_append(struct WAL *wal, const char *key, size_t key_len, int64_t value_loc)
Appends a new MemTable operation to the WAL.
Definition wal.c:89
void WAL_free(struct WAL *wal)
Frees the WAL.
Definition wal.c:131
int WAL_load_memtable(struct WAL *wal, struct MemTable *memtable)
Replays the WAL from the start and recreates the MemTable.
Definition wal.c:42