Browse Source

Get store features; other inconsequential additions.

Stefano Cossu 3 years ago
parent
commit
d8e76b672a
5 changed files with 47 additions and 5 deletions
  1. 15 1
      include/graph.h
  2. 5 2
      include/store.h
  3. 9 0
      include/store_mdb.h
  4. 13 1
      src/graph.c
  5. 5 1
      src/store_mdb.c

+ 15 - 1
include/graph.h

@@ -116,7 +116,7 @@ LSUP_graph_copy (const LSUP_Graph *src);
  * @param[in] src Graph to store.
  *
  * @param[out] dest Pointer to graph handle for the new stored graph. The new
- *  graph will have the same URI as the source.
+ *  graph will have the same URI as the source. It may be NULL.
  *
  * @param[in] env Environment to copy to. If NULL, it is set to the deafult
  *  LSUP store. This makes it possible to copy MDB graphs across different
@@ -293,6 +293,20 @@ LSUP_graph_remove (
         const LSUP_Term *o, size_t *ct);
 
 
+/** @brief Remove a whole graph from a context-aware store.
+ *
+ * @param[in] uri Graph (context) to remove.
+ *
+ * @return LSUP_OK if the graph was removed; LSUP_NOACTION if no graph was
+ *  found with the given URI; LSUP_VALU_ERR if the graph back end is a non-
+ *  permanent or non-context aware store.
+ */
+/*
+LSUP_rc
+LSUP_graph_remove_ctx (LSUP_Graph *gr);
+*/
+
+
 /** Look up triples by a matching pattern and yield an iterator.
  *
  * @param gr[in] Graph to look up.

+ 5 - 2
include/store.h

@@ -11,7 +11,10 @@
  * the medium (i.e. a "permanent" store may have been created ad hoc on a
  * tempfs).
  */
-#define     LSUP_STORE_PERM     1<<0    // Store is on a permanent location.
-#define     LSUP_STORE_CTX      1<<1    // Store supports contexts (quads).
+#define LSUP_STORE_PERM     1<<0    // Store is on a permanent location.
+#define LSUP_STORE_CTX      1<<1    // Store supports contexts (quads).
+#define LSUP_STORE_IDX      1<<2    // Store is fully SPO(C)-indexed.
+#define LSUP_STORE_TXN      1<<3    // Supports manual transaction handling.
+#define LSUP_STORE_NET      1<<4    // Store is over a network protocol.
 
 #endif  /* _LSUP_STORE_H */

+ 9 - 0
include/store_mdb.h

@@ -95,6 +95,15 @@ LSUP_mdbstore_new (const char *path, const LSUP_Buffer *default_ctx);
 void LSUP_mdbstore_free (LSUP_MDBStore *store);
 
 
+/** @brief Store feature flags.
+ *
+ * @param[in] store Store handle.
+ *
+ * @return A combination of LSUP_STORE_* feature flags.
+ */
+int LSUP_mdbstore_features (LSUP_MDBStore *store);
+
+
 /** @brief Print stats about a store and its databases.
  *
  * TODO

+ 13 - 1
src/graph.c

@@ -164,7 +164,7 @@ LSUP_graph_store (
         if (UNLIKELY (rc < 0)) return LSUP_DB_ERR;
     }
 
-    *dest_p = dest;
+    if (dest_p) *dest_p = dest;
 
     return LSUP_OK;
 }
@@ -407,6 +407,18 @@ LSUP_graph_remove (
 }
 
 
+/* TODO Useless? Remove?
+LSUP_rc
+LSUP_graph_remove_ctx (LSUP_Graph *gr)
+{
+    LSUP_rc rc;
+
+    // TODO replace this test with a feature test.
+    if (gr->store_type != LSUP_STORE_MDB) return LSUP_VALUE_ERR;
+}
+*/
+
+
 GraphIterator *
 LSUP_graph_lookup (const Graph *gr, const LSUP_Term *s, const LSUP_Term *p,
         const LSUP_Term *o, size_t *ct)

+ 5 - 1
src/store_mdb.c

@@ -264,7 +264,7 @@ LSUP_mdbstore_new (const char *path, const LSUP_Buffer *default_ctx)
     int db_rc;
     LSUP_MDBStore *store;
     MALLOC_GUARD (store, NULL);
-    store->features = LSUP_STORE_CTX;
+    store->features = LSUP_STORE_CTX | LSUP_STORE_IDX;
     if (strcmp (path, LSUP_MDB_RAMDISK_PATH) != 0)
             store->features |= LSUP_STORE_PERM;
 
@@ -351,6 +351,10 @@ LSUP_mdbstore_free (LSUP_MDBStore *store)
 }
 
 
+int LSUP_mdbstore_features (LSUP_MDBStore *store)
+{ return store->features; }
+
+
 LSUP_rc
 LSUP_mdbstore_stat (LSUP_MDBStore *store, MDB_stat *stat)
 {