]> git.xolatile.top Git - soikk-DB.git/commitdiff
added htable delete function
authorSoikk <76824648+Soikk@users.noreply.github.com>
Sat, 30 Jul 2022 15:35:47 +0000 (17:35 +0200)
committerSoikk <76824648+Soikk@users.noreply.github.com>
Sat, 30 Jul 2022 15:35:47 +0000 (17:35 +0200)
hash-testing/main.c
hash-testing/main.exe [new file with mode: 0644]
include/storage.h
src/database.c
src/storage.c

index f95b391e0974663ff74897467618e64982d2dec7..23fdbbd7975fabd0673a904fd4e2930c7dc9f72c 100644 (file)
@@ -344,11 +344,13 @@ int main(){
     while (fgets(line, sizeof(line), f)) {
         uint16_t l;
         char *nline = normalizeStr(line, &l);
-        uint64_t hash = crc64(0, nline, l);
-        if(isInArr(arr, hash)){
+        uint64_t hash = crc64(SEED, nline, l);
+        //uint32_t hash = xcrc32(nline, l, SEED);
+        //uint32_t hash = murmurhash(nline, l, SEED);
+        /*if(isInArr(arr, hash)){
                ++collisions;
         }
-        arr[i] = hash;
+        arr[i] = hash;*/
         //printf("%s\t%08x\n", nline, hash);
         ++i;
     }
diff --git a/hash-testing/main.exe b/hash-testing/main.exe
new file mode 100644 (file)
index 0000000..3d96212
Binary files /dev/null and b/hash-testing/main.exe differ
index bef740a9982a8b0182d0b27a8aeea78a8bfc5533..ebf2dc216c08029f2a93d93dd5279088bb9d6911 100644 (file)
@@ -101,6 +101,8 @@ int htableAdd(htable *ht, uint64_t h);
 
 uint64_t htableSearch(htable *ht, uint64_t h);
 
+int htableDelete(htable *ht, uint64_t h);
+
 // MTABLE
 
 mtable *newMtable(uint64_t size);
index ea3a6e0df441bed3c9acbab4caa52ab954c33338..5595240204d15ae80579560187ce4ba6d41ade4e 100644 (file)
@@ -222,3 +222,9 @@ void debugDatabase(database *db){
        }
        printf("\n");
 }
+
+void reOrderDatabase(database *db){
+
+       
+
+}
index 4ebbfdc507d9aa08767281ef1d73fba6ed8aa564..2be4d9e5edb9b3667b3084d321b66d88fef17cd5 100644 (file)
@@ -142,6 +142,7 @@ int htableAdd(htable *ht, uint64_t h){
        return 0;
 }
 
+// We assume the table isnt ordered as of right now
 uint64_t htableSearch(htable *ht, uint64_t h){
        for(uint64_t i = 0; i < ht->size; ++i){
                if(h == ht->table[i]){
@@ -151,6 +152,18 @@ uint64_t htableSearch(htable *ht, uint64_t h){
        return -1;
 }
 
+int htableDelete(htable *ht, uint64_t h){
+       uint64_t i = htableSearch(ht, h);
+       if(i == -1){
+               return -1;
+       }
+       ht->size--;
+       for(uint64_t j = i; j < ht->size-1; ++j){
+               ht->table[j] = ht->table[j+1];
+       }
+       return 0;
+}
+
 mtable *newMtable(uint64_t size){
        mtable *mt = malloc(sizeof(mtable));
        size = (((uint64_t)size) < 0) ? 0 : size;