aboutsummaryrefslogtreecommitdiff
path: root/include/storage.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/storage.h')
-rw-r--r--include/storage.h65
1 files changed, 48 insertions, 17 deletions
diff --git a/include/storage.h b/include/storage.h
index ebf2dc2..8bfc751 100644
--- a/include/storage.h
+++ b/include/storage.h
@@ -60,11 +60,11 @@ typedef struct lookupTable{
char **table; // They cant be longer than MAXPATH
} ltable;
-// Stores the hashes of the filepaths/tags (for easier lookup)
-typedef struct hashTable{
+// Stores a number (used as the count for files and tags in the mapping table)
+typedef struct countTable{
uint64_t size;
uint64_t *table;
-} htable;
+} ctable;
typedef struct relation{
uint64_t file;
@@ -77,42 +77,73 @@ typedef struct mappingTable{
relation *table;
} mtable;
+// Stores a hash and an index (hash table implemented with an AVL tree) for easier lookup
+typedef struct AVLnode{
+ uint64_t h;
+ uint64_t i;
+ struct AVLnode *left;
+ struct AVLnode *right;
+} node;
-// LTABLE
-ltable *newLtable(uint64_t size);
+typedef node* tree;
-ltable *loadLtable(FILE *fp);
-int storeLtable(const ltable *lt, FILE *fp);
+// LTABLE
+
+ltable *newLtable(uint64_t size);
int ltableAdd(ltable *lt, char *str);
uint64_t ltableSearch(ltable *lt, char *str);
-// HTABLE
+int storeLtable(const ltable *lt, FILE *fp);
+
+ltable *loadLtable(FILE *fp);
+
+// CTABLE
-htable *newHtable(uint64_t size);
+ctable *newCtable(uint64_t size);
-htable *loadHtable(FILE *fp);
+int ctableAdd(ctable *ct, uint64_t n);
-int storeHtable(const htable *ht, FILE *fp);
+int ctableDelete(ctable *ct, uint64_t n);
-int htableAdd(htable *ht, uint64_t h);
+uint64_t ctableSearch(ctable *ct, uint64_t n);
-uint64_t htableSearch(htable *ht, uint64_t h);
+int storeCtable(const ctable *ht, FILE *fp);
-int htableDelete(htable *ht, uint64_t h);
+ctable *loadCtable(FILE *fp);
// MTABLE
mtable *newMtable(uint64_t size);
-mtable *loadMtable(FILE *fp);
+int mtableAdd(mtable *mt, relation r);
+
+uint64_t mtableSearch(mtable *mt, relation r);
+
+uint64_t mtableSearchFile(mtable *mt, uint64_t file);
+
+uint64_t mtableSearchTag(mtable *mt, uint64_t tag);
int storeMtable(const mtable *mt, FILE *fp);
-int mtableAdd(mtable *mt, relation r);
+mtable *loadMtable(FILE *fp);
-uint64_t mtableSearch(mtable *mt, relation r);
+// AVL TREE
+
+uint64_t height(node *n);
+
+node *newNode(uint64_t h, uint64_t i);
+
+node *insertNode(node *r, uint64_t h, uint64_t i);
+
+node *deleteNode(node *r, uint64_t h);
+
+uint64_t nodeSearch(node *n, uint64_t h);
+
+int storeAVLTree(tree root, FILE *fp);
+
+tree loadAVLTree(FILE *fp);
#endif