NeoMutt  2024-03-23-23-gec7045
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 181 of file bdb.c.

182{
183 if (!store)
184 return NULL;
185
186 // Decloak an opaque pointer
187 struct BdbStoreData *sdata = store;
188
189 DBT dkey = { 0 };
190 DBT data = { 0 };
191
192 dbt_init(&dkey, (void *) key, klen);
193 dbt_empty_init(&data);
194 data.flags = DB_DBT_MALLOC;
195
196 sdata->db->get(sdata->db, NULL, &dkey, &data, 0);
197
198 *vlen = data.size;
199 return data.data;
200}
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB thing.
Definition: bdb.c:101
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB thing.
Definition: bdb.c:87
Berkeley DB Store.
Definition: bdb.c:46
DB * db
Definition: bdb.c:48
+ 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 205 of file lmdb.c.

206{
207 if (!store)
208 return NULL;
209
210 MDB_val dkey = { 0 };
211 MDB_val data = { 0 };
212
213 // Decloak an opaque pointer
214 struct LmdbStoreData *sdata = store;
215
216 dkey.mv_data = (void *) key;
217 dkey.mv_size = klen;
218 data.mv_data = NULL;
219 data.mv_size = 0;
220 int rc = lmdb_get_read_txn(sdata);
221 if (rc != MDB_SUCCESS)
222 {
223 sdata->txn = NULL;
224 mutt_debug(LL_DEBUG2, "txn_renew: %s\n", mdb_strerror(rc));
225 return NULL;
226 }
227 rc = mdb_get(sdata->txn, sdata->db, &dkey, &data);
228 if (rc == MDB_NOTFOUND)
229 {
230 return NULL;
231 }
232 if (rc != MDB_SUCCESS)
233 {
234 mutt_debug(LL_DEBUG2, "mdb_get: %s\n", mdb_strerror(rc));
235 return NULL;
236 }
237
238 *vlen = data.mv_size;
239 return data.mv_data;
240}
#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:95
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
LMDB store.
Definition: lmdb.c:65
MDB_txn * txn
Definition: lmdb.c:67
MDB_dbi db
Definition: lmdb.c:68
+ 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 120 of file rocksdb.c.

121{
122 if (!store)
123 return NULL;
124
125 // Decloak an opaque pointer
126 struct RocksDbStoreData *sdata = store;
127
128 void *rv = rocksdb_get(sdata->db, sdata->read_options, key, klen, vlen, &sdata->err);
129 if (sdata->err)
130 {
131 rocksdb_free(sdata->err);
132 sdata->err = NULL;
133 return NULL;
134 }
135
136 return rv;
137}
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}