summaryrefslogtreecommitdiff
path: root/source/storage
diff options
context:
space:
mode:
Diffstat (limited to 'source/storage')
-rw-r--r--source/storage/b_tree.c45
-rw-r--r--source/storage/b_tree.h44
-rw-r--r--source/storage/csv_reader.c7
-rw-r--r--source/storage/csv_reader.h43
-rw-r--r--source/storage/table.c0
-rw-r--r--source/storage/table.h0
6 files changed, 0 insertions, 139 deletions
diff --git a/source/storage/b_tree.c b/source/storage/b_tree.c
deleted file mode 100644
index 6a0e76d..0000000
--- a/source/storage/b_tree.c
+++ /dev/null
@@ -1,45 +0,0 @@
1
2// TODO(nasr): 1. splitting the tree when getting too big? (horizontally) 2. joining trees?
3
4internal b_tree_node *
5node_alloc(mem_arena *arena)
6{
7 b_tree_node *node = PushStructZero(arena, type);
8 node->leaf = 1;
9 return node;
10}
11
12// NOTE(nasr): @return the index of of the found element
13internal i32
14node_find_pos(mem_arena *arena, string8 value)
15{
16 i32 i = 0;
17 while (i < n->key_count && str8_cmp(n->keys[i], k) < 0)
18 {
19 ++i;
20 }
21
22 return i;
23}
24
25// NOTE(nasr): nodes that get passed as parameters should've already been loaded into memory
26internal void
27b_tree_search(node *node)
28{
29
30
31}
32
33internal void
34b_tree_insert()
35{
36
37}
38
39internal void
40b_tree_write()
41{
42 // TODO(nasr): write the b_tree to disk
43}
44
45
diff --git a/source/storage/b_tree.h b/source/storage/b_tree.h
deleted file mode 100644
index 10ad00d..0000000
--- a/source/storage/b_tree.h
+++ /dev/null
@@ -1,44 +0,0 @@
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 // i32 *refc;
25
26 i32 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 */
diff --git a/source/storage/csv_reader.c b/source/storage/csv_reader.c
deleted file mode 100644
index 2fcbe04..0000000
--- a/source/storage/csv_reader.c
+++ /dev/null
@@ -1,7 +0,0 @@
1internal void
2read_csv(string8 buffer)
3{
4 printf("\nsize:%lu\ndata %s\n", buffer.size, buffer.data);
5
6}
7
diff --git a/source/storage/csv_reader.h b/source/storage/csv_reader.h
deleted file mode 100644
index 36e07a4..0000000
--- a/source/storage/csv_reader.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef CSV_READER_H
2#define CSV_READER_H
3
4typedef struct csv_row csv_row;
5struct csv_row
6{
7 // array of size col_count, points into mmap buffer
8 string8 *fields;
9 i32 count;
10};
11
12typedef struct csv_table csv_table;
13struct csv_table
14{
15 // first row, col names
16 // all data rows
17 string8 *headers;
18 csv_row *rows;
19 i32 col_count;
20 i32 row_count;
21};
22
23read_only global_variable
24csv_row nil_csv_row =
25{
26 .fields = &nil_string,
27 .count = 0,
28};
29
30
31
32read_only global_variable
33csv_table nil_csv_table =
34{
35 .headers = &nil_string,
36 .rows = &nil_csv_row,
37 .col_count = 0,
38 .row_count = 0,
39};
40
41
42
43#endif /* CSV_READER_H */
diff --git a/source/storage/table.c b/source/storage/table.c
deleted file mode 100644
index e69de29..0000000
--- a/source/storage/table.c
+++ /dev/null
diff --git a/source/storage/table.h b/source/storage/table.h
deleted file mode 100644
index e69de29..0000000
--- a/source/storage/table.h
+++ /dev/null