Motr  M0
idx_mock.c File Reference
#include "motr/client.h"
#include "motr/client_internal.h"
#include "motr/addb.h"
#include "motr/idx.h"
#include "lib/errno.h"
#include "lib/trace.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Include dependency graph for idx_mock.c:

Go to the source code of this file.

Data Structures

struct  key
 
struct  val
 
struct  kv_pair
 
struct  index
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT
 
#define MAX_IDX_FNAME_LEN   (256)
 
#define IDX_CSV_DELIMITER   (',')
 

Functions

static uint64_t kv_hash (const struct m0_htable *htable, const struct key *key)
 
static int kv_hash_key_eq (const struct key *k1, const struct key *k2)
 
 M0_HT_DESCR_DEFINE (kv_pairs, "Hash of key value pairs", static, struct kv_pair, p_link, p_magic, 0x41, 0x67, p_key, kv_hash, kv_hash_key_eq)
 
 M0_HT_DEFINE (kv_pairs, static, struct kv_pair, struct key)
 
static uint64_t idx_hash (const struct m0_htable *htable, const struct m0_uint128 *key)
 
static int idx_hash_key_eq (const struct m0_uint128 *key1, const struct m0_uint128 *key2)
 
 M0_HT_DESCR_DEFINE (indices, "Hash of key value pairs", static, struct index, i_link, i_magic, 0x43, 0x67, i_fid, idx_hash, idx_hash_key_eq)
 
 M0_HT_DEFINE (indices, static, struct index, struct m0_uint128)
 
static int make_idx_fname (char *fname, struct m0_uint128 idx_fid)
 
static int idx_access (struct m0_uint128 idx_fid)
 
static int idx_rm (struct m0_uint128 idx_fid)
 
static struct indexidx_load (struct m0_uint128 idx_fid)
 
static int idx_dump (struct index *midx)
 
static int idx_find (struct m0_uint128 idx_fid, struct index **midx, bool to_load)
 
static int idx_mock_namei_new (struct m0_op_idx *oi)
 
static int idx_mock_namei_del (struct m0_op_idx *oi)
 
static int idx_mock_namei_lookup (struct m0_op_idx *oi)
 
static int idx_mock_namei_list (struct m0_op_idx *oi)
 
static int idx_mock_get (struct m0_op_idx *oi)
 
static int idx_mock_put (struct m0_op_idx *oi)
 
static int idx_mock_del (struct m0_op_idx *oi)
 
static int idx_mock_next (struct m0_op_idx *oi)
 
static int idx_mock_init (void *svc)
 
static int idx_mock_fini (void *svc)
 
M0_INTERNAL void m0_idx_mock_register (void)
 

Variables

static char * idx_store_path = NULL
 
static struct m0_htable idx_htable
 
static struct m0_idx_query_ops idx_mock_query_ops
 
static struct m0_idx_service_ops idx_mock_svc_ops
 

Macro Definition Documentation

◆ IDX_CSV_DELIMITER

#define IDX_CSV_DELIMITER   (',')

Definition at line 142 of file idx_mock.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT

Definition at line 30 of file idx_mock.c.

◆ MAX_IDX_FNAME_LEN

#define MAX_IDX_FNAME_LEN   (256)

----------------------------------------------------------------------—*

Index store *

Definition at line 141 of file idx_mock.c.

Function Documentation

◆ idx_access()

static int idx_access ( struct m0_uint128  idx_fid)
static

Definition at line 151 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ idx_dump()

static int idx_dump ( struct index midx)
static

Definition at line 243 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ idx_find()

static int idx_find ( struct m0_uint128  idx_fid,
struct index **  midx,
bool  to_load 
)
static

Lookup an index in hash table and disks.

Parameters
idx_fidindex's FID.
midxwhere a found or loaded index is store.
to_loadindex is loaded into memory if it is set.
Returns
0: not found, 1: found, < 0 error.

Definition at line 332 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ idx_hash()

static uint64_t idx_hash ( const struct m0_htable htable,
const struct m0_uint128 key 
)
static

Generates a hash key for an entity.

Definition at line 112 of file idx_mock.c.

◆ idx_hash_key_eq()

static int idx_hash_key_eq ( const struct m0_uint128 key1,
const struct m0_uint128 key2 
)
static

Compares the hash keys of two entities.

Definition at line 122 of file idx_mock.c.

◆ idx_load()

static struct index* idx_load ( struct m0_uint128  idx_fid)
static

Definition at line 183 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ idx_mock_del()

static int idx_mock_del ( struct m0_op_idx oi)
static

Definition at line 570 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_fini()

static int idx_mock_fini ( void *  svc)
static

Definition at line 685 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_get()

static int idx_mock_get ( struct m0_op_idx oi)
static

