summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sord/sord.h19
-rw-r--r--src/sord.c87
-rw-r--r--src/sord_test.c30
3 files changed, 1 insertions, 135 deletions
diff --git a/sord/sord.h b/sord/sord.h
index d464358..feca90b 100644
--- a/sord/sord.h
+++ b/sord/sord.h
@@ -356,30 +356,13 @@ sord_add(SordModel model, const SordQuad quad);
/**
Remove a quad from the store.
- This function invalidates all iterators to @a sord (use sord_remove_iter
- if this is undesirable)
+ Note that is it illegal to remove while iterator over @a model.
*/
SORD_API
void
sord_remove(SordModel model, const SordQuad quad);
/**
- Remove a quad from the store by iterator.
-
- @a iter will be incremented to point at the next value.
-*/
-SORD_API
-void
-sord_remove_iter(SordModel model, SordIter iter);
-
-/**
- Remove a graph from the store.
-*/
-SORD_API
-void
-sord_remove_graph(SordModel model, SordNode graph);
-
-/**
@}
@name Iteration
@{
diff --git a/src/sord.c b/src/sord.c
index 9c193a0..3843e2c 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -1047,90 +1047,3 @@ sord_remove(SordModel sord, const SordQuad tup)
--sord->n_quads;
}
-
-void
-sord_remove_iter(SordModel sord, SordIter iter)
-{
- SordQuad tup;
- sord_iter_get(iter, tup);
-
- SORD_WRITE_LOG("Remove " TUP_FMT "\n", TUP_FMT_ARGS(tup));
-
- // TODO: Directly remove the iterator's index (avoid one search)
-
- for (unsigned i = 0; i < NUM_ORDERS; ++i) {
- if (sord->indices[i]) {
- const int* const ordering = orderings[i];
- const SordQuad key = {
- tup[ordering[0]], tup[ordering[1]], tup[ordering[2]], tup[ordering[3]]
- };
- GSequenceIter* const cur = index_search(sord, sord->indices[i], key);
- if (!g_sequence_iter_is_end(cur)) {
- g_sequence_remove(cur);
- } else {
- assert(i == 0); // Assuming index coherency
- }
- }
- }
-
- for (int i = 0; i < TUP_LEN; ++i)
- sord_drop_quad_ref(sord, tup[i]);
-
- --sord->n_quads;
-
- iter->end = g_sequence_iter_is_end(iter->cur);
-}
-
-void
-sord_remove_graph(SordModel sord, SordNode graph)
-{
-#if 0
- if (!sord->indices[GSPO])
- return;
-
- // Remove all quads in graph from non-graph indices
- BDBCUR* cur = tcbdbcurnew(sord->indices[GSPO]);
- const SordQuad search_key = { graph, 0, 0, 0 };
- int key_size = sizeof(SordQuad);
- tcbdbcurjump(cur, &search_key, key_size);
- do {
- const SordNode* key = (const SordNode*)tcbdbcurkey3(cur, &key_size);
- if (!key || key[0] != graph)
- break;
-
- for (unsigned i = 0; i < GSPO; ++i) {
- if (sord->indices[i]) {
- const int* const ordering = orderings[i];
- const SordQuad tup = { key[1], key[2], key[3], key[0] }; // Key in SPOG order
- const SordQuad subkey = {
- tup[ordering[0]], tup[ordering[1]], tup[ordering[2]], tup[ordering[3]]
- };
- if (!tcbdbout(sord->indices[i], &subkey, sizeof(SordQuad)))
- fprintf(stderr, "Failed to remove key " TUP_FMT "\n", TUP_FMT_ARGS(subkey));
- }
- }
-
- --sord->n_quads;
- } while (tcbdbcurnext(cur));
-
- // Remove all quads in graph from graph indices
- for (unsigned i = GSPO; i < NUM_ORDERS; ++i) {
- if (sord->indices[i]) {
- BDBCUR* cur = tcbdbcurnew(sord->indices[i]);
- tcbdbcurjump(cur, &search_key, key_size);
- while (true) {
- const SordNode* key = (const SordNode*)tcbdbcurkey3(cur, &key_size);
- if (!key || key[0] != graph) {
- break;
- } else if (i == GSPO) {
- for (int i = 0; i < TUP_LEN; ++i) {
- sord_drop_quad_ref(sord, key[i]);
- }
- }
- if (!tcbdbcurout(cur))
- break;
- }
- }
- }
-#endif
-}
diff --git a/src/sord_test.c b/src/sord_test.c
index 8a3c88b..e89d939 100644
--- a/src/sord_test.c
+++ b/src/sord_test.c
@@ -257,31 +257,6 @@ test_read(SordWorld world, SordModel sord, const size_t n_quads, const int n_obj
}
int
-test_write(SordModel sord, const size_t n_quads, const int n_objects_per)
-{
- int ret = EXIT_SUCCESS;
-
- fprintf(stderr, "Removing Statements... ");
-
- // Remove statements
- SordIter iter;
- for (iter = sord_begin(sord); !sord_iter_end(iter);) {
- sord_remove_iter(sord, iter);
- }
- sord_iter_free(iter);
-
- const int num_quads = sord_num_quads(sord);
- if (num_quads != 0) {
- fprintf(stderr, "Fail: All quads removed but %d quads remain\n", num_quads);
- return test_fail();
- }
-
- fprintf(stderr, "OK\n\n");
-
- return ret;
-}
-
-int
main(int argc, char** argv)
{
static const size_t n_quads = 300;
@@ -359,11 +334,6 @@ main(int argc, char** argv)
sord_free(sord);
}
- sord = sord_new(world, SORD_SPO, false);
- if (test_write(sord, n_quads, n_objects_per))
- goto fail;
-
- sord_free(sord);
sord_world_free(world);
return EXIT_SUCCESS;