NeoMutt  2024-04-25-85-g27bab4
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches

Fetch a Value from the Store. More...

+ Collaboration diagram for fetch():

Functions

static void * store_bdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_gdbm_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_kyotocabinet_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_lmdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_qdbm_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_rocksdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_tokyocabinet_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void * store_tdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 

Detailed Description

Fetch a Value from the Store.

Parameters
[in]storeStore retrieved via open()
[in]keyKey identifying the record
[in]klenLength of the Key string
[out]vlenLength of the Value
Return values
ptrSuccess, Value associated with the Key
NULLError, or Key not found

Function Documentation

◆ store_bdb_fetch()

static void * store_bdb_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 182 of file bdb.c.

183{
184 if (!store)
185 return NULL;
186
187 // Decloak an opaque pointer
188 struct BdbStoreData *sdata = store;
189
190 DBT dkey = { 0 };
191 DBT data = { 0 };
192
193 dbt_init(&dkey, (void *) key, klen);
194 dbt_empty_init(&data);
195 data.flags = DB_DBT_MALLOC;
196
197 sdata->db->get(sdata->db, NULL, &dkey, &data, 0);
198
199 *vlen = data.size;
200 return data.data;
201}
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB thing.
Definition: bdb.c:102
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB thing.
Definition: bdb.c:88
Berkeley DB Store.
Definition: bdb.c:47
DB * db
Definition: bdb.c:49
+ Here is the call graph for this function:

◆ store_gdbm_fetch()

static void * store_gdbm_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 62 of file gdbm.c.

63{
64 if (!store || (klen > INT_MAX))
65 return NULL;
66
67 datum dkey = { 0 };
68 datum data = { 0 };
69
70 // Decloak an opaque pointer
71 GDBM_FILE db = store;
72
73 dkey.dptr = (char *) key;
74 dkey.dsize = klen;
75 data = gdbm_fetch(db, dkey);
76
77 *vlen = data.dsize;
78 return data.dptr;
79}

◆ store_kyotocabinet_fetch()

static void * store_kyotocabinet_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 70 of file kc.c.

72{
73 if (!store)
74 return NULL;
75
76 // Decloak an opaque pointer
77 KCDB *db = store;
78 return kcdbget(db, key, klen, vlen);
79}

◆ store_lmdb_fetch()

static void * store_lmdb_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 211 of file lmdb.c.

212{
213 if (!store)
214 return NULL;
215
216 MDB_val dkey = { 0 };
217 MDB_val data = { 0 };
218
219 // Decloak an opaque pointer
220 struct LmdbStoreData *sdata = store;
221
222 dkey.mv_data = (void *) key;
223 dkey.mv_size = klen;
224 data.mv_data = NULL;
225 data.mv_size = 0;
226 int rc = lmdb_get_read_txn(sdata);
227 if (rc != MDB_SUCCESS)
228 {
229 sdata->txn = NULL;
230 mutt_debug(LL_DEBUG2, "txn_renew: %s\n", mdb_strerror(rc));
231 return NULL;
232 }
233 rc = mdb_get(sdata->txn, sdata->db, &dkey, &data);
234 if (rc == MDB_NOTFOUND)
235 {
236 return NULL;
237 }
238 if (rc != MDB_SUCCESS)
239 {
240 mutt_debug(LL_DEBUG2, "mdb_get: %s\n", mdb_strerror(rc));
241 return NULL;
242 }
243
244 *vlen = data.mv_size;
245 return data.mv_data;
246}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int lmdb_get_read_txn(struct LmdbStoreData *sdata)
Get an LMDB read transaction.
Definition: lmdb.c:96
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
LMDB store.
Definition: lmdb.c:66
MDB_txn * txn
Definition: lmdb.c:68
MDB_dbi db
Definition: lmdb.c:69
+ Here is the call graph for this function:

◆ store_qdbm_fetch()

static void * store_qdbm_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 56 of file qdbm.c.

57{
58 if (!store)
59 return NULL;
60
61 // Decloak an opaque pointer
62 VILLA *db = store;
63 int sp = 0;
64 void *rv = vlget(db, key, klen, &sp);
65 *vlen = sp;
66 return rv;
67}

◆ store_rocksdb_fetch()

static void * store_rocksdb_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 123 of file rocksdb.c.

124{
125 if (!store)
126 return NULL;
127
128 // Decloak an opaque pointer
129 struct RocksDbStoreData *sdata = store;
130
131 void *rv = rocksdb_get(sdata->db, sdata->read_options, key, klen, vlen, &sdata->err);
132 if (sdata->err)
133 {
134 rocksdb_free(sdata->err);
135 sdata->err = NULL;
136 return NULL;
137 }
138
139 return rv;
140}
RocksDB store.
Definition: rocksdb.c:41
rocksdb_t * db
Definition: rocksdb.c:42
rocksdb_readoptions_t * read_options
Definition: rocksdb.c:44
char * err
Definition: rocksdb.c:46

◆ store_tokyocabinet_fetch()

static void * store_tokyocabinet_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 65 of file tc.c.

67{
68 if (!store)
69 return NULL;
70
71 // Decloak an opaque pointer
72 TCBDB *db = store;
73 int sp = 0;
74 void *rv = tcbdbget(db, key, klen, &sp);
75 *vlen = sp;
76 return rv;
77}

◆ store_tdb_fetch()

static void * store_tdb_fetch ( StoreHandle store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Fetch a Value from the Store - Implements StoreOps::fetch() -.

Definition at line 62 of file tdb.c.

63{
64 if (!store)
65 return NULL;
66
67 // Decloak an opaque pointer
68 TDB_CONTEXT *db = store;
69 TDB_DATA dkey;
70 TDB_DATA data;
71
72 dkey.dptr = (unsigned char *) key;
73 dkey.dsize = klen;
74 data = tdb_fetch(db, dkey);
75
76 *vlen = data.dsize;
77 return data.dptr;
78}