|
@@ -12,7 +12,6 @@ struct graph_t {
|
|
* NOTE: This is
|
|
* NOTE: This is
|
|
* NULL for permanent stores.
|
|
* NULL for permanent stores.
|
|
*/
|
|
*/
|
|
- void * txn; ///< Store transaction.
|
|
|
|
};
|
|
};
|
|
|
|
|
|
struct graph_iter_t {
|
|
struct graph_iter_t {
|
|
@@ -87,17 +86,15 @@ LSUP_graph_new (
|
|
if (gr->store->sif->features & LSUP_STORE_PERM) gr->nsm = NULL;
|
|
if (gr->store->sif->features & LSUP_STORE_PERM) gr->nsm = NULL;
|
|
else gr->nsm = nsm ? nsm : LSUP_default_nsm;
|
|
else gr->nsm = nsm ? nsm : LSUP_default_nsm;
|
|
|
|
|
|
- gr->txn = NULL;
|
|
|
|
-
|
|
|
|
log_debug ("Graph created.");
|
|
log_debug ("Graph created.");
|
|
return gr;
|
|
return gr;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_bool_op(
|
|
|
|
- const LSUP_bool_op op, const LSUP_Graph *gr1, const LSUP_Graph *gr2,
|
|
|
|
- LSUP_Graph *res)
|
|
|
|
|
|
+LSUP_graph_bool_op_txn (
|
|
|
|
+ void *txn, const LSUP_bool_op op,
|
|
|
|
+ const LSUP_Graph *gr1, const LSUP_Graph *gr2, LSUP_Graph *res)
|
|
{
|
|
{
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
if (UNLIKELY (
|
|
if (UNLIKELY (
|
|
@@ -127,16 +124,16 @@ LSUP_graph_bool_op(
|
|
LSUP_BufferTriple *sspo = BTRP_DUMMY;
|
|
LSUP_BufferTriple *sspo = BTRP_DUMMY;
|
|
size_t ct;
|
|
size_t ct;
|
|
|
|
|
|
- add_it = res->store->sif->add_init_fn (res->store->data, res_sc, gr1->txn);
|
|
|
|
|
|
+ add_it = res->store->sif->add_init_fn (res->store->data, res_sc, txn);
|
|
|
|
|
|
if (op == LSUP_BOOL_XOR) {
|
|
if (op == LSUP_BOOL_XOR) {
|
|
// Add triples from gr2 if not found in gr1.
|
|
// Add triples from gr2 if not found in gr1.
|
|
lu2_it = gr2->store->sif->lookup_fn (
|
|
lu2_it = gr2->store->sif->lookup_fn (
|
|
- gr2->store->data, NULL, NULL, NULL, gr2_sc, NULL, gr1->txn);
|
|
|
|
|
|
+ gr2->store->data, NULL, NULL, NULL, gr2_sc, NULL, txn);
|
|
while (gr2->store->sif->lu_next_fn (lu2_it, sspo, NULL) == LSUP_OK) {
|
|
while (gr2->store->sif->lu_next_fn (lu2_it, sspo, NULL) == LSUP_OK) {
|
|
lu1_it = gr1->store->sif->lookup_fn (
|
|
lu1_it = gr1->store->sif->lookup_fn (
|
|
gr1->store->data, sspo->s, sspo->p, sspo->o, gr1_sc,
|
|
gr1->store->data, sspo->s, sspo->p, sspo->o, gr1_sc,
|
|
- gr1->txn, &ct);
|
|
|
|
|
|
+ txn, &ct);
|
|
if (ct > 0)
|
|
if (ct > 0)
|
|
res->store->sif->add_iter_fn (add_it, sspo);
|
|
res->store->sif->add_iter_fn (add_it, sspo);
|
|
gr1->store->sif->lu_free_fn (lu1_it);
|
|
gr1->store->sif->lu_free_fn (lu1_it);
|
|
@@ -145,11 +142,11 @@ LSUP_graph_bool_op(
|
|
}
|
|
}
|
|
|
|
|
|
lu1_it = gr1->store->sif->lookup_fn (
|
|
lu1_it = gr1->store->sif->lookup_fn (
|
|
- gr1->store->data, NULL, NULL, NULL, gr1_sc, gr1->txn, NULL);
|
|
|
|
|
|
+ gr1->store->data, NULL, NULL, NULL, gr1_sc, txn, NULL);
|
|
while (gr1->store->sif->lu_next_fn (lu1_it, sspo, NULL) == LSUP_OK) {
|
|
while (gr1->store->sif->lu_next_fn (lu1_it, sspo, NULL) == LSUP_OK) {
|
|
lu2_it = gr2->store->sif->lookup_fn (
|
|
lu2_it = gr2->store->sif->lookup_fn (
|
|
gr2->store->data, sspo->s, sspo->p, sspo->o, gr2_sc,
|
|
gr2->store->data, sspo->s, sspo->p, sspo->o, gr2_sc,
|
|
- gr1->txn, &ct);
|
|
|
|
|
|
+ txn, &ct);
|
|
// For XOR and subtraction, add if not found.
|
|
// For XOR and subtraction, add if not found.
|
|
// For intersection, add if found.
|
|
// For intersection, add if found.
|
|
if ((ct == 0) ^ (op == LSUP_BOOL_INTERSECTION))
|
|
if ((ct == 0) ^ (op == LSUP_BOOL_INTERSECTION))
|
|
@@ -246,14 +243,14 @@ LSUP_graph_equals (const LSUP_Graph *gr1, const LSUP_Graph *gr2)
|
|
|
|
|
|
|
|
|
|
LSUP_GraphIterator *
|
|
LSUP_GraphIterator *
|
|
-LSUP_graph_add_init (LSUP_Graph *gr)
|
|
|
|
|
|
+LSUP_graph_add_init_txn (void *txn, LSUP_Graph *gr)
|
|
{
|
|
{
|
|
LSUP_GraphIterator *it;
|
|
LSUP_GraphIterator *it;
|
|
CALLOC_GUARD (it, NULL);
|
|
CALLOC_GUARD (it, NULL);
|
|
|
|
|
|
LSUP_Buffer *sc = LSUP_term_serialize (gr->uri);
|
|
LSUP_Buffer *sc = LSUP_term_serialize (gr->uri);
|
|
|
|
|
|
- it->data = gr->store->sif->add_init_fn (gr->store->data, sc, gr->txn);
|
|
|
|
|
|
+ it->data = gr->store->sif->add_init_fn (gr->store->data, sc, txn);
|
|
LSUP_buffer_free (sc);
|
|
LSUP_buffer_free (sc);
|
|
|
|
|
|
it->graph = gr;
|
|
it->graph = gr;
|
|
@@ -272,19 +269,19 @@ LSUP_graph_add_iter (LSUP_GraphIterator *it, const LSUP_Triple *spo)
|
|
if (UNLIKELY (!sspo)) return LSUP_MEM_ERR;
|
|
if (UNLIKELY (!sspo)) return LSUP_MEM_ERR;
|
|
const LSUP_StoreInt *sif = it->graph->store->sif;
|
|
const LSUP_StoreInt *sif = it->graph->store->sif;
|
|
|
|
|
|
- LSUP_rc rc = sif->add_iter_fn (it->data, sspo);
|
|
|
|
- PCHECK (rc, finally);
|
|
|
|
|
|
+ LSUP_rc rc;
|
|
|
|
+
|
|
|
|
+ PCHECK (rc = sif->add_iter_fn (it->data, sspo), finally);
|
|
|
|
|
|
- // Store datatype term permanently if the store supports it.
|
|
|
|
|
|
+ // Store datatype term permanently.
|
|
if (rc == LSUP_OK && sif->add_term_fn) {
|
|
if (rc == LSUP_OK && sif->add_term_fn) {
|
|
- void *txn;
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|
|
LSUP_Term *term = LSUP_triple_pos (spo, i);
|
|
LSUP_Term *term = LSUP_triple_pos (spo, i);
|
|
if (term->type == LSUP_TERM_LITERAL) {
|
|
if (term->type == LSUP_TERM_LITERAL) {
|
|
LSUP_Buffer *ser_dtype = LSUP_term_serialize (term->datatype);
|
|
LSUP_Buffer *ser_dtype = LSUP_term_serialize (term->datatype);
|
|
- // Run add_term in the iterator's txn.
|
|
|
|
- txn = sif->iter_txn_fn ? sif->iter_txn_fn (it->data) : NULL;
|
|
|
|
- sif->add_term_fn ( it->graph->store->data, ser_dtype, txn);
|
|
|
|
|
|
+ LSUP_rc term_rc = sif->add_term_fn (
|
|
|
|
+ it->graph->store->data, ser_dtype, it->data);
|
|
|
|
+ PCHECK (term_rc, finally);
|
|
LSUP_buffer_free (ser_dtype);
|
|
LSUP_buffer_free (ser_dtype);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -307,12 +304,13 @@ LSUP_graph_add_done (LSUP_GraphIterator *it)
|
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_add (LSUP_Graph *gr, const LSUP_Triple trp[], size_t *ct)
|
|
|
|
|
|
+LSUP_graph_add_txn (
|
|
|
|
+ void *txn, LSUP_Graph *gr, const LSUP_Triple trp[], size_t *ct)
|
|
{
|
|
{
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
|
|
|
|
// Initialize iterator.
|
|
// Initialize iterator.
|
|
- LSUP_GraphIterator *it = LSUP_graph_add_init (gr);
|
|
|
|
|
|
+ LSUP_GraphIterator *it = LSUP_graph_add_init_txn (txn, gr);
|
|
|
|
|
|
if (ct) *ct = 0;
|
|
if (ct) *ct = 0;
|
|
// Serialize and insert RDF triples.
|
|
// Serialize and insert RDF triples.
|
|
@@ -331,6 +329,7 @@ LSUP_graph_add (LSUP_Graph *gr, const LSUP_Triple trp[], size_t *ct)
|
|
rc = db_rc;
|
|
rc = db_rc;
|
|
goto finally;
|
|
goto finally;
|
|
}
|
|
}
|
|
|
|
+ log_trace ("Graph size at end of add iter: %lu", LSUP_graph_size (gr));
|
|
}
|
|
}
|
|
|
|
|
|
finally:
|
|
finally:
|
|
@@ -341,9 +340,10 @@ finally:
|
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_remove (
|
|
|
|
- LSUP_Graph *gr, const LSUP_Term *s, const LSUP_Term *p,
|
|
|
|
- const LSUP_Term *o, size_t *ct)
|
|
|
|
|
|
+LSUP_graph_remove_txn (
|
|
|
|
+ void *txn, LSUP_Graph *gr,
|
|
|
|
+ const LSUP_Term *s, const LSUP_Term *p, const LSUP_Term *o,
|
|
|
|
+ size_t *ct)
|
|
{
|
|
{
|
|
LSUP_rc rc;
|
|
LSUP_rc rc;
|
|
|
|
|
|
@@ -354,7 +354,7 @@ LSUP_graph_remove (
|
|
*sc = LSUP_term_serialize (gr->uri);
|
|
*sc = LSUP_term_serialize (gr->uri);
|
|
|
|
|
|
rc = gr->store->sif->remove_fn (
|
|
rc = gr->store->sif->remove_fn (
|
|
- gr->store->data, ss, sp, so, sc, gr->txn, ct);
|
|
|
|
|
|
+ gr->store->data, ss, sp, so, sc, txn, ct);
|
|
|
|
|
|
LSUP_buffer_free (ss);
|
|
LSUP_buffer_free (ss);
|
|
LSUP_buffer_free (sp);
|
|
LSUP_buffer_free (sp);
|
|
@@ -371,14 +371,16 @@ LSUP_graph_remove (
|
|
* The destination graph is not initialized here, so the copy is cumulative.
|
|
* The destination graph is not initialized here, so the copy is cumulative.
|
|
*/
|
|
*/
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_copy_contents (const LSUP_Graph *src, LSUP_Graph *dest)
|
|
|
|
|
|
+LSUP_graph_copy_contents_txn (
|
|
|
|
+ void *txn, const LSUP_Graph *src, LSUP_Graph *dest)
|
|
{
|
|
{
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
LSUP_rc rc = LSUP_NOACTION;
|
|
|
|
|
|
- LSUP_GraphIterator *it = LSUP_graph_lookup (src, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
+ LSUP_GraphIterator *it = LSUP_graph_lookup_txn (
|
|
|
|
+ txn, src, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
LSUP_Triple *spo = NULL;
|
|
LSUP_Triple *spo = NULL;
|
|
- LSUP_GraphIterator *add_it = LSUP_graph_add_init (dest);
|
|
|
|
|
|
+ LSUP_GraphIterator *add_it = LSUP_graph_add_init_txn (txn, dest);
|
|
while (LSUP_graph_iter_next (it, &spo) != LSUP_END) {
|
|
while (LSUP_graph_iter_next (it, &spo) != LSUP_END) {
|
|
LSUP_rc add_rc = LSUP_graph_add_iter (add_it, spo);
|
|
LSUP_rc add_rc = LSUP_graph_add_iter (add_it, spo);
|
|
LSUP_triple_free (spo);
|
|
LSUP_triple_free (spo);
|
|
@@ -397,9 +399,10 @@ LSUP_graph_copy_contents (const LSUP_Graph *src, LSUP_Graph *dest)
|
|
|
|
|
|
|
|
|
|
LSUP_GraphIterator *
|
|
LSUP_GraphIterator *
|
|
-LSUP_graph_lookup (
|
|
|
|
- const LSUP_Graph *gr, const LSUP_Term *s, const LSUP_Term *p,
|
|
|
|
- const LSUP_Term *o, size_t *ct)
|
|
|
|
|
|
+LSUP_graph_lookup_txn (
|
|
|
|
+ void *txn, const LSUP_Graph *gr,
|
|
|
|
+ const LSUP_Term *s, const LSUP_Term *p, const LSUP_Term *o,
|
|
|
|
+ size_t *ct)
|
|
{
|
|
{
|
|
LSUP_GraphIterator *it;
|
|
LSUP_GraphIterator *it;
|
|
MALLOC_GUARD (it, NULL);
|
|
MALLOC_GUARD (it, NULL);
|
|
@@ -411,7 +414,7 @@ LSUP_graph_lookup (
|
|
*sc = LSUP_term_serialize (gr->uri);
|
|
*sc = LSUP_term_serialize (gr->uri);
|
|
|
|
|
|
it->data = gr->store->sif->lookup_fn (
|
|
it->data = gr->store->sif->lookup_fn (
|
|
- gr->store->data, ss, sp, so, sc, gr->txn, ct);
|
|
|
|
|
|
+ gr->store->data, ss, sp, so, sc, txn, ct);
|
|
|
|
|
|
LSUP_buffer_free (ss);
|
|
LSUP_buffer_free (ss);
|
|
LSUP_buffer_free (sp);
|
|
LSUP_buffer_free (sp);
|
|
@@ -489,30 +492,25 @@ LSUP_graph_contains (const LSUP_Graph *gr, const LSUP_Triple *spo)
|
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_begin (LSUP_Graph *gr, int flags) {
|
|
|
|
|
|
+LSUP_graph_begin (LSUP_Graph *gr, int flags, void **txn) {
|
|
if (!(gr->store->sif->features & LSUP_STORE_TXN)) return LSUP_VALUE_ERR;
|
|
if (!(gr->store->sif->features & LSUP_STORE_TXN)) return LSUP_VALUE_ERR;
|
|
|
|
|
|
- return gr->store->sif->txn_begin_fn(gr->store->data, flags, &gr->txn);
|
|
|
|
|
|
+ return gr->store->sif->txn_begin_fn (gr->store->data, flags, txn);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
LSUP_rc
|
|
-LSUP_graph_commit (LSUP_Graph *gr)
|
|
|
|
|
|
+LSUP_graph_commit (LSUP_Graph *gr, void *txn)
|
|
{
|
|
{
|
|
- LSUP_rc rc = gr->store->sif->txn_commit_fn (gr->txn);
|
|
|
|
-
|
|
|
|
- if (rc == LSUP_OK) gr->txn = NULL;
|
|
|
|
|
|
+ if (!(gr->store->sif->features & LSUP_STORE_TXN)) return LSUP_VALUE_ERR;
|
|
|
|
|
|
- return rc;
|
|
|
|
|
|
+ return gr->store->sif->txn_commit_fn (txn);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
void
|
|
-LSUP_graph_abort (LSUP_Graph *gr)
|
|
|
|
-{
|
|
|
|
- gr->store->sif->txn_abort_fn (gr->txn);
|
|
|
|
- gr->txn = NULL;
|
|
|
|
-}
|
|
|
|
|
|
+LSUP_graph_abort (LSUP_Graph *gr, void *txn)
|
|
|
|
+{ return gr->store->sif->txn_abort_fn (txn); }
|
|
|
|
|
|
|
|
|
|
LSUP_LinkMap *
|
|
LSUP_LinkMap *
|
|
@@ -733,4 +731,3 @@ graph_iter_alloc_buffers (LSUP_GraphIterator *it)
|
|
*/
|
|
*/
|
|
|
|
|
|
size_t LSUP_graph_size (const LSUP_Graph *gr);
|
|
size_t LSUP_graph_size (const LSUP_Graph *gr);
|
|
-
|
|
|