From 4b721332d570f53719894af922c22b7cba146b18 Mon Sep 17 00:00:00 2001 From: Soikk Date: Sat, 13 Aug 2022 18:49:30 +0200 Subject: Added primitive repl, delete functions for database and remove tag from file function. --- DOC | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'DOC') diff --git a/DOC b/DOC index 8aa33d4..857cf0d 100644 --- a/DOC +++ b/DOC @@ -1,5 +1,17 @@ OBSERVATIONS +Notation: + CREATE miDB -> creates new database called miDB. + CREATE miDB miDB2 -> creates two new databases + CREATE "miDB miDB2" -> creates a new database called "miDB miDB2" (without the quotation marks). + + OPEN .. + + TAG file WITH tag -> adds tag to file + TAG file1 file2 WITH tag -> adds tag to file1, file2 + TAG file WITH tag1 tag2 -> adds tag1, tag2 to file + + STORAGE LTABLE @@ -253,25 +265,6 @@ DATABASE static void decreaseCount(ctable *ct, uint64_t i); Auxiliary function that decreases the count of cell i at ct's table; - static int addRelation(database *db, relation r); - Auxiliary function that adds a relation to the mapping table in db. - This function returns 0 if r was inserted correctly or -1 if r was already on the database. - - int addFileTag(database *db, char *file, char *tag); - This function uses the auxiliary functions addRelation and increaseCount. - Adds a file and a tag to the database, and its relation. - If the file or the tag or both were already on the database, it still adds the relation. - If the relation wasn't in the database, it adds one to the cfiles' table for the file index and another one to the ctags' table for the file index, and then returns 0. - If the relation was in the database, it returns -1. - - int addFileTags(database *db, char *file, int ntags, ...); - Adds multiple tags to a single file using addFileTag. - Returns 0 upon completion. - - int addTagFiles(database *db, char *tag, int nfiles, ...); - Adds the same tag to multiple files using addFileTag. - Returns 0 upon completion. - static void decreaseHigherIndexNode(node *n, uint64_t i); Auxiliary function that decreases the indexes in the node structure of n by one if they're bigger than i. @@ -293,6 +286,25 @@ DATABASE To counter this, we use the auxiliary functions decreaseHigherIndexNode and decreaseHigherTagIndexMap to update all the higher indexes in htags and map. This function returns 0 upon completion or -1 if the tag is not in the database. + static int addRelation(database *db, relation r); + Auxiliary function that adds a relation to the mapping table in db. + This function returns 0 if r was inserted correctly or -1 if r was already on the database. + + int addFileTag(database *db, char *file, char *tag); + This function uses the auxiliary functions addRelation and increaseCount. + Adds a file and a tag to the database, and its relation. + If the file or the tag or both were already on the database, it still adds the relation. + If the relation wasn't in the database, it adds one to the cfiles' table for the file index and another one to the ctags' table for the file index, and then returns 0. + If the relation was in the database, it returns -1. + + int addFileTags(database *db, char *file, int ntags, ...); + Adds multiple tags to a single file using addFileTag. + Returns 0 upon completion. + + int addTagFiles(database *db, char *tag, int nfiles, ...); + Adds the same tag to multiple files using addFileTag. + Returns 0 upon completion. + int searchFile(database *db, char *file, uint64_t n, uint64_t **r, uint64_t *rl); Stores in r a list with the indexes of the first n tags that this file has. If n is 0, it returns all of them. Stores in rl the length of r. -- cgit v1.2.3