NeoMutt  2025-12-11-694-ga89709
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_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_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_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_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_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 64 of file gdbm.c.

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

◆ 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 212 of file lmdb.c.

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

◆ 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 124 of file rocksdb.c.

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

◆ 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 64 of file tdb.c.

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