|
@@ -159,12 +159,14 @@ graph_copy_contents (const LSUP_Graph *src, LSUP_Graph *dest)
|
|
|
|
|
|
LSUP_SerTriple sspo;
|
|
|
|
|
|
+ LSUP_GraphIterator *add_it = LSUP_graph_add_init (dest);
|
|
|
while (graph_iter_next_buffer (it, &sspo) != LSUP_END) {
|
|
|
TRACE ("Inserting triple #%lu\n", LSUP_graph_iter_cur (it));
|
|
|
- LSUP_rc add_rc = LSUP_graph_add (dest, NULL, 0, &sspo, 1, NULL);
|
|
|
+ LSUP_rc add_rc = LSUP_graph_add_iter (add_it, &sspo);
|
|
|
if (LIKELY (add_rc == LSUP_OK)) rc = LSUP_OK;
|
|
|
else if (add_rc < 0) return add_rc;
|
|
|
}
|
|
|
+ LSUP_graph_add_done (it);
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
@@ -316,10 +318,9 @@ LSUP_graph_add_done (LSUP_GraphIterator *it)
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
|
-LSUP_graph_add(
|
|
|
- LSUP_Graph *gr,
|
|
|
- const LSUP_Triple trp[], size_t trp_ct,
|
|
|
- const LSUP_SerTriple strp[], size_t strp_ct, size_t *inserted)
|
|
|
+LSUP_graph_add (
|
|
|
+ Graph *gr, const LSUP_Triple trp[],
|
|
|
+ const LSUP_SerTriple strp[], size_t *inserted)
|
|
|
{
|
|
|
/*
|
|
|
* NOTE It is possible to pass both sets of RDF triples and buffer triples.
|
|
@@ -334,24 +335,28 @@ LSUP_graph_add(
|
|
|
LSUP_SerTriple *sspo = LSUP_striple_new (BUF_DUMMY, BUF_DUMMY, BUF_DUMMY);
|
|
|
if (UNLIKELY (!sspo)) return LSUP_MEM_ERR;
|
|
|
|
|
|
- for (size_t i = 0; i < trp_ct; i++) {
|
|
|
- TRACE ("Inserting triple #%lu\n", i);
|
|
|
+ if (trp) {
|
|
|
+ for (size_t i = 0; trp[i].s != NULL; i++) {
|
|
|
+ TRACE ("Inserting triple #%lu\n", i);
|
|
|
|
|
|
- LSUP_triple_serialize (trp + i, sspo);
|
|
|
- LSUP_rc db_rc = LSUP_graph_add_iter (it, sspo);
|
|
|
+ LSUP_triple_serialize (trp + i, sspo);
|
|
|
+ LSUP_rc db_rc = LSUP_graph_add_iter (it, sspo);
|
|
|
|
|
|
- if (db_rc == LSUP_OK) rc = LSUP_OK;
|
|
|
- if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
|
+ if (db_rc == LSUP_OK) rc = LSUP_OK;
|
|
|
+ if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
|
+ }
|
|
|
}
|
|
|
LSUP_striple_free (sspo);
|
|
|
|
|
|
// Insert serialized triples.
|
|
|
- for (size_t i = 0; i < strp_ct; i++) {
|
|
|
- TRACE ("Inserting serialized triple #%lu\n", i);
|
|
|
- LSUP_rc db_rc = LSUP_graph_add_iter (it, strp + i);
|
|
|
+ if (strp) {
|
|
|
+ for (size_t i = 0; strp[i].s != NULL; i++) {
|
|
|
+ TRACE ("Inserting serialized triple #%lu\n", i);
|
|
|
+ LSUP_rc db_rc = LSUP_graph_add_iter (it, strp + i);
|
|
|
|
|
|
- if (db_rc == LSUP_OK) rc = LSUP_OK;
|
|
|
- if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
|
+ if (db_rc == LSUP_OK) rc = LSUP_OK;
|
|
|
+ if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (inserted) {
|