YACDB
Yet Another C(rappy) Database
db_structs.h
Go to the documentation of this file.
1
9#pragma once
10#include <stdio.h>
11
18typedef size_t Page;
19
27#define YACDB_FILE_NAME "yac.db"
28#define YACDB_SIGNATURE "YACDB format"
29#define YACDB_PAGE_SIZE 512
30#define YACDB_DEFAULT_CACHE_SIZE 10
31
33{
34 char signature[13];
35 unsigned short page_size;
36
37 unsigned int change_counter;
38
39 Page nb_pages;
40 unsigned int default_cache_size;
41
42 Page nb_free_pages;
43 Page fst_free_page;
44};
45
46struct yacdb
47{
48 FILE *file;
49 struct yacdb_header *header;
50
51 struct cached_node *cache;
52 size_t cache_size;
53
54 // Page *cache;
55 // int cache_size;
56 // int cache_index;
57 // int cache_count;
58};
59
60enum page_type
61{
62 NODE_TYPE_TABLE_LEAF = 13,
63 NODE_TYPE_TABLE_INTERIOR = 5,
64 NODE_TYPE_INDEX_LEAF = 10,
65 NODE_TYPE_INDEX_INTERIOR = 2
66};
67
69{
70 Page parent_addr;
71 enum page_type page_type;
72 unsigned short nb_cells;
73 Page right_pointer;
74};
75
77{
78 Page next_page;
79 size_t size;
80};
81
83{
84 size_t size;
85 void *data;
86};
87
88struct ti_cell
89{
90 unsigned int key;
91 Page pointer;
92};
93
95{
96 unsigned int key;
97 unsigned int size;
98 Page overflow;
99};
100
102{
103 struct tl_cell_header *header;
104 void *data;
105};
106
108{
109 struct yacdb *yacdb;
110 struct btree_header *btree_h;
111
112 void **cells_h;
113
114 Page page;
115
116 void *data;
117
118 unsigned short *offsets;
119};
size_t Page
A address to a page.
Definition: db_structs.h:18
Definition: db_structs.h:69
Definition: db_structs.h:108
A struct for holding cached nodes.
Definition: diskio.h:65
Definition: db_structs.h:83
Definition: db_structs.h:77
Definition: db_structs.h:89
Definition: db_structs.h:95
Definition: db_structs.h:102
Definition: db_structs.h:33
Definition: db_structs.h:47