summaryrefslogtreecommitdiff
path: root/source/b_tree.h
diff options
context:
space:
mode:
authornasr <nsrddyn@gmail.com>2026-03-08 21:01:43 +0000
committernasr <nsrddyn@gmail.com>2026-03-08 21:01:43 +0000
commit71ced998122c357bc62e54d9bb4e124c88acf94b (patch)
tree746fca3d71a8640478ad6b6f4429a19f4dfbbda8 /source/b_tree.h
parentf8f24f8c67fe903e267ab29bb2fbb9d334a722de (diff)
refactor(main): worked on string handling in C and other stuff
Diffstat (limited to 'source/b_tree.h')
-rw-r--r--source/b_tree.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/b_tree.h b/source/b_tree.h
new file mode 100644
index 0000000..0fc4d3c
--- /dev/null
+++ b/source/b_tree.h
@@ -0,0 +1,44 @@
1#ifndef BTREE_H
2#define BTREE_H
3
4// maximum height of the tree the lower the lower the lower amount
5// of disk reads which translates into faster?
6#define B_TREE_ORDER 4
7
8typedef struct b_tree_node b_tree_node;
9struct b_tree_node
10{
11
12 // store the values
13 string8 keys[B_TREE_ORDER - 1];
14 csv_row *rows[B_TREE_ORDER - 1];
15
16 b_tree_node *parent;
17 // handle to store children faster than linked list
18 // because now we can iteratate over the nodes instead of having cache misses
19 // when jumping through linked nodes
20 b_tree_node *children[B_TREE_ORDER];
21
22 // NOTE(nasr): reference count ::: check how many leaves are using this node
23 // also not needed for now because we don't free individual node because of arena allocator
24 // s32 *refc;
25
26 s32 key_count;
27
28 b32 leaf;
29
30};
31
32typedef struct b_tree b_tree;
33struct b_tree
34{
35 // NOTE(nasr): make sure this always stays in memory
36 // so that initial fetch never requires a disk read
37 b_tree_node *root;
38
39};
40
41
42
43
44#endif /* BTREE_H */