YACDB
Yet Another C(rappy) Database
cursor.h
Go to the documentation of this file.
1
8#pragma once
9
10#include "../../diskio/include/diskio.h"
11#include "../../diskio/include/db_structs.h"
12
18typedef struct
19{
24
30 struct node *node;
31
35 unsigned short cell;
36} Cursor;
37
42int insert(Page root, struct key_value *kv);
43
47Cursor *find_leaf(Page root, Key key);
48
49int cursor_next(Cursor *cursor);
50
52
53void step_in(Cursor *cursor);
54
55struct key_value *create_kv(Key key, void *value, size_t size);
56
57void insert_in_arr_Page(Page pages[], size_t size, Page val, size_t offset);
58
59void insert_in_arr_kv(struct key_value *key_vals[], size_t size, struct key_value *val, size_t offset);
60
61void free_cursor(Cursor *cursor);
Cursor * find_leaf(Page root, Key key)
find the correct leaf node for a given key
Definition: cursor.c:56
int insert(Page root, struct key_value *kv)
Inserts a key value pair inside the tree. The key value will be freed.
Definition: cursor.c:417
Cursor * create_at_start(Page root)
Create a cursor object on the leftmost leaf.
Definition: cursor.c:6
void insert_in_arr_kv(struct key_value *key_vals[], size_t size, struct key_value *val, size_t offset)
Inserts the value into the array at a given index.
Definition: cursor.c:123
size_t Page
A address to a page.
Definition: db_structs.h:18
unsigned long Key
A key to a record.
Definition: diskio.h:28
Definition: cursor.h:19
Page page
The page the cursor is on.
Definition: cursor.h:23
unsigned short cell
The current cell the cursor is on.
Definition: cursor.h:35
struct node * node
The node associated with the page that the cursor is on.
Definition: cursor.h:30
Definition: diskio.h:37
The basic structure stored in memory.
Definition: diskio.h:51