Browse Source

Adapt htstore and tests; make signatures consistent.

Stefano Cossu 2 years ago
parent
commit
efc1a901ca
4 changed files with 25 additions and 14 deletions
  1. 1 1
      include/store_interface.h
  2. 11 6
      src/store_htable.c
  3. 5 1
      src/store_mdb.c
  4. 8 6
      test/test_store.c

+ 1 - 1
include/store_interface.h

@@ -313,7 +313,7 @@ typedef bool (*store_trp_exist_fn_t)(
 typedef LSUP_rc (*store_remove_fn_t)(
         void *store,
         const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct, void *udata);
+        const LSUP_Buffer *sc, void *udata, size_t *ct);
 
 
 /** @brief Put an in-memory namespace map into a permanent back end.

+ 11 - 6
src/store_htable.c

@@ -217,8 +217,9 @@ htstore_size (const void *h)
 
 
 static LSUP_rc
-htstore_add_term (void *h, const LSUP_Buffer *sterm)
+htstore_add_term (void *h, const LSUP_Buffer *sterm, void *_unused)
 {
+    (void) _unused;
     HTStore *store = h;
     IndexEntry entry_s = {
         .key = LSUP_buffer_hash (sterm),
@@ -238,9 +239,10 @@ htstore_add_term (void *h, const LSUP_Buffer *sterm)
 
 
 static void *
-htstore_add_init (void *h, const LSUP_Buffer *_unused)
+htstore_add_init (void *h, const LSUP_Buffer *_unused, void *_unused2)
 {
     (void) _unused;
+    (void) _unused2;
     HTIterator *it;
     MALLOC_GUARD (it, NULL);
 
@@ -265,7 +267,7 @@ htstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
     if (rc != LSUP_OK) return rc;
 
     for (int i = 0; i < 3; i++)
-        htstore_add_term (it->store, LSUP_btriple_pos (sspo, i));
+        htstore_add_term (it->store, LSUP_btriple_pos (sspo, i), NULL);
 
     return rc;
 }
@@ -283,8 +285,9 @@ static void *
 htstore_lookup (
         void *h,
         const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct)
+        const LSUP_Buffer *sc, void *_unused, size_t *ct)
 {
+    (void) _unused;
     HTStore *store = h;
     HTIterator *it;
     CALLOC_GUARD (it, NULL);
@@ -351,13 +354,15 @@ htstore_lookup (
 static LSUP_rc
 htstore_remove(
         void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so,  const LSUP_Buffer *_unused, size_t *ct_p)
+        const LSUP_Buffer *so,  const LSUP_Buffer *_unused,
+        void *_unused2, size_t *ct_p)
 {
     (void) _unused;
+    (void) _unused2;
     HTStore *store = h;
     size_t ct;
 
-    HTIterator *it = htstore_lookup (store, ss, sp, so, NULL, &ct);
+    HTIterator *it = htstore_lookup (store, ss, sp, so, NULL, NULL, &ct);
     if (UNLIKELY (!it)) return LSUP_DB_ERR;
 
     LSUP_rc rc;

+ 5 - 1
src/store_mdb.c

@@ -467,6 +467,7 @@ mdbstore_free (void *h)
 }
 
 
+#if 0
 static char *
 mdbstore_id (const void *h)
 {
@@ -476,6 +477,7 @@ mdbstore_id (const void *h)
 
     return strcat ("file://", path);
 }
+#endif
 
 
 static LSUP_rc
@@ -974,7 +976,7 @@ mdbiter_free (void *h)
 static LSUP_rc
 mdbstore_remove (
         void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so, const LSUP_Buffer *sc, size_t *ct, void *th)
+        const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
 {
     MDBStore *store = h;
     LSUP_rc rc = LSUP_NOACTION, db_rc;
@@ -1059,6 +1061,7 @@ fail:
 }
 
 
+#if 0
 static int
 mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
 {
@@ -1087,6 +1090,7 @@ mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
 
     return rc;
 }
+#endif
 
 
 static LSUP_rc

+ 8 - 6
test/test_store.c

@@ -34,7 +34,7 @@ static int test_triple_store()
     }
 
     // Test adding.
-    void *it = store->sif->add_init_fn (store->data, NULL);
+    void *it = store->sif->add_init_fn (store->data, NULL, NULL);
     size_t ins = 0;
     for (size_t i = 0; i < NUM_TRP; i++) {
         LSUP_rc rc = store->sif->add_iter_fn (it, ser_trp + i);
@@ -102,7 +102,8 @@ static int test_triple_store()
         log_info ("Testing triple lookup #%d.", i);
 
         void *it = store->sif->lookup_fn (
-                store->data, lut[i][0], lut[i][1], lut[i][2], luc[i], &ct);
+                store->data, lut[i][0], lut[i][1], lut[i][2], luc[i],
+                NULL, &ct);
         ASSERT (it != NULL, "Error creating iterator!");
         EXPECT_INT_EQ (ct, results[i]);
 
@@ -153,7 +154,7 @@ static int test_quad_store()
     size_t ins;
 
     // Only triples 0÷5 in default context.
-    it = store->sif->add_init_fn (store->data, NULL);
+    it = store->sif->add_init_fn (store->data, NULL, NULL);
     ins = 0;
     for (size_t i = 0; i < 6; i++) {
         log_info ("Inserting triple #%d in default context.", i);
@@ -170,7 +171,7 @@ static int test_quad_store()
     LSUP_Buffer *sc2 = LSUP_term_serialize (ctx2);
 
     // Only triples 4÷9 in context 2 (effectively 4 non-duplicates).
-    it = store->sif->add_init_fn (store->data, sc2);
+    it = store->sif->add_init_fn (store->data, sc2, NULL);
     ASSERT (it != NULL, "Error creating iterator!");
     ins = 0;
     for (size_t i = 4; i < 10; i++) {
@@ -322,7 +323,8 @@ static int test_quad_store()
 
         log_info ("Checking triple #%d.", i);
         void *it = store->sif->lookup_fn (
-                store->data, lut[i][0], lut[i][1], lut[i][2], luc[i], &ct);
+                store->data, lut[i][0], lut[i][1], lut[i][2], luc[i],
+                NULL, &ct);
         ASSERT (it != NULL, "Lookup error!");
         EXPECT_INT_EQ (ct, results[i]);
 
@@ -333,7 +335,7 @@ static int test_quad_store()
     for (int i = 0; i < 10; i++) {
         void *it = store->sif->lookup_fn (
                 store->data, ser_trp[i].s, ser_trp[i].p, ser_trp[i].o,
-                NULL, NULL);
+                NULL, NULL, NULL);
         log_info ("Checking contexts for triple %d.", i);
         LSUP_Buffer *ctx_a;
         EXPECT_PASS (store->sif->lu_next_fn (it, NULL, &ctx_a));