NeoMutt  2024-11-14-138-ge5ca67
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 183 of file bdb.c.

184{
185 if (!store)
186 return NULL;
187
188 // Decloak an opaque pointer
189 struct BdbStoreData *sdata = store;
190
191 DBT dkey = { 0 };
192 DBT data = { 0 };
193
194 dbt_init(&dkey, (void *) key, klen);
195 dbt_empty_init(&data);
196 data.flags = DB_DBT_MALLOC;
197
198 sdata->db->get(sdata->db, NULL, &dkey, &data, 0);
199
200 *vlen = data.size;
201 return data.data;
202}
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 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_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 71 of file kc.c.

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

◆ 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 MDB_val dkey = { 0 };
218 MDB_val data = { 0 };
219
220 // Decloak an opaque pointer
221 struct LmdbStoreData *sdata = store;
222
223 dkey.mv_data = (void *) key;
224 dkey.mv_size = klen;
225 data.mv_data = NULL;
226 data.mv_size = 0;
227 int rc = lmdb_get_read_txn(sdata);
228 if (rc != MDB_SUCCESS)
229 {
230 sdata->txn = NULL;
231 mutt_debug(LL_DEBUG2, "txn_renew: %s\n", mdb_strerror(rc));
232 return NULL;
233 }
234 rc = mdb_get(sdata->txn, sdata->db, &dkey, &data);
235 if (rc == MDB_NOTFOUND)
236 {
237 return NULL;
238 }
239 if (rc != MDB_SUCCESS)
240 {
241 mutt_debug(LL_DEBUG2, "mdb_get: %s\n", mdb_strerror(rc));
242 return NULL;
243 }
244
245 *vlen = data.mv_size;
246 return data.mv_data;
247}
#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:97
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
LMDB store.
Definition: lmdb.c:67
MDB_txn * txn
Definition: lmdb.c:69
MDB_dbi db
Definition: lmdb.c:70
+ 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 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
Definition: rocksdb.c:43
rocksdb_readoptions_t * read_options
Definition: rocksdb.c:45
char * err
Definition: rocksdb.c:47

◆ 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 66 of file tc.c.

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

◆ 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}