瀏覽代碼

Remove deprecated functions.

Stefano Cossu 2 年之前
父節點
當前提交
38aff6f8d2
共有 4 個文件被更改,包括 0 次插入188 次删除
  1. 0 23
      include/graph.h
  2. 0 37
      include/store_mdb.h
  3. 0 43
      src/graph.c
  4. 0 85
      src/store_mdb.c

+ 0 - 23
include/graph.h

@@ -62,29 +62,6 @@ LSUP_graph_new_env (
     LSUP_graph_new_env (LSUP_default_env, uri, type)
 
 
-/** @brief Create an array of graphs from pattern matching on an MDB store.
- *
- * The s, p, o lookup terms behave as in #LSUP_store_lookup().
- *
- * @param[in] s Lookup subject.
- *
- * @param[in] p Lookup predicate.
- *
- * @param[in] o Lookup object.
- *
- * @param[in] env Environment to look into. If NULL, it is set to the deafult
- *  environment.
- *
- * @return A NULL-terminated array of graph handles.
- */
-/* TODO Only used in CPython from_lookup. Review the utility of the function.
- * Remove if not useful.
-LSUP_Graph **
-LSUP_graph_new_lookup_env (
-        const LSUP_Env *env, const LSUP_Term *s,
-        const LSUP_Term *p, const LSUP_Term *o);
-*/
-
 /** @brief Shortcut for #LSUP_graph_new_lookup_env() on default MDB store.
  */
 #define LSUP_graph_new_lookup(s, p, o) \

+ 0 - 37
include/store_mdb.h

@@ -324,43 +324,6 @@ LSUP_mdbiter_count (LSUP_MDBIterator *it);
 void LSUP_mdbiter_free (LSUP_MDBIterator *it);
 
 
-/** @brief Gather the contexts of all triples matching a pattern.
- *
- * This function yields a NULL-terminated array of LSUP_Buffer handles for all
- * the triples that match an s, p, o lookup pattern in a store. All values are
- * unique.
- *
- * TODO Implement a free method (and align names). Currently freeing the result
- * is non-trivial and easy to forget:
- *
- *      size_t i = 0;
- *      while (ctx_a[i] != NULL)
- *          free (ctx_a[i++]); // Buffer data are memory-mapped. Not freeing.
- *      free (ctx_a);
- *
- * ss, sp, so arguments are used as in #LSUP_mdbstore_lookup().
- *
- * TODO Remove deprecated function and use the standard lookup method.
- *
- * @param store[in] The store to be queried.
- *
- * @param ss[in] Serialized subject. It may be NULL.
- *
- * @param sp[in] Serialized predicate. It may be NULL.
- *
- * @param so[in] Serialized object. It may be NULL.
- *
- * @return Array of context handles. Memory is allocated by this function and
- * must be freed by the caller.
- */
-/*
-LSUP_Buffer **
-LSUP_mdbstore_lookup_contexts (
-        LSUP_MDBStore *store, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so);
-*/
-
-
 /** @brief Get all namespace prefixes in the store.
  *
  * @param[in] store MDB store to query.

+ 0 - 43
src/graph.c

@@ -88,49 +88,6 @@ LSUP_graph_new_env (
 }
 
 
-/*
-LSUP_Graph **
-LSUP_graph_new_lookup_env (
-        const LSUP_Env *env, const LSUP_Term *s,
-        const LSUP_Term *p, const LSUP_Term *o)
-{
-    if (UNLIKELY (!env)) {
-        log_error ("No valid environment passed. Did you call LSUP_init()?");
-        return NULL;
-    }
-    LSUP_Buffer
-        *ss = LSUP_term_serialize (s),
-        *sp = LSUP_term_serialize (p),
-        *so = LSUP_term_serialize (o);
-
-    LSUP_MDBIterator *it;
-    it = LSUP_mdbstore_lookup (env->mdb_store, ss, sp, so, NULL, NULL);
-
-    LSUP_buffer_free (ss);
-    LSUP_buffer_free (sp);
-    LSUP_buffer_free (so);
-
-    LSUP_Buffer *ctx;
-    // Count for allocation.
-    size_t i;
-    for (i = 0; ctx_a[i] != NULL; i++) {}
-    LSUP_Graph **gr_a = calloc (i + 1, sizeof (*gr_a));
-    if (UNLIKELY (!gr_a)) return NULL;
-
-    for (i = 0; ctx_a[i] != NULL; i++) {
-        gr_a[i] = LSUP_graph_new (
-                LSUP_iriref_new (NULL, NULL), LSUP_STORE_MDB);
-        LSUP_Term *uri = LSUP_term_new_from_buffer (ctx_a[i]);
-        gr_a[i]->uri = uri;
-        LSUP_buffer_free (ctx_a[i]);
-    }
-    free (ctx_a);
-
-    return gr_a;
-}
-*/
-
-
 LSUP_Graph *
 LSUP_graph_copy (const Graph *src)
 {

+ 0 - 85
src/store_mdb.c

@@ -521,17 +521,6 @@ LSUP_mdbstore_add (
 }
 
 
-/*
-static LSUP_Key
-sterm_to_key (
-        LSUP_MDBStore *store, const LSUP_Buffer *sterm)
-{
-    // TODO this will be replaced by a lookup when 128-bit hash is introduced.
-    return LSUP_buffer_hash (sterm);
-}
-*/
-
-
 static LSUP_rc
 key_to_sterm (LSUP_MDBIterator *it, const LSUP_Key key, LSUP_Buffer *sterm)
 {
@@ -894,37 +883,6 @@ fail:
 }
 
 
-/* TODO remove deprecated function.
-LSUP_Buffer **
-LSUP_mdbstore_lookup_contexts (
-        LSUP_MDBStore *store, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so)
-{
-    LSUP_MDBIterator *it = LSUP_mdbstore_lookup (
-            store, ss, sp, so, NULL, NULL);
-
-    LSUP_rc rc = LSUP_NORESULT;
-    KeySet *ckey, *tmp;
-    while (rc != LSUP_END)
-        rc = mdbiter_next_key (it, ckeys);
-
-    size_t i = 0;
-    LSUP_Buffer **ctx_a = calloc (HASH_COUNT (ckeys) + 1, sizeof (*ctx_a));
-    if (UNLIKELY (!ctx_a)) return NULL;
-
-    HASH_ITER (hh, ckeys, ckey, tmp) {
-        ctx_a[i] = BUF_DUMMY;
-        key_to_sterm (it, ckey->key, ctx_a[i++]);
-        HASH_DEL (ckeys, ckey);
-        free (ckey);
-    }
-    LSUP_mdbiter_free (it);
-
-    return ctx_a;
-}
-*/
-
-
 LSUP_rc
 LSUP_mdbstore_nsm_get (LSUP_MDBStore *store, LSUP_NSMap **nsm_p)
 {
@@ -1100,49 +1058,6 @@ fail:
 }
 
 
-/*
-LSUP_rc
-LSUP_mdbstore_tcache_get (LSUP_MDBStore *store)
-{
-    int db_rc, rc = LSUP_NOACTION;
-    MDB_txn *txn = NULL;
-    MDB_cursor *cur = NULL;
-
-    RCCK (mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn));
-
-    db_rc = mdb_cursor_open (txn, store->dbi[IDX_IDK_ID], &cur);
-    if (UNLIKELY (db_rc != MDB_SUCCESS)) {
-        log_error ("Database error: %s", LSUP_strerror (db_rc));
-        rc = LSUP_DB_ERR;
-        goto finally;
-    }
-
-    MDB_val key, data;
-    db_rc = mdb_cursor_get (cur, &key, &data, MDB_FIRST);
-    if (db_rc != MDB_NOTFOUND) rc = LSUP_OK;
-
-    while (db_rc == MDB_SUCCESS) {
-        rc = LSUP_tcache_add_id (
-                *(uint32_t *) key.mv_data, (char *) data.mv_data);
-        if (UNLIKELY (rc != LSUP_OK)) goto finally;
-
-        db_rc = mdb_cursor_get (cur, &key, &data, MDB_NEXT_NODUP);
-    }
-
-    if (db_rc != MDB_NOTFOUND) {
-        log_error ("Database error: %s", LSUP_strerror (db_rc));
-        rc = LSUP_DB_ERR;
-    }
-
-finally:
-    if (cur) mdb_cursor_close (cur);
-    mdb_txn_abort (txn);
-
-    return rc;
-}
-*/
-
-
 /* * * Static functions. * * */