NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN

Fetch a Value from the Store. More...

+ Collaboration diagram for fetch():

Functions

static void * store_bdb_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_gdbm_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_kyotocabinet_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_lmdb_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_qdbm_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_rocksdb_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_tokyocabinet_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 
static void * store_tdb_fetch (void *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -. More...
 

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 ( void *  store,
const char *  key,
size_t  klen,
size_t *  vlen 
)
static

Implements StoreOps::fetch() -.

Definition at line 158 of file bdb.c.

159 {
160  if (!store)
161  return NULL;
162 
163  DBT dkey;
164  DBT data;
165 
166  struct StoreDbCtx *ctx = store;
167 
168  dbt_init(&dkey, (void *) key, klen);
169  dbt_empty_init(&data);
170  data.flags = DB_DBT_MALLOC;
171 
172  ctx->db->get(ctx->db, NULL, &dkey, &data, 0);
173 
174  *vlen = data.size;
175  return data.data;
176 }
Berkeley DB context.
Definition: bdb.c:48
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB context.
Definition: bdb.c:62
DB * db
Definition: bdb.c:51
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB context.
Definition: bdb.c:76
+ Here is the call graph for this function:

◆ store_gdbm_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 60 of file gdbm.c.

61 {
62  if (!store)
63  return NULL;
64 
65  datum dkey;
66  datum data;
67 
68  GDBM_FILE db = store;
69 
70  dkey.dptr = (char *) key;
71  dkey.dsize = klen;
72  data = gdbm_fetch(db, dkey);
73 
74  *vlen = data.dsize;
75  return data.dptr;
76 }
DB * db
Definition: bdb.c:51

◆ store_kyotocabinet_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 71 of file kc.c.

72 {
73  if (!store)
74  return NULL;
75 
76  KCDB *db = store;
77  return kcdbget(db, key, klen, vlen);
78 }
DB * db
Definition: bdb.c:51

◆ store_lmdb_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 180 of file lmdb.c.

181 {
182  if (!store)
183  return NULL;
184 
185  MDB_val dkey;
186  MDB_val data;
187 
188  struct StoreLmdbCtx *ctx = store;
189 
190  dkey.mv_data = (void *) key;
191  dkey.mv_size = klen;
192  data.mv_data = NULL;
193  data.mv_size = 0;
194  int rc = mdb_get_r_txn(ctx);
195  if (rc != MDB_SUCCESS)
196  {
197  ctx->txn = NULL;
198  mutt_debug(LL_DEBUG2, "txn_renew: %s\n", mdb_strerror(rc));
199  return NULL;
200  }
201  rc = mdb_get(ctx->txn, ctx->db, &dkey, &data);
202  if (rc == MDB_NOTFOUND)
203  {
204  return NULL;
205  }
206  if (rc != MDB_SUCCESS)
207  {
208  mutt_debug(LL_DEBUG2, "mdb_get: %s\n", mdb_strerror(rc));
209  return NULL;
210  }
211 
212  *vlen = data.mv_size;
213  return data.mv_data;
214 }
MDB_txn * txn
Definition: lmdb.c:59
LMDB context.
Definition: lmdb.c:56
Log at debug level 2.
Definition: logging.h:41
static int mdb_get_r_txn(struct StoreLmdbCtx *ctx)
Get an LMDB read transaction.
Definition: lmdb.c:69
MDB_dbi db
Definition: lmdb.c:60
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
+ Here is the call graph for this function:

◆ store_qdbm_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 55 of file qdbm.c.

56 {
57  if (!store)
58  return NULL;
59 
60  VILLA *db = store;
61  int sp = 0;
62  void *rv = vlget(db, key, klen, &sp);
63  *vlen = sp;
64  return rv;
65 }
MDB_dbi db
Definition: lmdb.c:60

◆ store_rocksdb_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 92 of file rocksdb.c.

93 {
94  if (!store)
95  return NULL;
96 
97  struct RocksDbCtx *ctx = store;
98 
99  void *rv = rocksdb_get(ctx->db, ctx->read_options, key, klen, vlen, &ctx->err);
100  if (ctx->err)
101  {
102  rocksdb_free(ctx->err);
103  ctx->err = NULL;
104  return NULL;
105  }
106 
107  return rv;
108 }
rocksdb_t * db
Definition: rocksdb.c:41
rocksdb_readoptions_t * read_options
Definition: rocksdb.c:43
char * err
Definition: rocksdb.c:45
Berkeley DB context.
Definition: rocksdb.c:39

◆ store_tokyocabinet_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 64 of file tc.c.

65 {
66  if (!store)
67  return NULL;
68 
69  int sp = 0;
70  TCBDB *db = store;
71  void *rv = tcbdbget(db, key, klen, &sp);
72  *vlen = sp;
73  return rv;
74 }
rocksdb_t * db
Definition: rocksdb.c:41

◆ store_tdb_fetch()

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

Implements StoreOps::fetch() -.

Definition at line 57 of file tdb.c.

58 {
59  if (!store)
60  return NULL;
61 
62  TDB_CONTEXT *db = store;
63  TDB_DATA dkey;
64  TDB_DATA data;
65 
66  dkey.dptr = (unsigned char *) key;
67  dkey.dsize = klen;
68  data = tdb_fetch(db, dkey);
69 
70  *vlen = data.dsize;
71  return data.dptr;
72 }
rocksdb_t * db
Definition: rocksdb.c:41