WiscKey Database
Embedded LSM-Tree Key-Value Database
Loading...
Searching...
No Matches
memtable.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_MEMTABLE_H
18#define WISCKEY_MEMTABLE_H
19
20#include <stdint.h>
21#include <stdlib.h>
22
23#define MEMTABLE_SIZE 1024
24
32
40{
41 char* key;
42 size_t key_len;
43 int64_t value_loc;
44};
45
55{
56 struct MemTableRecord*
58 size_t size;
59};
60
68struct MemTable*
70
84struct MemTableRecord*
85MemTable_get(const struct MemTable* memtable, const char* key, size_t key_len);
86
97void
98MemTable_set(struct MemTable* memtable,
99 const char* key,
100 size_t key_len,
101 int64_t value_loc);
102
115void
116MemTable_delete(struct MemTable* memtable, const char* key, size_t key_len);
117
126void
127MemTable_free(struct MemTable* memtable);
128
129#endif /* WISCKEY_MEMTABLE_H */
struct MemTable * MemTable_new()
Creates a new empty MemTable.
Definition memtable.c:39
#define MEMTABLE_SIZE
Max number of MemTableRecords in a MemTable.
Definition memtable.h:23
void MemTable_set(struct MemTable *memtable, const char *key, size_t key_len, int64_t value_loc)
Sets a key-value pair in a MemTable.
Definition memtable.c:118
void MemTable_delete(struct MemTable *memtable, const char *key, size_t key_len)
Deletes a record from a MemTable.
Definition memtable.c:145
struct MemTableRecord * MemTable_get(const struct MemTable *memtable, const char *key, size_t key_len)
Gets a MemTableRecord from a MemTable by key.
Definition memtable.c:107
void MemTable_free(struct MemTable *memtable)
Frees a MemTable and its records.
Definition memtable.c:170
Single Record in the MemTable.
Definition memtable.h:40
char * key
The key of the record.
Definition memtable.h:41
int64_t value_loc
The location of the value in the ValueLog.
Definition memtable.h:43
size_t key_len
The length of the key.
Definition memtable.h:42
MemTable of the Database.
Definition memtable.h:55
size_t size
The number of records filled in records.
Definition memtable.h:58
struct MemTableRecord * records[MEMTABLE_SIZE]
Array of records sorted by key.
Definition memtable.h:56