|
@@ -11,6 +11,8 @@
|
|
|
// factor low.
|
|
|
#define IDX_SIZE_RATIO 1.7
|
|
|
|
|
|
+// RAMdisk path for MDB volatile store.
|
|
|
+#define MDB_RAMDISK_PATH TMPDIR "/lsup_mem_graph"
|
|
|
|
|
|
typedef enum KSetFlag {
|
|
|
LSUP_KS_NONE = 0,
|
|
@@ -55,7 +57,7 @@ size_t LSUP_graph_size(const LSUP_Graph *gr);
|
|
|
|
|
|
/* * * Static prototypes. * * */
|
|
|
|
|
|
-static inline void default_ctx_init();
|
|
|
+static inline void mdbstore_init();
|
|
|
|
|
|
|
|
|
/* * * Post-lookup callback prototypes * * */
|
|
@@ -103,18 +105,21 @@ LSUP_graph_new(const LSUP_store_type store_type)
|
|
|
CRITICAL(gr = malloc(sizeof(LSUP_Graph)));
|
|
|
gr->uri = LSUP_uri_new(NULL);
|
|
|
|
|
|
- default_ctx_init();
|
|
|
+ mdbstore_init();
|
|
|
|
|
|
if (store_type == LSUP_STORE_MEM) {
|
|
|
// TODO uncomment gr->ht_store = LSUP_htstore_new(0);
|
|
|
+ // if (!gr->ht_store) return NULL;
|
|
|
|
|
|
} else if (store_type == LSUP_STORE_MDB) {
|
|
|
gr->mdb_store = LSUP_mdbstore_new(
|
|
|
getenv("LSUP_MDB_STORE_PATH"), default_ctx);
|
|
|
+ if (!gr->mdb_store) return NULL;
|
|
|
|
|
|
} else {
|
|
|
gr->mdb_store = LSUP_mdbstore_new(
|
|
|
- TMPDIR "/lsup_mem_graph", default_ctx);
|
|
|
+ MDB_RAMDISK_PATH, default_ctx);
|
|
|
+ if (!gr->mdb_store) return NULL;
|
|
|
}
|
|
|
|
|
|
return gr;
|
|
@@ -218,6 +223,7 @@ LSUP_graph_set_uri(LSUP_Graph *gr, const char *uri)
|
|
|
LSUP_rc
|
|
|
LSUP_graph_resize(LSUP_Graph *gr, size_t size)
|
|
|
{
|
|
|
+ return LSUP_OK; // TODO remove line.
|
|
|
if (gr->store_type == LSUP_STORE_MEM)
|
|
|
return 0;// TODO uncomment LSUP_htstore_resize(gr->ht_store, size);
|
|
|
|
|
@@ -464,10 +470,22 @@ LSUP_graph_contains(const LSUP_Graph *gr, const LSUP_Triple *spo)
|
|
|
|
|
|
/* * * Static functions * * */
|
|
|
|
|
|
-static inline void default_ctx_init()
|
|
|
+/** @brief Initialize default context and ramdisk only once per process.
|
|
|
+ *
|
|
|
+ * The ramdisk store persists after the application is closed, but will be
|
|
|
+ * wiped clean the next time this function is called.
|
|
|
+ */
|
|
|
+static inline void mdbstore_init()
|
|
|
{
|
|
|
- // Initialize default context only once per process.
|
|
|
if(UNLIKELY(!default_ctx)) {
|
|
|
+ // RAM disk store.
|
|
|
+ char *path = MDB_RAMDISK_PATH;
|
|
|
+ LSUP_mdbstore_setup (&path, true);
|
|
|
+
|
|
|
+ // Permanent store.
|
|
|
+ //path = getenv ("LSUP_MDB_STORE_PATH");
|
|
|
+ //LSUP_mdbstore_setup (&path);
|
|
|
+
|
|
|
LSUP_Term *default_ctx_uri = LSUP_uri_new(default_ctx_label);
|
|
|
default_ctx = LSUP_buffer_new_from_term(default_ctx_uri);
|
|
|
LSUP_term_free(default_ctx_uri);
|