|
@@ -327,8 +327,30 @@ LSUP_graph_add_iter (LSUP_GraphIterator *it, const LSUP_Triple *spo)
|
|
|
"Adding triple {%s, %s, %s} to %s",
|
|
|
spo->s->data, spo->p->data, spo->o->data,
|
|
|
LSUP_graph_uri(it->graph)->data);
|
|
|
- LSUP_BufferTriple *sspo = LSUP_triple_serialize (spo);
|
|
|
+
|
|
|
+ // Make relative s and o.
|
|
|
+ LSUP_Term *rel_s, *rel_o;
|
|
|
+ if (LSUP_IS_IRI (spo->s))
|
|
|
+ rel_s = LSUP_iriref_relative (it->graph->uri, spo->s);
|
|
|
+ else rel_s = spo->s;
|
|
|
+ if (LSUP_IS_IRI (spo->o))
|
|
|
+ rel_o = LSUP_iriref_relative (it->graph->uri, spo->o);
|
|
|
+ else rel_o = spo->o;
|
|
|
+
|
|
|
+ LSUP_Triple *rel_spo = LSUP_triple_new (rel_s, spo->p, rel_o);
|
|
|
+ LOG_TRACE (
|
|
|
+ "Relative triple: {%s %s %s}",
|
|
|
+ rel_s->data, spo->p->data, rel_o->data);
|
|
|
+
|
|
|
+ // Serialize relative triple.
|
|
|
+ LSUP_BufferTriple *sspo = LSUP_triple_serialize (rel_spo);
|
|
|
if (UNLIKELY (!sspo)) return LSUP_MEM_ERR;
|
|
|
+
|
|
|
+ // Selectively free triple members and structure.
|
|
|
+ if (rel_s != spo->s) LSUP_term_free (rel_s);
|
|
|
+ if (rel_o != spo->o) LSUP_term_free (rel_o);
|
|
|
+ free (rel_spo);
|
|
|
+
|
|
|
const LSUP_StoreInt *sif = it->graph->store->sif;
|
|
|
|
|
|
LSUP_rc rc;
|
|
@@ -460,12 +482,25 @@ LSUP_graph_lookup_txn (
|
|
|
LSUP_GraphIterator *it;
|
|
|
MALLOC_GUARD (it, NULL);
|
|
|
|
|
|
+ // Make relative s and o.
|
|
|
+ LSUP_Term *rel_s, *rel_o;
|
|
|
+ if (s && LSUP_IS_IRI (s))
|
|
|
+ rel_s = LSUP_iriref_relative (gr->uri, s);
|
|
|
+ else rel_s = (LSUP_Term *)s;
|
|
|
+ if (o && LSUP_IS_IRI (o))
|
|
|
+ rel_o = LSUP_iriref_relative (gr->uri, o);
|
|
|
+ else rel_o = (LSUP_Term *)o;
|
|
|
+
|
|
|
LSUP_Buffer
|
|
|
- *ss = LSUP_term_serialize (s),
|
|
|
+ *ss = LSUP_term_serialize (rel_s),
|
|
|
*sp = LSUP_term_serialize (p),
|
|
|
- *so = LSUP_term_serialize (o),
|
|
|
+ *so = LSUP_term_serialize (rel_o),
|
|
|
*sc = LSUP_term_serialize (gr->uri);
|
|
|
|
|
|
+ // Selectively free triple members and structure.
|
|
|
+ if (rel_s != s) LSUP_term_free (rel_s);
|
|
|
+ if (rel_o != o) LSUP_term_free (rel_o);
|
|
|
+
|
|
|
it->data = gr->store->sif->lookup_fn (
|
|
|
gr->store->data, ss, sp, so, sc, txn, ct);
|
|
|
|
|
@@ -482,7 +517,7 @@ LSUP_graph_lookup_txn (
|
|
|
it->graph = gr;
|
|
|
|
|
|
if (it->graph->store->sif->features & LSUP_STORE_COW) {
|
|
|
- // Copy-on-wite store.
|
|
|
+ // Copy-on-write store.
|
|
|
it->sspo = BTRP_DUMMY;
|
|
|
if (UNLIKELY (it->sspo == NULL)) return NULL;
|
|
|
it->sspo->s->flags |= LSUP_BUF_BORROWED;
|