|
@@ -1,4 +1,4 @@
|
|
-#include "lsup/store_mdb.h"
|
|
|
|
|
|
+#include "volksdata/store_mdb.h"
|
|
|
|
|
|
/**
|
|
/**
|
|
* Number of DBs defined. See MAIN_TABLE and LOOKUP_TABLE defines below.
|
|
* Number of DBs defined. See MAIN_TABLE and LOOKUP_TABLE defines below.
|
|
@@ -80,15 +80,15 @@ typedef struct mdbstore_iter_t {
|
|
MDB_cursor * ctx_cur; ///< MDB c:spo index cursor.
|
|
MDB_cursor * ctx_cur; ///< MDB c:spo index cursor.
|
|
MDB_val key; ///< Internal data handler.
|
|
MDB_val key; ///< Internal data handler.
|
|
MDB_val data; ///< Internal data handler.
|
|
MDB_val data; ///< Internal data handler.
|
|
- LSUP_TripleKey spok; ///< Triple to be populated with match.
|
|
|
|
- LSUP_Key * ck; /**< Context array.
|
|
|
|
|
|
+ VOLK_TripleKey spok; ///< Triple to be populated with match.
|
|
|
|
+ VOLK_Key * ck; /**< Context array.
|
|
*
|
|
*
|
|
* This shall be populated for each
|
|
* This shall be populated for each
|
|
* matching triple if requested. */
|
|
* matching triple if requested. */
|
|
iter_op_fn_t iter_op_fn; ///< Function used to look up next match.
|
|
iter_op_fn_t iter_op_fn; ///< Function used to look up next match.
|
|
const uint8_t * term_order; ///< Term order used in 1-2bound look-ups.
|
|
const uint8_t * term_order; ///< Term order used in 1-2bound look-ups.
|
|
- LSUP_Key luk[3]; ///< 0÷3 lookup keys.
|
|
|
|
- LSUP_Key luc; ///< Ctx key to filter by. May be NULL_KEY.
|
|
|
|
|
|
+ VOLK_Key luk[3]; ///< 0÷3 lookup keys.
|
|
|
|
+ VOLK_Key luc; ///< Ctx key to filter by. May be NULL_KEY.
|
|
size_t i; ///< Internal counter for paged lookups.
|
|
size_t i; ///< Internal counter for paged lookups.
|
|
size_t ct; ///< Current count of records inserted or
|
|
size_t ct; ///< Current count of records inserted or
|
|
///< results found.
|
|
///< results found.
|
|
@@ -197,27 +197,27 @@ static const uint8_t lookup_ordering_2bound[3][3] = {
|
|
* Static prototypes.
|
|
* Static prototypes.
|
|
*/
|
|
*/
|
|
static int index_triple(
|
|
static int index_triple(
|
|
- MDBStore *store, StoreOp op, LSUP_TripleKey spok, LSUP_Key ck,
|
|
|
|
|
|
+ MDBStore *store, StoreOp op, VOLK_TripleKey spok, VOLK_Key ck,
|
|
MDB_txn *txn);
|
|
MDB_txn *txn);
|
|
-static LSUP_rc mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th);
|
|
|
|
|
|
+static VOLK_rc mdbstore_add_term (void *h, const VOLK_Buffer *sterm, void *th);
|
|
|
|
|
|
-inline static LSUP_rc lookup_0bound (MDBIterator *it, size_t *ct);
|
|
|
|
-inline static LSUP_rc lookup_1bound (
|
|
|
|
|
|
+inline static VOLK_rc lookup_0bound (MDBIterator *it, size_t *ct);
|
|
|
|
+inline static VOLK_rc lookup_1bound (
|
|
uint8_t idx0, MDBIterator *it, size_t *ct);
|
|
uint8_t idx0, MDBIterator *it, size_t *ct);
|
|
-inline static LSUP_rc lookup_2bound (
|
|
|
|
|
|
+inline static VOLK_rc lookup_2bound (
|
|
uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct);
|
|
uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct);
|
|
-inline static LSUP_rc lookup_3bound(MDBIterator *it, size_t *ct);
|
|
|
|
|
|
+inline static VOLK_rc lookup_3bound(MDBIterator *it, size_t *ct);
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
static const char *
|
|
mdbstore_path_from_id (const char *id)
|
|
mdbstore_path_from_id (const char *id)
|
|
{
|
|
{
|
|
// Set environment path.
|
|
// Set environment path.
|
|
- if (!id) id = getenv ("LSUP_MDB_STORE_URN");
|
|
|
|
|
|
+ if (!id) id = getenv ("VOLK_MDB_STORE_URN");
|
|
if (!id) {
|
|
if (!id) {
|
|
- id = LSUP_MDB_STORE_URN;
|
|
|
|
|
|
+ id = VOLK_MDB_STORE_URN;
|
|
log_info (
|
|
log_info (
|
|
- "`LSUP_MDB_STORE_URN' environment variable is not "
|
|
|
|
|
|
+ "`VOLK_MDB_STORE_URN' environment variable is not "
|
|
"set. The default URN %s has been set as the store ID.", id
|
|
"set. The default URN %s has been set as the store ID.", id
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -237,18 +237,18 @@ mdbstore_path_from_id (const char *id)
|
|
*
|
|
*
|
|
* This function takes care of creating the environment path if not existing,
|
|
* This function takes care of creating the environment path if not existing,
|
|
* and checking that it's a writable directory. If the path is not specified
|
|
* and checking that it's a writable directory. If the path is not specified
|
|
- * in the LSUP_MDB_STORE_URN environment variable, a default directory is used.
|
|
|
|
|
|
+ * in the VOLK_MDB_STORE_URN environment variable, a default directory is used.
|
|
*/
|
|
*/
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_setup (const char *id, bool clear)
|
|
mdbstore_setup (const char *id, bool clear)
|
|
{
|
|
{
|
|
const char *path = mdbstore_path_from_id (id);
|
|
const char *path = mdbstore_path_from_id (id);
|
|
- if (!path) return LSUP_VALUE_ERR;
|
|
|
|
|
|
+ if (!path) return VOLK_VALUE_ERR;
|
|
|
|
|
|
// If the directory exists (unless clear == true), do nothing.
|
|
// If the directory exists (unless clear == true), do nothing.
|
|
if (clear) rm_r (path);
|
|
if (clear) rm_r (path);
|
|
- LSUP_rc rc = mkdir_p (path, ENV_DIR_MODE);
|
|
|
|
- log_info ("Create dir rc: %s", LSUP_strerror (rc));
|
|
|
|
|
|
+ VOLK_rc rc = mkdir_p (path, ENV_DIR_MODE);
|
|
|
|
+ log_info ("Create dir rc: %s", VOLK_strerror (rc));
|
|
PRCCK (rc);
|
|
PRCCK (rc);
|
|
|
|
|
|
// Open a temporary environment and txn to create the DBs.
|
|
// Open a temporary environment and txn to create the DBs.
|
|
@@ -280,25 +280,25 @@ mdbstore_setup (const char *id, bool clear)
|
|
// Index default context.
|
|
// Index default context.
|
|
MDB_cursor *cur;
|
|
MDB_cursor *cur;
|
|
CHECK (mdb_cursor_open (txn, dbi, &cur), fail);
|
|
CHECK (mdb_cursor_open (txn, dbi, &cur), fail);
|
|
- LSUP_Key k = LSUP_buffer_hash (LSUP_default_ctx_buf);
|
|
|
|
|
|
+ VOLK_Key k = VOLK_buffer_hash (VOLK_default_ctx_buf);
|
|
MDB_val key, data;
|
|
MDB_val key, data;
|
|
key.mv_data = &k;
|
|
key.mv_data = &k;
|
|
key.mv_size = sizeof (k);
|
|
key.mv_size = sizeof (k);
|
|
|
|
|
|
- data.mv_data = LSUP_default_ctx_buf->addr;
|
|
|
|
- data.mv_size = LSUP_default_ctx_buf->size;
|
|
|
|
|
|
+ data.mv_data = VOLK_default_ctx_buf->addr;
|
|
|
|
+ data.mv_size = VOLK_default_ctx_buf->size;
|
|
|
|
|
|
- LSUP_rc db_rc = mdb_cursor_put (cur, &key, &data, 0);
|
|
|
|
|
|
+ VOLK_rc db_rc = mdb_cursor_put (cur, &key, &data, 0);
|
|
CHECK (db_rc, fail);
|
|
CHECK (db_rc, fail);
|
|
}
|
|
}
|
|
|
|
|
|
mdb_txn_commit (txn);
|
|
mdb_txn_commit (txn);
|
|
mdb_env_close (env);
|
|
mdb_env_close (env);
|
|
|
|
|
|
- return clear ? LSUP_OK : rc;
|
|
|
|
|
|
+ return clear ? VOLK_OK : rc;
|
|
|
|
|
|
fail:
|
|
fail:
|
|
- if (rc >= 0) rc = LSUP_DB_ERR;
|
|
|
|
|
|
+ if (rc >= 0) rc = VOLK_DB_ERR;
|
|
mdb_txn_abort (txn);
|
|
mdb_txn_abort (txn);
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
@@ -310,7 +310,7 @@ fail:
|
|
*
|
|
*
|
|
* Some environment variables affect various store parameters:
|
|
* Some environment variables affect various store parameters:
|
|
*
|
|
*
|
|
- * - LSUP_MDB_MAPSIZE Long int specifying the size of the memory map. Usually
|
|
|
|
|
|
+ * - VOLK_MDB_MAPSIZE Long int specifying the size of the memory map. Usually
|
|
* it is not necessary to modify this, unless one is operating under memory
|
|
* it is not necessary to modify this, unless one is operating under memory
|
|
* and disk constraints. The default map size is 1Tb.
|
|
* and disk constraints. The default map size is 1Tb.
|
|
*/
|
|
*/
|
|
@@ -329,7 +329,7 @@ mdbstore_new (const char *id, size_t _unused)
|
|
|
|
|
|
// Set map size.
|
|
// Set map size.
|
|
size_t mapsize;
|
|
size_t mapsize;
|
|
- char *env_mapsize = getenv ("LSUP_MDB_MAPSIZE");
|
|
|
|
|
|
+ char *env_mapsize = getenv ("VOLK_MDB_MAPSIZE");
|
|
if (env_mapsize == NULL) mapsize = DEFAULT_MAPSIZE;
|
|
if (env_mapsize == NULL) mapsize = DEFAULT_MAPSIZE;
|
|
else sscanf (env_mapsize, "%zu", &mapsize);
|
|
else sscanf (env_mapsize, "%zu", &mapsize);
|
|
log_info (
|
|
log_info (
|
|
@@ -387,7 +387,7 @@ mdbstore_id (const void *h)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_stat (const MDBStore *store, MDB_stat *stat)
|
|
mdbstore_stat (const MDBStore *store, MDB_stat *stat)
|
|
{
|
|
{
|
|
if (!(store->flags & LSSTORE_OPEN)) return 0;
|
|
if (!(store->flags & LSSTORE_OPEN)) return 0;
|
|
@@ -396,10 +396,10 @@ mdbstore_stat (const MDBStore *store, MDB_stat *stat)
|
|
mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn);
|
|
mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn);
|
|
|
|
|
|
if (mdb_stat (txn, store->dbi[IDX_SPO_C], stat) != MDB_SUCCESS)
|
|
if (mdb_stat (txn, store->dbi[IDX_SPO_C], stat) != MDB_SUCCESS)
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ return VOLK_DB_ERR;
|
|
mdb_txn_abort (txn);
|
|
mdb_txn_abort (txn);
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -410,29 +410,29 @@ mdbstore_size (const void *h)
|
|
// Size is calculated outside of any pending write txn.
|
|
// Size is calculated outside of any pending write txn.
|
|
|
|
|
|
MDB_stat stat;
|
|
MDB_stat stat;
|
|
- if (mdbstore_stat (store, &stat) != LSUP_OK) return 0;
|
|
|
|
|
|
+ if (mdbstore_stat (store, &stat) != VOLK_OK) return 0;
|
|
|
|
|
|
return stat.ms_entries;
|
|
return stat.ms_entries;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_txn_begin (void *h, int flags, void **th)
|
|
mdbstore_txn_begin (void *h, int flags, void **th)
|
|
{
|
|
{
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
|
|
|
|
RCCK (mdb_txn_begin (store->env, NULL, flags, (MDB_txn **) th));
|
|
RCCK (mdb_txn_begin (store->env, NULL, flags, (MDB_txn **) th));
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_txn_commit (void *th)
|
|
mdbstore_txn_commit (void *th)
|
|
{
|
|
{
|
|
RCCK (mdb_txn_commit ((MDB_txn *) th));
|
|
RCCK (mdb_txn_commit ((MDB_txn *) th));
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -457,7 +457,7 @@ mdbiter_txn (void *h)
|
|
* NULL, the loop transaction will have the passed txn set as its parent.
|
|
* NULL, the loop transaction will have the passed txn set as its parent.
|
|
*/
|
|
*/
|
|
static void *
|
|
static void *
|
|
-mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
|
|
|
|
|
|
+mdbstore_add_init (void *h, const VOLK_Buffer *sc, void *th)
|
|
{
|
|
{
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
/* An iterator is used here. Some members are a bit misused but it does
|
|
/* An iterator is used here. Some members are a bit misused but it does
|
|
@@ -473,7 +473,7 @@ mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
|
|
|
|
|
|
if (sc) {
|
|
if (sc) {
|
|
// Store context if it's not the default one.
|
|
// Store context if it's not the default one.
|
|
- it->luc = LSUP_buffer_hash (sc);
|
|
|
|
|
|
+ it->luc = VOLK_buffer_hash (sc);
|
|
|
|
|
|
// Insert t:st for context.
|
|
// Insert t:st for context.
|
|
//LOG_DEBUG("Adding context: %s", sc);
|
|
//LOG_DEBUG("Adding context: %s", sc);
|
|
@@ -486,13 +486,13 @@ mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
|
|
it->txn, it->store->dbi[IDX_T_ST],
|
|
it->txn, it->store->dbi[IDX_T_ST],
|
|
&it->key, &it->data, MDB_NOOVERWRITE);
|
|
&it->key, &it->data, MDB_NOOVERWRITE);
|
|
if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
|
|
if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
|
|
- log_error (LSUP_strerror (db_rc));
|
|
|
|
|
|
+ log_error (VOLK_strerror (db_rc));
|
|
mdb_txn_abort (it->txn);
|
|
mdb_txn_abort (it->txn);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
LOG_DEBUG("No context passed to iterator, using default.");
|
|
LOG_DEBUG("No context passed to iterator, using default.");
|
|
- it->luc = LSUP_buffer_hash (LSUP_default_ctx_buf);
|
|
|
|
|
|
+ it->luc = VOLK_buffer_hash (VOLK_default_ctx_buf);
|
|
}
|
|
}
|
|
|
|
|
|
return it;
|
|
return it;
|
|
@@ -510,20 +510,20 @@ fail:
|
|
* #mdbstore_add_abort or #mdbstore_add_done. FIXME
|
|
* #mdbstore_add_abort or #mdbstore_add_done. FIXME
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
-static LSUP_rc
|
|
|
|
-mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
|
|
|
|
|
|
+static VOLK_rc
|
|
|
|
+mdbstore_add_iter (void *h, const VOLK_BufferTriple *sspo)
|
|
{
|
|
{
|
|
- if (UNLIKELY (!h)) return LSUP_VALUE_ERR;
|
|
|
|
|
|
+ if (UNLIKELY (!h)) return VOLK_VALUE_ERR;
|
|
|
|
|
|
MDBIterator *it = h;
|
|
MDBIterator *it = h;
|
|
- int db_rc = LSUP_NOACTION;
|
|
|
|
- LSUP_TripleKey spok = NULL_TRP;
|
|
|
|
|
|
+ int db_rc = VOLK_NOACTION;
|
|
|
|
+ VOLK_TripleKey spok = NULL_TRP;
|
|
|
|
|
|
// Add triple terms.
|
|
// Add triple terms.
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|
|
- LSUP_Buffer *st = LSUP_btriple_pos (sspo, i);
|
|
|
|
|
|
+ VOLK_Buffer *st = VOLK_btriple_pos (sspo, i);
|
|
|
|
|
|
- spok[i] = LSUP_buffer_hash (st);
|
|
|
|
|
|
+ spok[i] = VOLK_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;
|
|
@@ -535,7 +535,7 @@ mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
|
|
&it->key, &it->data, MDB_NOOVERWRITE);
|
|
&it->key, &it->data, MDB_NOOVERWRITE);
|
|
if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
|
|
if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
|
|
LOG_RC (db_rc);
|
|
LOG_RC (db_rc);
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -554,30 +554,30 @@ mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
|
|
it->txn, it->store->dbi[IDX_SPO_C],
|
|
it->txn, it->store->dbi[IDX_SPO_C],
|
|
&it->key, &it->data, MDB_NODUPDATA);
|
|
&it->key, &it->data, MDB_NODUPDATA);
|
|
|
|
|
|
- if (db_rc == MDB_KEYEXIST) return LSUP_NOACTION;
|
|
|
|
|
|
+ if (db_rc == MDB_KEYEXIST) return VOLK_NOACTION;
|
|
if (db_rc != MDB_SUCCESS) {
|
|
if (db_rc != MDB_SUCCESS) {
|
|
log_error (
|
|
log_error (
|
|
- "MDB error while inserting triple: %s", LSUP_strerror(db_rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ "MDB error while inserting triple: %s", VOLK_strerror(db_rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
// Index.
|
|
// Index.
|
|
- LSUP_rc rc = index_triple (it->store, OP_ADD, spok, it->luc, it->txn);
|
|
|
|
- if (rc == LSUP_OK) it->i++;
|
|
|
|
|
|
+ VOLK_rc rc = index_triple (it->store, OP_ADD, spok, it->luc, it->txn);
|
|
|
|
+ if (rc == VOLK_OK) it->i++;
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_add_done (void *h)
|
|
mdbstore_add_done (void *h)
|
|
{
|
|
{
|
|
MDBIterator *it = h;
|
|
MDBIterator *it = h;
|
|
- LSUP_rc rc = LSUP_OK;
|
|
|
|
|
|
+ VOLK_rc rc = VOLK_OK;
|
|
|
|
|
|
if (mdb_txn_commit (it->txn) != MDB_SUCCESS) {
|
|
if (mdb_txn_commit (it->txn) != MDB_SUCCESS) {
|
|
mdb_txn_abort (it->txn);
|
|
mdb_txn_abort (it->txn);
|
|
- rc = LSUP_TXN_ERR;
|
|
|
|
|
|
+ rc = VOLK_TXN_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
free (it);
|
|
free (it);
|
|
@@ -596,11 +596,11 @@ mdbstore_add_abort (void *h)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
key_to_sterm (
|
|
key_to_sterm (
|
|
- MDBStore *store, MDB_txn *txn, const LSUP_Key key, LSUP_Buffer *sterm)
|
|
|
|
|
|
+ MDBStore *store, MDB_txn *txn, const VOLK_Key key, VOLK_Buffer *sterm)
|
|
{
|
|
{
|
|
- LSUP_rc rc = LSUP_NORESULT;
|
|
|
|
|
|
+ VOLK_rc rc = VOLK_NORESULT;
|
|
int db_rc;
|
|
int db_rc;
|
|
|
|
|
|
MDB_val key_v, data_v;
|
|
MDB_val key_v, data_v;
|
|
@@ -609,15 +609,15 @@ key_to_sterm (
|
|
|
|
|
|
db_rc = mdb_get (txn, store->dbi[IDX_T_ST], &key_v, &data_v);
|
|
db_rc = mdb_get (txn, store->dbi[IDX_T_ST], &key_v, &data_v);
|
|
|
|
|
|
- sterm->flags |= LSUP_BUF_BORROWED;
|
|
|
|
|
|
+ sterm->flags |= VOLK_BUF_BORROWED;
|
|
if (db_rc == MDB_SUCCESS) {
|
|
if (db_rc == MDB_SUCCESS) {
|
|
sterm->addr = data_v.mv_data;
|
|
sterm->addr = data_v.mv_data;
|
|
sterm->size = data_v.mv_size;
|
|
sterm->size = data_v.mv_size;
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ rc = VOLK_OK;
|
|
} else if (db_rc == MDB_NOTFOUND) {
|
|
} else if (db_rc == MDB_NOTFOUND) {
|
|
sterm->addr = NULL;
|
|
sterm->addr = NULL;
|
|
sterm->size = 0;
|
|
sterm->size = 0;
|
|
- } else rc = LSUP_DB_ERR;
|
|
|
|
|
|
+ } else rc = VOLK_DB_ERR;
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
@@ -625,20 +625,20 @@ key_to_sterm (
|
|
|
|
|
|
static void *
|
|
static void *
|
|
mdbstore_lookup (
|
|
mdbstore_lookup (
|
|
- void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
|
|
|
|
- const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
|
|
|
|
|
|
+ void *h, const VOLK_Buffer *ss, const VOLK_Buffer *sp,
|
|
|
|
+ const VOLK_Buffer *so, const VOLK_Buffer *sc, void *th, size_t *ct)
|
|
{
|
|
{
|
|
- LSUP_TripleKey spok = {
|
|
|
|
- LSUP_buffer_hash (ss),
|
|
|
|
- LSUP_buffer_hash (sp),
|
|
|
|
- LSUP_buffer_hash (so),
|
|
|
|
|
|
+ VOLK_TripleKey spok = {
|
|
|
|
+ VOLK_buffer_hash (ss),
|
|
|
|
+ VOLK_buffer_hash (sp),
|
|
|
|
+ VOLK_buffer_hash (so),
|
|
};
|
|
};
|
|
|
|
|
|
MDBIterator *it;
|
|
MDBIterator *it;
|
|
CALLOC_GUARD (it, NULL);
|
|
CALLOC_GUARD (it, NULL);
|
|
|
|
|
|
it->store = h;
|
|
it->store = h;
|
|
- it->luc = LSUP_buffer_hash (sc);
|
|
|
|
|
|
+ it->luc = VOLK_buffer_hash (sc);
|
|
LOG_DEBUG("Lookup context: %lx", it->luc);
|
|
LOG_DEBUG("Lookup context: %lx", it->luc);
|
|
|
|
|
|
if (ct) *ct = 0;
|
|
if (ct) *ct = 0;
|
|
@@ -650,7 +650,7 @@ mdbstore_lookup (
|
|
// Start RO transaction if not in a write txn already.
|
|
// Start RO transaction if not in a write txn already.
|
|
it->rc = mdb_txn_begin (it->store->env, NULL, MDB_RDONLY, &it->txn);
|
|
it->rc = mdb_txn_begin (it->store->env, NULL, MDB_RDONLY, &it->txn);
|
|
if (it->rc != MDB_SUCCESS) {
|
|
if (it->rc != MDB_SUCCESS) {
|
|
- log_error ("Database error in lookup: %s", LSUP_strerror (it->rc));
|
|
|
|
|
|
+ log_error ("Database error in lookup: %s", VOLK_strerror (it->rc));
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
LOG_TRACE ("Opening new MDB transaction @%p", it->txn);
|
|
LOG_TRACE ("Opening new MDB transaction @%p", it->txn);
|
|
@@ -722,20 +722,20 @@ mdbstore_lookup (
|
|
* ckset is filled with an array of contexts that the triple appears
|
|
* ckset is filled with an array of contexts that the triple appears
|
|
* in, if not NULL.
|
|
* in, if not NULL.
|
|
*/
|
|
*/
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbiter_next_key (MDBIterator *it)
|
|
mdbiter_next_key (MDBIterator *it)
|
|
{
|
|
{
|
|
- if (UNLIKELY (!it)) return LSUP_VALUE_ERR;
|
|
|
|
|
|
+ if (UNLIKELY (!it)) return VOLK_VALUE_ERR;
|
|
|
|
|
|
// Only advance if the previous it->rc wasn't already at the end.
|
|
// Only advance if the previous it->rc wasn't already at the end.
|
|
- if (it->rc == MDB_NOTFOUND) return LSUP_END;
|
|
|
|
|
|
+ if (it->rc == MDB_NOTFOUND) return VOLK_END;
|
|
|
|
|
|
if (UNLIKELY (it->rc != MDB_SUCCESS)) {
|
|
if (UNLIKELY (it->rc != MDB_SUCCESS)) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
- LSUP_rc rc;
|
|
|
|
|
|
+ VOLK_rc rc;
|
|
|
|
|
|
/* Retrieve current value and advance cursor to the next result.
|
|
/* Retrieve current value and advance cursor to the next result.
|
|
* it->rc is set to the result of the next iteration.
|
|
* it->rc is set to the result of the next iteration.
|
|
@@ -749,14 +749,14 @@ mdbiter_next_key (MDBIterator *it)
|
|
data.mv_size = KLEN;
|
|
data.mv_size = KLEN;
|
|
|
|
|
|
if (it->luc) {
|
|
if (it->luc) {
|
|
- rc = LSUP_NORESULT; // Flow control value, will never be returned.
|
|
|
|
|
|
+ rc = VOLK_NORESULT; // Flow control value, will never be returned.
|
|
do {
|
|
do {
|
|
//LOG_DEBUG("begin ctx loop.");
|
|
//LOG_DEBUG("begin ctx loop.");
|
|
/* If ctx is specified, look if the matching triple is associated
|
|
/* If ctx is specified, look if the matching triple is associated
|
|
* with it. If not, move on to the next triple.
|
|
* with it. If not, move on to the next triple.
|
|
* The loop normally exits when a triple with matching ctx is found
|
|
* The loop normally exits when a triple with matching ctx is found
|
|
- * (LSUP_OK), if there are no more triples (LSUP_END), or if there
|
|
|
|
- * is an error (LSUP_DB_ERR).
|
|
|
|
|
|
+ * (VOLK_OK), if there are no more triples (VOLK_END), or if there
|
|
|
|
+ * is an error (VOLK_DB_ERR).
|
|
*/
|
|
*/
|
|
LOG_TRACE (
|
|
LOG_TRACE (
|
|
"Found spok: {%lx, %lx, %lx}",
|
|
"Found spok: {%lx, %lx, %lx}",
|
|
@@ -767,26 +767,26 @@ mdbiter_next_key (MDBIterator *it)
|
|
db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_GET_BOTH);
|
|
db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_GET_BOTH);
|
|
|
|
|
|
if (db_rc == MDB_SUCCESS) {
|
|
if (db_rc == MDB_SUCCESS) {
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ rc = VOLK_OK;
|
|
LOG_TRACE("Triple found in context: %x", it->luc);
|
|
LOG_TRACE("Triple found in context: %x", it->luc);
|
|
|
|
|
|
} else if (db_rc == MDB_NOTFOUND) {
|
|
} else if (db_rc == MDB_NOTFOUND) {
|
|
LOG_TRACE("Triple not found in context: %x", it->luc);
|
|
LOG_TRACE("Triple not found in context: %x", it->luc);
|
|
- if (it->rc == MDB_NOTFOUND) rc = LSUP_END;
|
|
|
|
|
|
+ if (it->rc == MDB_NOTFOUND) rc = VOLK_END;
|
|
else it->iter_op_fn (it);
|
|
else it->iter_op_fn (it);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- log_error ("Database error: %s", LSUP_strerror (db_rc));
|
|
|
|
- rc = LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (db_rc));
|
|
|
|
+ rc = VOLK_DB_ERR;
|
|
}
|
|
}
|
|
- } while (rc == LSUP_NORESULT);
|
|
|
|
|
|
+ } while (rc == VOLK_NORESULT);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
LOG_TRACE (
|
|
LOG_TRACE (
|
|
"Found spok in any context: {%lx, %lx, %lx}",
|
|
"Found spok in any context: {%lx, %lx, %lx}",
|
|
it->spok[0], it->spok[1], it->spok[2]);
|
|
it->spok[0], it->spok[1], it->spok[2]);
|
|
|
|
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ rc = VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
// Get all contexts for a triple.
|
|
// Get all contexts for a triple.
|
|
@@ -794,15 +794,15 @@ mdbiter_next_key (MDBIterator *it)
|
|
db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_SET_KEY);
|
|
db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_SET_KEY);
|
|
if (db_rc != MDB_SUCCESS) {
|
|
if (db_rc != MDB_SUCCESS) {
|
|
log_error ("No context found for triple!");
|
|
log_error ("No context found for triple!");
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
size_t ct;
|
|
size_t ct;
|
|
db_rc = mdb_cursor_count (it->ctx_cur, &ct);
|
|
db_rc = mdb_cursor_count (it->ctx_cur, &ct);
|
|
- if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
|
|
|
|
|
|
+ if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
|
|
// 1 spare for sentinel. Always allocated even on zero matches.
|
|
// 1 spare for sentinel. Always allocated even on zero matches.
|
|
- LSUP_Key *tmp_ck = realloc (it->ck, sizeof (*it->ck) * (ct + 1));
|
|
|
|
- if (!tmp_ck) return LSUP_MEM_ERR;
|
|
|
|
|
|
+ VOLK_Key *tmp_ck = realloc (it->ck, sizeof (*it->ck) * (ct + 1));
|
|
|
|
+ if (!tmp_ck) return VOLK_MEM_ERR;
|
|
it->ck = tmp_ck;
|
|
it->ck = tmp_ck;
|
|
|
|
|
|
size_t i = 0;
|
|
size_t i = 0;
|
|
@@ -819,14 +819,14 @@ mdbiter_next_key (MDBIterator *it)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbiter_next (
|
|
mdbiter_next (
|
|
- void *h, LSUP_BufferTriple *sspo, LSUP_Buffer **ctx_p)
|
|
|
|
|
|
+ void *h, VOLK_BufferTriple *sspo, VOLK_Buffer **ctx_p)
|
|
{
|
|
{
|
|
MDBIterator *it = h;
|
|
MDBIterator *it = h;
|
|
- LSUP_rc rc = mdbiter_next_key (it);
|
|
|
|
|
|
+ VOLK_rc rc = mdbiter_next_key (it);
|
|
|
|
|
|
- if (rc == LSUP_OK) {
|
|
|
|
|
|
+ if (rc == VOLK_OK) {
|
|
if (sspo) {
|
|
if (sspo) {
|
|
key_to_sterm (it->store, it->txn, it->spok[0], sspo->s);
|
|
key_to_sterm (it->store, it->txn, it->spok[0], sspo->s);
|
|
key_to_sterm (it->store, it->txn, it->spok[1], sspo->p);
|
|
key_to_sterm (it->store, it->txn, it->spok[1], sspo->p);
|
|
@@ -840,10 +840,10 @@ mdbiter_next (
|
|
// Preallocate.
|
|
// Preallocate.
|
|
size_t i = 0;
|
|
size_t i = 0;
|
|
while (it->ck[i++]); // Include sentinel in count.
|
|
while (it->ck[i++]); // Include sentinel in count.
|
|
- LSUP_Buffer *ctx;
|
|
|
|
|
|
+ VOLK_Buffer *ctx;
|
|
LOG_TRACE("Allocating %lu context buffers + sentinel.", i - 1);
|
|
LOG_TRACE("Allocating %lu context buffers + sentinel.", i - 1);
|
|
ctx = malloc(i * sizeof (*ctx));
|
|
ctx = malloc(i * sizeof (*ctx));
|
|
- if (!ctx) return LSUP_MEM_ERR;
|
|
|
|
|
|
+ if (!ctx) return VOLK_MEM_ERR;
|
|
|
|
|
|
for (i = 0; it->ck[i]; i++)
|
|
for (i = 0; it->ck[i]; i++)
|
|
key_to_sterm (it->store, it->txn, it->ck[i], ctx + i);
|
|
key_to_sterm (it->store, it->txn, it->ck[i], ctx + i);
|
|
@@ -873,17 +873,17 @@ mdbiter_free (void *h)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_update_ctx (
|
|
mdbstore_update_ctx (
|
|
- void *h, const LSUP_Buffer *old_c, const LSUP_Buffer *new_c, void *th)
|
|
|
|
|
|
+ void *h, const VOLK_Buffer *old_c, const VOLK_Buffer *new_c, void *th)
|
|
{
|
|
{
|
|
- LSUP_rc rc = LSUP_NOACTION;
|
|
|
|
|
|
+ VOLK_rc rc = VOLK_NOACTION;
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
unsigned char *trp_data = NULL;
|
|
unsigned char *trp_data = NULL;
|
|
|
|
|
|
- LSUP_Key
|
|
|
|
- old_ck = LSUP_buffer_hash (old_c),
|
|
|
|
- new_ck = LSUP_buffer_hash (new_c);
|
|
|
|
|
|
+ VOLK_Key
|
|
|
|
+ old_ck = VOLK_buffer_hash (old_c),
|
|
|
|
+ new_ck = VOLK_buffer_hash (new_c);
|
|
// lu_key, lu_data look up all triples with old context in c:spo, and
|
|
// lu_key, lu_data look up all triples with old context in c:spo, and
|
|
// replace old c with new c.
|
|
// replace old c with new c.
|
|
MDB_txn
|
|
MDB_txn
|
|
@@ -909,7 +909,7 @@ mdbstore_update_ctx (
|
|
log_error (
|
|
log_error (
|
|
"Context key %lu already exists. Not replacing old graph.",
|
|
"Context key %lu already exists. Not replacing old graph.",
|
|
new_ck);
|
|
new_ck);
|
|
- rc = LSUP_CONFLICT;
|
|
|
|
|
|
+ rc = VOLK_CONFLICT;
|
|
goto close_i;
|
|
goto close_i;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -921,21 +921,21 @@ mdbstore_update_ctx (
|
|
rc = mdb_cursor_get (i_cur, &key, &data, MDB_SET);
|
|
rc = mdb_cursor_get (i_cur, &key, &data, MDB_SET);
|
|
if (rc == MDB_NOTFOUND) {
|
|
if (rc == MDB_NOTFOUND) {
|
|
log_info ("No triples found associated with old context.");
|
|
log_info ("No triples found associated with old context.");
|
|
- rc = LSUP_NOACTION;
|
|
|
|
|
|
+ rc = VOLK_NOACTION;
|
|
goto close_i;
|
|
goto close_i;
|
|
}
|
|
}
|
|
if (rc != MDB_SUCCESS) {
|
|
if (rc != MDB_SUCCESS) {
|
|
- rc = LSUP_DB_ERR;
|
|
|
|
|
|
+ rc = VOLK_DB_ERR;
|
|
goto close_i;
|
|
goto close_i;
|
|
}
|
|
}
|
|
|
|
|
|
- // From here on, it can only be LSUP_OK or error.
|
|
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ // From here on, it can only be VOLK_OK or error.
|
|
|
|
+ rc = VOLK_OK;
|
|
size_t trp_ct;
|
|
size_t trp_ct;
|
|
CHECK (rc = mdb_cursor_count (i_cur, &trp_ct), close_i);
|
|
CHECK (rc = mdb_cursor_count (i_cur, &trp_ct), close_i);
|
|
trp_data = malloc (trp_ct * TRP_KLEN);
|
|
trp_data = malloc (trp_ct * TRP_KLEN);
|
|
if (UNLIKELY (!trp_data)) {
|
|
if (UNLIKELY (!trp_data)) {
|
|
- rc = LSUP_MEM_ERR;
|
|
|
|
|
|
+ rc = VOLK_MEM_ERR;
|
|
goto close_i;
|
|
goto close_i;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -943,7 +943,7 @@ mdbstore_update_ctx (
|
|
// deleted while cursors are active.
|
|
// deleted while cursors are active.
|
|
rc = mdb_cursor_get (i_cur, &key, &data, MDB_GET_MULTIPLE);
|
|
rc = mdb_cursor_get (i_cur, &key, &data, MDB_GET_MULTIPLE);
|
|
if (rc != MDB_SUCCESS) {
|
|
if (rc != MDB_SUCCESS) {
|
|
- rc = rc == MDB_NOTFOUND ? LSUP_NOACTION : LSUP_DB_ERR;
|
|
|
|
|
|
+ rc = rc == MDB_NOTFOUND ? VOLK_NOACTION : VOLK_DB_ERR;
|
|
goto close_i;
|
|
goto close_i;
|
|
}
|
|
}
|
|
size_t loc_cur = 0;
|
|
size_t loc_cur = 0;
|
|
@@ -1001,7 +1001,7 @@ close_d:
|
|
close_i:
|
|
close_i:
|
|
mdb_cursor_close (i_cur);
|
|
mdb_cursor_close (i_cur);
|
|
close_txn:
|
|
close_txn:
|
|
- if (rc == LSUP_OK) {
|
|
|
|
|
|
+ if (rc == VOLK_OK) {
|
|
RCCK (mdb_txn_commit (txn));
|
|
RCCK (mdb_txn_commit (txn));
|
|
} else mdb_txn_abort (txn);
|
|
} else mdb_txn_abort (txn);
|
|
|
|
|
|
@@ -1012,20 +1012,20 @@ finally:
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
mdbstore_remove (
|
|
mdbstore_remove (
|
|
- void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
|
|
|
|
- const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
|
|
|
|
|
|
+ void *h, const VOLK_Buffer *ss, const VOLK_Buffer *sp,
|
|
|
|
+ const VOLK_Buffer *so, const VOLK_Buffer *sc, void *th, size_t *ct)
|
|
{
|
|
{
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
- LSUP_rc
|
|
|
|
- rc = LSUP_NOACTION,
|
|
|
|
|
|
+ VOLK_rc
|
|
|
|
+ rc = VOLK_NOACTION,
|
|
db_rc = 0;
|
|
db_rc = 0;
|
|
|
|
|
|
- LSUP_Key ck = NULL_KEY;
|
|
|
|
|
|
+ VOLK_Key ck = NULL_KEY;
|
|
|
|
|
|
- if (sc == NULL) sc = LSUP_default_ctx_buf;
|
|
|
|
- ck = LSUP_buffer_hash (sc);
|
|
|
|
|
|
+ if (sc == NULL) sc = VOLK_default_ctx_buf;
|
|
|
|
+ ck = VOLK_buffer_hash (sc);
|
|
|
|
|
|
MDB_txn *txn;
|
|
MDB_txn *txn;
|
|
mdb_txn_begin (store->env, (MDB_txn *) th, 0, &txn);
|
|
mdb_txn_begin (store->env, (MDB_txn *) th, 0, &txn);
|
|
@@ -1042,10 +1042,10 @@ mdbstore_remove (
|
|
|
|
|
|
// The lookup operates within the current (bottom) write transaction.
|
|
// The lookup operates within the current (bottom) write transaction.
|
|
MDBIterator *it = mdbstore_lookup (store, ss, sp, so, sc, txn, ct);
|
|
MDBIterator *it = mdbstore_lookup (store, ss, sp, so, sc, txn, ct);
|
|
- if (UNLIKELY (!it)) return LSUP_DB_ERR;
|
|
|
|
|
|
+ if (UNLIKELY (!it)) return VOLK_DB_ERR;
|
|
if (ct) LOG_DEBUG("Found %lu triples to remove.", *ct);
|
|
if (ct) LOG_DEBUG("Found %lu triples to remove.", *ct);
|
|
|
|
|
|
- while (mdbiter_next_key (it) == LSUP_OK) {
|
|
|
|
|
|
+ while (mdbiter_next_key (it) == VOLK_OK) {
|
|
spok_v.mv_data = it->spok;
|
|
spok_v.mv_data = it->spok;
|
|
|
|
|
|
db_rc = mdb_cursor_get (dcur, &spok_v, &ck_v, MDB_GET_BOTH);
|
|
db_rc = mdb_cursor_get (dcur, &spok_v, &ck_v, MDB_GET_BOTH);
|
|
@@ -1087,7 +1087,7 @@ mdbstore_remove (
|
|
mdbiter_free (it);
|
|
mdbiter_free (it);
|
|
|
|
|
|
if (UNLIKELY (mdb_txn_commit (txn) != MDB_SUCCESS)) {
|
|
if (UNLIKELY (mdb_txn_commit (txn) != MDB_SUCCESS)) {
|
|
- rc = LSUP_TXN_ERR;
|
|
|
|
|
|
+ rc = VOLK_TXN_ERR;
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1096,15 +1096,15 @@ mdbstore_remove (
|
|
fail:
|
|
fail:
|
|
mdb_txn_abort (txn);
|
|
mdb_txn_abort (txn);
|
|
|
|
|
|
- log_error ("Database error: %s", LSUP_strerror (db_rc));
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (db_rc));
|
|
|
|
|
|
- return rc == LSUP_TXN_ERR ? rc : LSUP_DB_ERR;
|
|
|
|
|
|
+ return rc == VOLK_TXN_ERR ? rc : VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
#if 0
|
|
static int
|
|
static int
|
|
-mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
|
|
|
|
|
|
+mdbstore_tkey_exists (MDBStore *store, VOLK_Key tkey)
|
|
{
|
|
{
|
|
int db_rc, rc;
|
|
int db_rc, rc;
|
|
MDB_val key, data;
|
|
MDB_val key, data;
|
|
@@ -1122,8 +1122,8 @@ mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
|
|
if (db_rc == MDB_SUCCESS) rc = 1;
|
|
if (db_rc == MDB_SUCCESS) rc = 1;
|
|
else if (db_rc == MDB_NOTFOUND) rc = 0;
|
|
else if (db_rc == MDB_NOTFOUND) rc = 0;
|
|
else {
|
|
else {
|
|
- log_error ("DB error: %s", LSUP_strerror (db_rc));
|
|
|
|
- rc = LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("DB error: %s", VOLK_strerror (db_rc));
|
|
|
|
+ rc = VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
if (cur) mdb_cursor_close (cur);
|
|
if (cur) mdb_cursor_close (cur);
|
|
@@ -1143,10 +1143,10 @@ mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
|
|
* @param[in] th transaction handle. It may be NULL, in which case a new
|
|
* @param[in] th transaction handle. It may be NULL, in which case a new
|
|
* transaction is opened and closed for the operation.
|
|
* transaction is opened and closed for the operation.
|
|
*
|
|
*
|
|
- * @return LSUP_OK on success; <0 on error.
|
|
|
|
|
|
+ * @return VOLK_OK on success; <0 on error.
|
|
*/
|
|
*/
|
|
-static LSUP_rc
|
|
|
|
-mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
|
|
|
|
|
|
+static VOLK_rc
|
|
|
|
+mdbstore_add_term (void *h, const VOLK_Buffer *sterm, void *th)
|
|
{
|
|
{
|
|
//LOG_TRACE("Adding term to MDB store: %s", sterm->addr);
|
|
//LOG_TRACE("Adding term to MDB store: %s", sterm->addr);
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
@@ -1163,7 +1163,7 @@ mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
|
|
MDB_cursor *cur;
|
|
MDB_cursor *cur;
|
|
CHECK (mdb_cursor_open (txn, store->dbi[IDX_T_ST], &cur), fail);
|
|
CHECK (mdb_cursor_open (txn, store->dbi[IDX_T_ST], &cur), fail);
|
|
|
|
|
|
- LSUP_Key k = LSUP_buffer_hash (sterm);
|
|
|
|
|
|
+ VOLK_Key k = VOLK_buffer_hash (sterm);
|
|
key.mv_data = &k;
|
|
key.mv_data = &k;
|
|
key.mv_size = sizeof (k);
|
|
key.mv_size = sizeof (k);
|
|
|
|
|
|
@@ -1175,20 +1175,20 @@ mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
|
|
|
|
|
|
if (!borrowed_txn) CHECK (db_rc = mdb_txn_commit (txn), fail);
|
|
if (!borrowed_txn) CHECK (db_rc = mdb_txn_commit (txn), fail);
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
|
|
|
|
fail:
|
|
fail:
|
|
if (!borrowed_txn) mdb_txn_abort (txn);
|
|
if (!borrowed_txn) mdb_txn_abort (txn);
|
|
LOG_TRACE("Aborted txn for adding term.");
|
|
LOG_TRACE("Aborted txn for adding term.");
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-LSUP_Buffer **
|
|
|
|
|
|
+VOLK_Buffer **
|
|
mdbstore_ctx_list (void *h, void *th)
|
|
mdbstore_ctx_list (void *h, void *th)
|
|
{
|
|
{
|
|
MDBStore *store = h;
|
|
MDBStore *store = h;
|
|
- LSUP_rc db_rc;
|
|
|
|
|
|
+ VOLK_rc db_rc;
|
|
MDB_txn *txn;
|
|
MDB_txn *txn;
|
|
if (th) txn = th;
|
|
if (th) txn = th;
|
|
else CHECK (mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn), fail);
|
|
else CHECK (mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn), fail);
|
|
@@ -1199,13 +1199,13 @@ mdbstore_ctx_list (void *h, void *th)
|
|
MDB_val key, data;
|
|
MDB_val key, data;
|
|
db_rc = mdb_cursor_get (cur, &key, &data, MDB_FIRST);
|
|
db_rc = mdb_cursor_get (cur, &key, &data, MDB_FIRST);
|
|
|
|
|
|
- LSUP_Buffer **tdata = NULL;
|
|
|
|
|
|
+ VOLK_Buffer **tdata = NULL;
|
|
size_t i = 0;
|
|
size_t i = 0;
|
|
while (db_rc == MDB_SUCCESS) {
|
|
while (db_rc == MDB_SUCCESS) {
|
|
tdata = realloc (tdata, (i + 1) * sizeof (*tdata));
|
|
tdata = realloc (tdata, (i + 1) * sizeof (*tdata));
|
|
if (UNLIKELY (!tdata)) goto fail;
|
|
if (UNLIKELY (!tdata)) goto fail;
|
|
tdata[i] = BUF_DUMMY;
|
|
tdata[i] = BUF_DUMMY;
|
|
- LSUP_Key tkey = *(LSUP_Key*)key.mv_data;
|
|
|
|
|
|
+ VOLK_Key tkey = *(VOLK_Key*)key.mv_data;
|
|
CHECK (key_to_sterm (store, txn, tkey, tdata[i]), fail);
|
|
CHECK (key_to_sterm (store, txn, tkey, tdata[i]), fail);
|
|
db_rc = mdb_cursor_get (cur, &key, &data, MDB_NEXT_NODUP);
|
|
db_rc = mdb_cursor_get (cur, &key, &data, MDB_NEXT_NODUP);
|
|
i++;
|
|
i++;
|
|
@@ -1225,10 +1225,10 @@ fail:
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-const LSUP_StoreInt mdbstore_int = {
|
|
|
|
|
|
+const VOLK_StoreInt mdbstore_int = {
|
|
.name = "MDB Store",
|
|
.name = "MDB Store",
|
|
- .features = LSUP_STORE_PERM | LSUP_STORE_CTX | LSUP_STORE_IDX
|
|
|
|
- | LSUP_STORE_TXN | LSUP_STORE_COW,
|
|
|
|
|
|
+ .features = VOLK_STORE_PERM | VOLK_STORE_CTX | VOLK_STORE_IDX
|
|
|
|
+ | VOLK_STORE_TXN | VOLK_STORE_COW,
|
|
|
|
|
|
.setup_fn = mdbstore_setup,
|
|
.setup_fn = mdbstore_setup,
|
|
.new_fn = mdbstore_new,
|
|
.new_fn = mdbstore_new,
|
|
@@ -1270,13 +1270,13 @@ const LSUP_StoreInt mdbstore_int = {
|
|
* @param[in] th Transaction handle. This MUST be a valid pointer to an open
|
|
* @param[in] th Transaction handle. This MUST be a valid pointer to an open
|
|
* RW transaction.
|
|
* RW transaction.
|
|
*/
|
|
*/
|
|
-static LSUP_rc
|
|
|
|
|
|
+static VOLK_rc
|
|
index_triple(
|
|
index_triple(
|
|
- MDBStore *store, StoreOp op, LSUP_TripleKey spok, LSUP_Key ck,
|
|
|
|
|
|
+ MDBStore *store, StoreOp op, VOLK_TripleKey spok, VOLK_Key ck,
|
|
MDB_txn *txn)
|
|
MDB_txn *txn)
|
|
{
|
|
{
|
|
int db_rc;
|
|
int db_rc;
|
|
- LSUP_rc rc = LSUP_NOACTION;
|
|
|
|
|
|
+ VOLK_rc rc = VOLK_NOACTION;
|
|
MDB_val v1, v2;
|
|
MDB_val v1, v2;
|
|
|
|
|
|
LOG_TRACE("Indexing triple: {%lx %lx %lx}", spok[0], spok[1], spok[2]);
|
|
LOG_TRACE("Indexing triple: {%lx %lx %lx}", spok[0], spok[1], spok[2]);
|
|
@@ -1295,9 +1295,9 @@ index_triple(
|
|
mdb_cursor_open (txn, store->dbi[IDX_C_SPO], &cur);
|
|
mdb_cursor_open (txn, store->dbi[IDX_C_SPO], &cur);
|
|
if (mdb_cursor_get (cur, &v1, &v2, MDB_GET_BOTH) == MDB_SUCCESS) {
|
|
if (mdb_cursor_get (cur, &v1, &v2, MDB_GET_BOTH) == MDB_SUCCESS) {
|
|
db_rc = mdb_cursor_del (cur, 0);
|
|
db_rc = mdb_cursor_del (cur, 0);
|
|
- if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
|
|
|
|
|
|
+ if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
|
|
|
|
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ rc = VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
mdb_cursor_close (cur);
|
|
mdb_cursor_close (cur);
|
|
@@ -1314,13 +1314,13 @@ index_triple(
|
|
db_rc = mdb_put(
|
|
db_rc = mdb_put(
|
|
txn, store->dbi[IDX_C_SPO],
|
|
txn, store->dbi[IDX_C_SPO],
|
|
&v1, &v2, MDB_NODUPDATA);
|
|
&v1, &v2, MDB_NODUPDATA);
|
|
- if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
|
|
|
|
- if (db_rc != MDB_KEYEXIST) rc = LSUP_OK;
|
|
|
|
|
|
+ if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
|
|
|
|
+ if (db_rc != MDB_KEYEXIST) rc = VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
- } else return LSUP_VALUE_ERR;
|
|
|
|
|
|
+ } else return VOLK_VALUE_ERR;
|
|
|
|
|
|
- LSUP_DoubleKey dbl_keys[3] = {
|
|
|
|
|
|
+ VOLK_DoubleKey dbl_keys[3] = {
|
|
{spok[1], spok[2]}, // po
|
|
{spok[1], spok[2]}, // po
|
|
{spok[0], spok[2]}, // so
|
|
{spok[0], spok[2]}, // so
|
|
{spok[0], spok[1]}, // sp
|
|
{spok[0], spok[1]}, // sp
|
|
@@ -1355,7 +1355,7 @@ index_triple(
|
|
db_rc = mdb_cursor_get (cur2, &v2, &v1, MDB_GET_BOTH);
|
|
db_rc = mdb_cursor_get (cur2, &v2, &v1, MDB_GET_BOTH);
|
|
if (db_rc == MDB_SUCCESS) mdb_cursor_del (cur2, 0);
|
|
if (db_rc == MDB_SUCCESS) mdb_cursor_del (cur2, 0);
|
|
// TODO error handling.
|
|
// TODO error handling.
|
|
- rc = LSUP_OK;
|
|
|
|
|
|
+ rc = VOLK_OK;
|
|
|
|
|
|
mdb_cursor_close (cur2);
|
|
mdb_cursor_close (cur2);
|
|
|
|
|
|
@@ -1368,8 +1368,8 @@ index_triple(
|
|
|
|
|
|
db_rc = mdb_put (txn, db1, &v1, &v2, MDB_NODUPDATA);
|
|
db_rc = mdb_put (txn, db1, &v1, &v2, MDB_NODUPDATA);
|
|
|
|
|
|
- if (db_rc == MDB_SUCCESS) rc = LSUP_OK;
|
|
|
|
- else if (db_rc != MDB_KEYEXIST) return LSUP_DB_ERR;
|
|
|
|
|
|
+ if (db_rc == MDB_SUCCESS) rc = VOLK_OK;
|
|
|
|
+ else if (db_rc != MDB_KEYEXIST) return VOLK_DB_ERR;
|
|
|
|
|
|
// 2-bound index.
|
|
// 2-bound index.
|
|
LOG_TRACE("Indexing in %s: ", db_labels[lookup_indices[i + 3]]);
|
|
LOG_TRACE("Indexing in %s: ", db_labels[lookup_indices[i + 3]]);
|
|
@@ -1379,8 +1379,8 @@ index_triple(
|
|
|
|
|
|
db_rc = mdb_put (txn, db2, &v2, &v1, MDB_NODUPDATA);
|
|
db_rc = mdb_put (txn, db2, &v2, &v1, MDB_NODUPDATA);
|
|
|
|
|
|
- if (db_rc == MDB_SUCCESS) rc = LSUP_OK;
|
|
|
|
- else if (db_rc != MDB_KEYEXIST) return LSUP_DB_ERR;
|
|
|
|
|
|
+ if (db_rc == MDB_SUCCESS) rc = VOLK_OK;
|
|
|
|
+ else if (db_rc != MDB_KEYEXIST) return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1397,7 +1397,7 @@ index_triple(
|
|
inline static void
|
|
inline static void
|
|
it_next_0bound (MDBIterator *it)
|
|
it_next_0bound (MDBIterator *it)
|
|
{
|
|
{
|
|
- memcpy (it->spok, it->key.mv_data, sizeof (LSUP_TripleKey));
|
|
|
|
|
|
+ memcpy (it->spok, it->key.mv_data, sizeof (VOLK_TripleKey));
|
|
|
|
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_NEXT);
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_NEXT);
|
|
}
|
|
}
|
|
@@ -1412,7 +1412,7 @@ it_next_0bound (MDBIterator *it)
|
|
inline static void
|
|
inline static void
|
|
it_next_1bound (MDBIterator *it)
|
|
it_next_1bound (MDBIterator *it)
|
|
{
|
|
{
|
|
- LSUP_DoubleKey *lu_dset = it->data.mv_data;
|
|
|
|
|
|
+ VOLK_DoubleKey *lu_dset = it->data.mv_data;
|
|
|
|
|
|
it->spok[it->term_order[0]] = it->luk[0];
|
|
it->spok[it->term_order[0]] = it->luk[0];
|
|
it->spok[it->term_order[1]] = lu_dset[it->i][0];
|
|
it->spok[it->term_order[1]] = lu_dset[it->i][0];
|
|
@@ -1448,7 +1448,7 @@ it_next_1bound (MDBIterator *it)
|
|
inline static void
|
|
inline static void
|
|
it_next_2bound (MDBIterator *it)
|
|
it_next_2bound (MDBIterator *it)
|
|
{
|
|
{
|
|
- LSUP_Key *lu_dset = it->data.mv_data;
|
|
|
|
|
|
+ VOLK_Key *lu_dset = it->data.mv_data;
|
|
|
|
|
|
it->spok[it->term_order[0]] = it->luk[0];
|
|
it->spok[it->term_order[0]] = it->luk[0];
|
|
it->spok[it->term_order[1]] = it->luk[1];
|
|
it->spok[it->term_order[1]] = it->luk[1];
|
|
@@ -1479,7 +1479,7 @@ it_next_3bound (MDBIterator *it)
|
|
|
|
|
|
/* * * Term-specific lookups. * * */
|
|
/* * * Term-specific lookups. * * */
|
|
|
|
|
|
-inline static LSUP_rc
|
|
|
|
|
|
+inline static VOLK_rc
|
|
lookup_0bound (MDBIterator *it, size_t *ct)
|
|
lookup_0bound (MDBIterator *it, size_t *ct)
|
|
{
|
|
{
|
|
LOG_DEBUG("Looking up 0 bound terms.");
|
|
LOG_DEBUG("Looking up 0 bound terms.");
|
|
@@ -1511,8 +1511,8 @@ lookup_0bound (MDBIterator *it, size_t *ct)
|
|
|
|
|
|
it->rc = mdb_cursor_open (it->txn, it->store->dbi[IDX_SPO_C], &it->cur);
|
|
it->rc = mdb_cursor_open (it->txn, it->store->dbi[IDX_SPO_C], &it->cur);
|
|
if (it->rc != MDB_SUCCESS) {
|
|
if (it->rc != MDB_SUCCESS) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_FIRST);
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_FIRST);
|
|
@@ -1524,15 +1524,15 @@ lookup_0bound (MDBIterator *it, size_t *ct)
|
|
it->iter_op_fn = it_next_0bound;
|
|
it->iter_op_fn = it_next_0bound;
|
|
|
|
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-inline static LSUP_rc
|
|
|
|
|
|
+inline static VOLK_rc
|
|
lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
lookup_1bound (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];
|
|
@@ -1550,7 +1550,7 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
if (it->luc != NULL_KEY) {
|
|
if (it->luc != NULL_KEY) {
|
|
LOG_DEBUG("Counting in context: %lx", it->luc);
|
|
LOG_DEBUG("Counting in context: %lx", it->luc);
|
|
MDBIterator *ct_it;
|
|
MDBIterator *ct_it;
|
|
- MALLOC_GUARD (ct_it, LSUP_MEM_ERR);
|
|
|
|
|
|
+ MALLOC_GUARD (ct_it, VOLK_MEM_ERR);
|
|
/*
|
|
/*
|
|
memcpy (ct_it, it, sizeof (*ct_it));
|
|
memcpy (ct_it, it, sizeof (*ct_it));
|
|
*/
|
|
*/
|
|
@@ -1565,11 +1565,11 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
ct_it->luc = it->luc;
|
|
ct_it->luc = it->luc;
|
|
ct_it->i = 0;
|
|
ct_it->i = 0;
|
|
|
|
|
|
- LSUP_rc rc = lookup_1bound (idx0, ct_it, NULL);
|
|
|
|
|
|
+ VOLK_rc rc = lookup_1bound (idx0, ct_it, NULL);
|
|
if (rc < 0) return rc;
|
|
if (rc < 0) return rc;
|
|
|
|
|
|
- LSUP_rc db_rc;
|
|
|
|
- while (LSUP_END != (db_rc = mdbiter_next_key (ct_it))) {
|
|
|
|
|
|
+ VOLK_rc db_rc;
|
|
|
|
+ while (VOLK_END != (db_rc = mdbiter_next_key (ct_it))) {
|
|
if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
if (UNLIKELY (db_rc < 0)) return db_rc;
|
|
(*ct)++;
|
|
(*ct)++;
|
|
}
|
|
}
|
|
@@ -1594,15 +1594,15 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
|
|
|
|
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-inline static LSUP_rc
|
|
|
|
|
|
+inline static VOLK_rc
|
|
lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
{
|
|
{
|
|
uint8_t luk1_offset, luk2_offset;
|
|
uint8_t luk1_offset, luk2_offset;
|
|
@@ -1640,11 +1640,11 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
log_error (
|
|
log_error (
|
|
"Values %d and %d not found in lookup keys.",
|
|
"Values %d and %d not found in lookup keys.",
|
|
idx0, idx1);
|
|
idx0, idx1);
|
|
- return LSUP_VALUE_ERR;
|
|
|
|
|
|
+ return VOLK_VALUE_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
// Compose term keys in lookup key.
|
|
// Compose term keys in lookup key.
|
|
- LSUP_DoubleKey luk;
|
|
|
|
|
|
+ VOLK_DoubleKey luk;
|
|
luk[luk1_offset] = it->luk[0];
|
|
luk[luk1_offset] = it->luk[0];
|
|
luk[luk2_offset] = it->luk[1];
|
|
luk[luk2_offset] = it->luk[1];
|
|
|
|
|
|
@@ -1659,7 +1659,7 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
// the context is to loop over them.
|
|
// the context is to loop over them.
|
|
if (it->luc != NULL_KEY) {
|
|
if (it->luc != NULL_KEY) {
|
|
MDBIterator *ct_it;
|
|
MDBIterator *ct_it;
|
|
- MALLOC_GUARD (ct_it, LSUP_MEM_ERR);
|
|
|
|
|
|
+ MALLOC_GUARD (ct_it, VOLK_MEM_ERR);
|
|
|
|
|
|
ct_it->store = it->store;
|
|
ct_it->store = it->store;
|
|
ct_it->txn = it->txn;
|
|
ct_it->txn = it->txn;
|
|
@@ -1672,7 +1672,7 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
|
|
|
|
lookup_2bound (idx0, idx1, ct_it, NULL);
|
|
lookup_2bound (idx0, idx1, ct_it, NULL);
|
|
|
|
|
|
- while (mdbiter_next_key (ct_it) != LSUP_END) (*ct) ++;
|
|
|
|
|
|
+ while (mdbiter_next_key (ct_it) != VOLK_END) (*ct) ++;
|
|
|
|
|
|
// Free the counter iterator without freeing the shared txn.
|
|
// Free the counter iterator without freeing the shared txn.
|
|
if (ct_it->cur) mdb_cursor_close (ct_it->cur);
|
|
if (ct_it->cur) mdb_cursor_close (ct_it->cur);
|
|
@@ -1694,15 +1694,15 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
|
|
|
|
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-inline static LSUP_rc
|
|
|
|
|
|
+inline static VOLK_rc
|
|
lookup_3bound (MDBIterator *it, size_t *ct)
|
|
lookup_3bound (MDBIterator *it, size_t *ct)
|
|
{
|
|
{
|
|
LOG_DEBUG(
|
|
LOG_DEBUG(
|
|
@@ -1730,8 +1730,8 @@ lookup_3bound (MDBIterator *it, size_t *ct)
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_BOTH);
|
|
it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_BOTH);
|
|
|
|
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
|
|
- log_error ("Database error: %s", LSUP_strerror (it->rc));
|
|
|
|
- return LSUP_DB_ERR;
|
|
|
|
|
|
+ log_error ("Database error: %s", VOLK_strerror (it->rc));
|
|
|
|
+ return VOLK_DB_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
mdb_cursor_close (it->cur);
|
|
mdb_cursor_close (it->cur);
|
|
@@ -1740,9 +1740,9 @@ lookup_3bound (MDBIterator *it, size_t *ct)
|
|
if (ct && it->rc == MDB_SUCCESS) *ct = 1;
|
|
if (ct && it->rc == MDB_SUCCESS) *ct = 1;
|
|
|
|
|
|
it->iter_op_fn = it_next_3bound;
|
|
it->iter_op_fn = it_next_3bound;
|
|
- memcpy (it->spok, it->luk, sizeof (LSUP_TripleKey));
|
|
|
|
|
|
+ memcpy (it->spok, it->luk, sizeof (VOLK_TripleKey));
|
|
|
|
|
|
- return LSUP_OK;
|
|
|
|
|
|
+ return VOLK_OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|