|
@@ -10,8 +10,14 @@ _graph_new (LSUP_StoreType type)
|
|
const LSUP_StoreInt *sif = LSUP_store_int (type);
|
|
const LSUP_StoreInt *sif = LSUP_store_int (type);
|
|
if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store;
|
|
|
|
+ if (type == LSUP_STORE_HTABLE) {
|
|
|
|
+ gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
|
+ } else {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
|
+ }
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
|
|
|
|
EXPECT_PASS (LSUP_graph_set_uri (gr, LSUP_iriref_new ("urn:gr:1", NULL)));
|
|
EXPECT_PASS (LSUP_graph_set_uri (gr, LSUP_iriref_new ("urn:gr:1", NULL)));
|
|
@@ -27,6 +33,7 @@ _graph_new (LSUP_StoreType type)
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr), 0);
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr), 0);
|
|
|
|
|
|
LSUP_graph_free (gr);
|
|
LSUP_graph_free (gr);
|
|
|
|
+ if (type != LSUP_STORE_HTABLE) LSUP_store_free (store);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -40,8 +47,14 @@ _graph_add (LSUP_StoreType type)
|
|
|
|
|
|
LSUP_Triple *trp = create_triples();
|
|
LSUP_Triple *trp = create_triples();
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store;
|
|
|
|
+ if (type == LSUP_STORE_HTABLE) {
|
|
|
|
+ gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
|
+ } else {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
|
+ }
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
|
|
|
|
size_t ct;
|
|
size_t ct;
|
|
@@ -62,6 +75,7 @@ _graph_add (LSUP_StoreType type)
|
|
free_triples (trp); // gr copied data.
|
|
free_triples (trp); // gr copied data.
|
|
|
|
|
|
LSUP_graph_free (gr);
|
|
LSUP_graph_free (gr);
|
|
|
|
+ if (type != LSUP_STORE_HTABLE) LSUP_store_free (store);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -121,8 +135,14 @@ _graph_lookup (LSUP_StoreType type)
|
|
|
|
|
|
if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store;
|
|
|
|
+ if (type == LSUP_STORE_HTABLE) {
|
|
|
|
+ gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
|
+ } else {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
|
+ }
|
|
|
|
|
|
size_t ct;
|
|
size_t ct;
|
|
LSUP_graph_add (gr, trp, &ct);
|
|
LSUP_graph_add (gr, trp, &ct);
|
|
@@ -166,6 +186,7 @@ _graph_lookup (LSUP_StoreType type)
|
|
|
|
|
|
free_triples (trp);
|
|
free_triples (trp);
|
|
LSUP_graph_free (gr);
|
|
LSUP_graph_free (gr);
|
|
|
|
+ if (type != LSUP_STORE_HTABLE) LSUP_store_free (store);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -179,8 +200,14 @@ _graph_remove (LSUP_StoreType type)
|
|
|
|
|
|
LSUP_Triple *trp = create_triples();
|
|
LSUP_Triple *trp = create_triples();
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store;
|
|
|
|
+ if (type == LSUP_STORE_HTABLE) {
|
|
|
|
+ gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
|
+ } else {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
|
+ }
|
|
|
|
|
|
size_t ct;
|
|
size_t ct;
|
|
LSUP_graph_add (gr, trp, &ct);
|
|
LSUP_graph_add (gr, trp, &ct);
|
|
@@ -205,6 +232,7 @@ _graph_remove (LSUP_StoreType type)
|
|
free_triples (trp); // gr copied data.
|
|
free_triples (trp); // gr copied data.
|
|
|
|
|
|
LSUP_graph_free (gr);
|
|
LSUP_graph_free (gr);
|
|
|
|
+ if (type != LSUP_STORE_HTABLE) LSUP_store_free (store);
|
|
|
|
|
|
// TODO Test complete removal of triples from index when they are not
|
|
// TODO Test complete removal of triples from index when they are not
|
|
// in another context.
|
|
// in another context.
|
|
@@ -223,8 +251,14 @@ _graph_txn (LSUP_StoreType type)
|
|
|
|
|
|
LSUP_Triple *trp = create_triples();
|
|
LSUP_Triple *trp = create_triples();
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), type, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store;
|
|
|
|
+ if (type == LSUP_STORE_HTABLE) {
|
|
|
|
+ gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
|
+ } else {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
|
+ }
|
|
|
|
|
|
void *txn;
|
|
void *txn;
|
|
size_t ct;
|
|
size_t ct;
|
|
@@ -245,6 +279,11 @@ _graph_txn (LSUP_StoreType type)
|
|
EXPECT_INT_EQ (ct, 8);
|
|
EXPECT_INT_EQ (ct, 8);
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr), 8);
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr), 8);
|
|
|
|
|
|
|
|
+ LSUP_graph_free (gr);
|
|
|
|
+ if (type != LSUP_STORE_HTABLE) LSUP_store_free (store);
|
|
|
|
+
|
|
|
|
+ free_triples (trp); // gr copied data.
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -330,15 +369,13 @@ static int test_graph_copy()
|
|
{
|
|
{
|
|
LSUP_Triple *trp = create_triples();
|
|
LSUP_Triple *trp = create_triples();
|
|
|
|
|
|
- LSUP_Graph *gr1 = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), LSUP_STORE_HTABLE, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr1 = LSUP_graph_new (NULL, NULL, NULL);
|
|
ASSERT (gr1 != NULL, "Error creating graph!");
|
|
ASSERT (gr1 != NULL, "Error creating graph!");
|
|
|
|
|
|
LSUP_graph_add (gr1, trp, NULL);
|
|
LSUP_graph_add (gr1, trp, NULL);
|
|
|
|
|
|
// Copy to graph with same store type.
|
|
// Copy to graph with same store type.
|
|
- LSUP_Graph *gr2 = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), LSUP_STORE_HTABLE, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr2 = LSUP_graph_new (NULL, NULL, NULL);
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr2));
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr2));
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
|
|
|
|
@@ -350,8 +387,7 @@ static int test_graph_copy()
|
|
}
|
|
}
|
|
|
|
|
|
// Copy to graph with a different store type.
|
|
// Copy to graph with a different store type.
|
|
- LSUP_Graph *gr3 = LSUP_graph_new (
|
|
|
|
- LSUP_iriref_new (NULL, NULL), LSUP_STORE_MDB, NULL, NULL, 0);
|
|
|
|
|
|
+ LSUP_Graph *gr3 = LSUP_graph_new (NULL, NULL, NULL);
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr3));
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr3));
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
|
|
|