Definition at line 434 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_init()

static int idx_mock_init ( void *  svc)
static

Definition at line 646 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_namei_del()

static int idx_mock_namei_del ( struct m0_op_idx oi)
static

Definition at line 387 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_namei_list()

static int idx_mock_namei_list ( struct m0_op_idx oi)
static

Definition at line 429 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_namei_lookup()

static int idx_mock_namei_lookup ( struct m0_op_idx oi)
static

Definition at line 424 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_namei_new()

static int idx_mock_namei_new ( struct m0_op_idx oi)
static

----------------------------------------------------------------------—*

Query Operations *

Definition at line 363 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_next()

static int idx_mock_next ( struct m0_op_idx oi)
static

Definition at line 616 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_mock_put()

static int idx_mock_put ( struct m0_op_idx oi)
static

Definition at line 489 of file idx_mock.c.

Here is the call graph for this function:

◆ idx_rm()

static int idx_rm ( struct m0_uint128  idx_fid)
static

Definition at line 167 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kv_hash()

static uint64_t kv_hash ( const struct m0_htable htable,
const struct key key 
)
static

Definition at line 65 of file idx_mock.c.

◆ kv_hash_key_eq()

static int kv_hash_key_eq ( const struct key k1,
const struct key k2 
)
static

Definition at line 77 of file idx_mock.c.

Here is the call graph for this function:

◆ M0_HT_DEFINE() [1/2]

M0_HT_DEFINE ( kv_pairs  ,
static  ,
struct kv_pair  ,
struct key   
)

◆ M0_HT_DEFINE() [2/2]

M0_HT_DEFINE ( indices  ,
static  ,
struct index  ,
struct m0_uint128   
)

◆ M0_HT_DESCR_DEFINE() [1/2]

M0_HT_DESCR_DEFINE ( kv_pairs  ,
"Hash of key value pairs"  ,
static  ,
struct kv_pair  ,
p_link  ,
p_magic  ,
0x41  ,
0x67  ,
p_key  ,
kv_hash  ,
kv_hash_key_eq   
)

◆ M0_HT_DESCR_DEFINE() [2/2]

M0_HT_DESCR_DEFINE ( indices  ,
"Hash of key value pairs"  ,
static  ,
struct index  ,
i_link  ,
i_magic  ,
0x43  ,
0x67  ,
i_fid  ,
idx_hash  ,
idx_hash_key_eq   
)

◆ m0_idx_mock_register()

M0_INTERNAL void m0_idx_mock_register ( void  )

Definition at line 768 of file idx_mock.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_idx_fname()

static int make_idx_fname ( char *  fname,
struct m0_uint128  idx_fid 
)
static

Definition at line 144 of file idx_mock.c.

Here is the caller graph for this function:

Variable Documentation

◆ idx_htable

struct m0_htable idx_htable
static

Definition at line 135 of file idx_mock.c.

◆ idx_mock_query_ops

struct m0_idx_query_ops idx_mock_query_ops
static
Initial value:
= {
.iqo_namei_create = idx_mock_namei_new,
.iqo_namei_delete = idx_mock_namei_del,
.iqo_namei_lookup = idx_mock_namei_lookup,
.iqo_namei_list = idx_mock_namei_list,
.iqo_get = idx_mock_get,
.iqo_put = idx_mock_put,
.iqo_del = idx_mock_del,
.iqo_next = idx_mock_next,
}
static int idx_mock_put(struct m0_op_idx *oi)
Definition: idx_mock.c:489
static int idx_mock_namei_list(struct m0_op_idx *oi)
Definition: idx_mock.c:429
static int idx_mock_del(struct m0_op_idx *oi)
Definition: idx_mock.c:570
static int idx_mock_namei_del(struct m0_op_idx *oi)
Definition: idx_mock.c:387
static int idx_mock_get(struct m0_op_idx *oi)
Definition: idx_mock.c:434
static int idx_mock_namei_lookup(struct m0_op_idx *oi)
Definition: idx_mock.c:424
static int idx_mock_next(struct m0_op_idx *oi)
Definition: idx_mock.c:616
static int idx_mock_namei_new(struct m0_op_idx *oi)
Definition: idx_mock.c:363

Definition at line 634 of file idx_mock.c.

◆ idx_mock_svc_ops

struct m0_idx_service_ops idx_mock_svc_ops
static
Initial value:
= {
.iso_init = idx_mock_init,
.iso_fini = idx_mock_fini
}
static int idx_mock_init(void *svc)
Definition: idx_mock.c:646
static int idx_mock_fini(void *svc)
Definition: idx_mock.c:685

Definition at line 703 of file idx_mock.c.

◆ idx_store_path

char* idx_store_path = NULL
static

Definition at line 42 of file idx_mock.c.