|
@@ -357,7 +357,7 @@ LSUP_mdbstore_add_init (LSUP_MDBStore *store, const LSUP_Buffer *sc)
|
|
if (store->default_ctx != NULL) {
|
|
if (store->default_ctx != NULL) {
|
|
if (sc == NULL) sc = store->default_ctx;
|
|
if (sc == NULL) sc = store->default_ctx;
|
|
|
|
|
|
- it->ck = LSUP_sterm_to_key (sc);
|
|
|
|
|
|
+ it->ck = LSUP_buffer_hash (sc);
|
|
|
|
|
|
// Insert t:st for context.
|
|
// Insert t:st for context.
|
|
//TRACE ("Adding context: %s", sc);
|
|
//TRACE ("Adding context: %s", sc);
|
|
@@ -393,7 +393,7 @@ LSUP_mdbstore_add_iter (MDBIterator *it, const LSUP_SerTriple *sspo)
|
|
printf ("\n");
|
|
printf ("\n");
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- spok[i] = LSUP_sterm_to_key (st);
|
|
|
|
|
|
+ spok[i] = LSUP_buffer_hash (st);
|
|
|
|
|
|
it->key.mv_data = spok + i;
|
|
it->key.mv_data = spok + i;
|
|
it->key.mv_size = KLEN;
|
|
it->key.mv_size = KLEN;
|
|
@@ -496,7 +496,7 @@ sterm_to_key (
|
|
LSUP_MDBStore *store, const LSUP_Buffer *sterm)
|
|
LSUP_MDBStore *store, const LSUP_Buffer *sterm)
|
|
{
|
|
{
|
|
// TODO this will be replaced by a lookup when 128-bit hash is introduced.
|
|
// TODO this will be replaced by a lookup when 128-bit hash is introduced.
|
|
- return LSUP_sterm_to_key (sterm);
|
|
|
|
|
|
+ return LSUP_buffer_hash (sterm);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -543,16 +543,16 @@ LSUP_mdbstore_lookup(
|
|
const LSUP_Buffer *sc, size_t *ct)
|
|
const LSUP_Buffer *sc, size_t *ct)
|
|
{
|
|
{
|
|
LSUP_TripleKey spok = {
|
|
LSUP_TripleKey spok = {
|
|
- LSUP_sterm_to_key (sspo->s),
|
|
|
|
- LSUP_sterm_to_key (sspo->p),
|
|
|
|
- LSUP_sterm_to_key (sspo->o),
|
|
|
|
|
|
+ LSUP_buffer_hash (sspo->s),
|
|
|
|
+ LSUP_buffer_hash (sspo->p),
|
|
|
|
+ LSUP_buffer_hash (sspo->o),
|
|
};
|
|
};
|
|
|
|
|
|
LSUP_MDBIterator *it = malloc (sizeof (*it));
|
|
LSUP_MDBIterator *it = malloc (sizeof (*it));
|
|
if (UNLIKELY (!it)) return NULL;
|
|
if (UNLIKELY (!it)) return NULL;
|
|
|
|
|
|
it->store = store;
|
|
it->store = store;
|
|
- it->ck = store->default_ctx ? LSUP_sterm_to_key (sc) : NULL_KEY;
|
|
|
|
|
|
+ it->ck = store->default_ctx ? LSUP_buffer_hash (sc) : NULL_KEY;
|
|
|
|
|
|
if (ct) *ct = 0;
|
|
if (ct) *ct = 0;
|
|
|
|
|
|
@@ -625,7 +625,6 @@ mdbiter_next_key (LSUP_MDBIterator *it)
|
|
|
|
|
|
LSUP_rc rc;
|
|
LSUP_rc rc;
|
|
|
|
|
|
- it->i++;
|
|
|
|
it->iter_op_fn (it);
|
|
it->iter_op_fn (it);
|
|
|
|
|
|
if (it->ck) {
|
|
if (it->ck) {
|
|
@@ -723,7 +722,7 @@ LSUP_mdbstore_remove(
|
|
|
|
|
|
if (store->default_ctx != NULL) {
|
|
if (store->default_ctx != NULL) {
|
|
if (sc == NULL) sc = store->default_ctx;
|
|
if (sc == NULL) sc = store->default_ctx;
|
|
- ck = LSUP_sterm_to_key (sc);
|
|
|
|
|
|
+ ck = LSUP_buffer_hash (sc);
|
|
}
|
|
}
|
|
|
|
|
|
MDB_txn *txn;
|
|
MDB_txn *txn;
|
|
@@ -944,7 +943,7 @@ it_next_1bound (MDBIterator *it)
|
|
it->spok[it->term_order[2]] = lu_dset[it->i][1];
|
|
it->spok[it->term_order[2]] = lu_dset[it->i][1];
|
|
|
|
|
|
TRACE(
|
|
TRACE(
|
|
- "Composed triple: {%lu %lu %lu}",
|
|
|
|
|
|
+ "Composed triple: {%lx %lx %lx}",
|
|
it->spok[0], it->spok[1], it->spok[2]);
|
|
it->spok[0], it->spok[1], it->spok[2]);
|
|
|
|
|
|
// Ensure next block within the same page is not beyond the last.
|
|
// Ensure next block within the same page is not beyond the last.
|
|
@@ -958,7 +957,8 @@ it_next_1bound (MDBIterator *it)
|
|
// move cursor to beginning of next page.
|
|
// move cursor to beginning of next page.
|
|
it->i = 0;
|
|
it->i = 0;
|
|
TRACE ("Reset page cursor to %lu.", it->i);
|
|
TRACE ("Reset page cursor to %lu.", it->i);
|
|
- it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_NEXT_MULTIPLE);
|
|
|
|
|
|
+ it->rc = mdb_cursor_get (
|
|
|
|
+ it->cur, &it->key, &it->data, MDB_NEXT_MULTIPLE);
|
|
TRACE ("it->rc: %d", it->rc);
|
|
TRACE ("it->rc: %d", it->rc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1056,7 +1056,7 @@ lookup_1bound (MDBStore *store, uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
{
|
|
{
|
|
it->term_order = (const uint8_t*)lookup_ordering_1bound[idx0];
|
|
it->term_order = (const uint8_t*)lookup_ordering_1bound[idx0];
|
|
|
|
|
|
- TRACE ("Looking up 1 bound term: %lu\n", it->luk[0]);
|
|
|
|
|
|
+ TRACE ("Looking up 1 bound term: %lx\n", it->luk[0]);
|
|
|
|
|
|
if (!it->txn) {
|
|
if (!it->txn) {
|
|
if (store->txn) it->txn = store->txn;
|
|
if (store->txn) it->txn = store->txn;
|
|
@@ -1075,6 +1075,7 @@ lookup_1bound (MDBStore *store, uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
// If a context is specified, the only way to count triples matching
|
|
// If a context is specified, the only way to count triples matching
|
|
// the context is to loop over them.
|
|
// the context is to loop over them.
|
|
if (it->ck != NULL_KEY) {
|
|
if (it->ck != NULL_KEY) {
|
|
|
|
+ TRACE ("Counting in context: %lx\n", it->ck);
|
|
MDBIterator *ct_it = malloc (sizeof (MDBIterator));
|
|
MDBIterator *ct_it = malloc (sizeof (MDBIterator));
|
|
if (UNLIKELY (!ct_it)) return LSUP_MEM_ERR;
|
|
if (UNLIKELY (!ct_it)) return LSUP_MEM_ERR;
|
|
|
|
|
|
@@ -1089,10 +1090,12 @@ lookup_1bound (MDBStore *store, uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
ct_it->key = it->key;
|
|
ct_it->key = it->key;
|
|
ct_it->data = it->data;
|
|
ct_it->data = it->data;
|
|
ct_it->i = 0;
|
|
ct_it->i = 0;
|
|
- lookup_1bound (store, idx0, ct_it, NULL);
|
|
|
|
|
|
+
|
|
|
|
+ LSUP_rc rc = lookup_1bound (store, idx0, ct_it, NULL);
|
|
|
|
+ if (rc < 0) return rc;
|
|
|
|
|
|
while (LSUP_mdbiter_next (ct_it, NULL) != LSUP_END) {
|
|
while (LSUP_mdbiter_next (ct_it, NULL) != LSUP_END) {
|
|
- ct[0] ++;
|
|
|
|
|
|
+ (*ct)++;
|
|
TRACE ("Counter increased to %lu.", *ct);
|
|
TRACE ("Counter increased to %lu.", *ct);
|
|
}
|
|
}
|
|
|
|
|