diff options
| author | Soikk | 2022-07-24 22:18:31 +0200 |
|---|---|---|
| committer | Soikk | 2022-07-24 22:18:31 +0200 |
| commit | ff5da06da823ac3a0bc7e89b35ed573255139b2d (patch) | |
| tree | 41551fe546a34ad8f771b5a75eb4d883db5fb4ac /include | |
| parent | caacd02d3c6a6ab3ddea620214ee5d1836de2c31 (diff) | |
| download | soikk-DB-ff5da06da823ac3a0bc7e89b35ed573255139b2d.tar.xz soikk-DB-ff5da06da823ac3a0bc7e89b35ed573255139b2d.tar.zst | |
Added ref count for files & tags. Refactored database.c. Removed tags.h but kept documentation.
Diffstat (limited to 'include')
| -rw-r--r-- | include/database.h | 9 | ||||
| -rw-r--r-- | include/storage.h | 11 | ||||
| -rw-r--r-- | include/str.h | 1 | ||||
| -rw-r--r-- | include/tags.h | 22 |
4 files changed, 19 insertions, 24 deletions
diff --git a/include/database.h b/include/database.h index 2b1c91a..339b48b 100644 --- a/include/database.h +++ b/include/database.h @@ -8,6 +8,7 @@ typedef struct database{ char name[32]; ltable *lfiles, *ltags; htable *hfiles, *htags; + htable *fcount, *tcount; mtable *map; } database; @@ -18,11 +19,17 @@ database *loadDatabase(const char* path); int storeDatabase(database *db, const char *path); +uint64_t addFile(database *db, char *file); + +uint64_t addTag(database *db, char *tag); + int addFileTag(database *db, char *file, char *tag); int addFileTags(database *db, char *file, int ntags, ...); -int searchTag(database *db, char *tag, uint64_t *rl); +int searchTag(database *db, char *tag, uint64_t n, uint64_t **r, uint64_t *rl); + +int searchFile(database *db, char *file, uint64_t n, uint64_t **r, uint64_t *rl); void printDatabase(database *db); diff --git a/include/storage.h b/include/storage.h index 82ea55a..bef740a 100644 --- a/include/storage.h +++ b/include/storage.h @@ -3,6 +3,17 @@ #include "db.h" +/* (From tags.h) + tags are stored in a big table (or their hashes are) ordered + by alphabetical order + tags can have namespaces which are a special tag that starts + with a ':' + all tags in a namespace are located between two occurrences + of the namespace within the list, + e.g [":people", "sam hyde", "hitler", ":people"] + maybe namespaces use another hashing function to prevent + collisions because of the lack of space because of the ':' +*/ /* tags are stored in a big table (or their hashes are) ordered diff --git a/include/str.h b/include/str.h index de119f8..999f1e3 100644 --- a/include/str.h +++ b/include/str.h @@ -14,5 +14,4 @@ char *normalizeStrLimit(const char *str, uint32_t *l, uint32_t limit); ssize_t strInTags(const char *tags, int n, const char *ndl, int m, char sep); - #endif diff --git a/include/tags.h b/include/tags.h deleted file mode 100644 index 0b7f5a9..0000000 --- a/include/tags.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef TAGS_H -#define TAGS_H - -/* - tags are stored in a big table (or their hashes are) ordered - by alphabetical order - tags can have namespaces which are a special tag that starts - with a ':' - all tags in a namespace are located between two occurrences - of the namespace within the list, - e.g [":people", "sam hyde", "hitler", ":people"] - maybe namespaces use another hashing function to prevent - collisions because of the lack of space because of the ':' -*/ - -#define MAXTAGS 4094 - -void insertTag(char **tags, char *tag){ - if() -} - -#endif
\ No newline at end of file |
