30 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT 38 #include <sys/types.h> 79 if (
k1->k_len !=
k2->k_len)
85 if (memcmp(
k1->k_data,
k2->k_data,
k1->k_len) == 0)
93 p_link, p_magic, 0x41, 0x67, p_key,
115 const uint64_t k =
key->u_lo;
125 const uint64_t
k1 = key1->
u_lo;
126 const uint64_t
k2 = key2->
u_lo;
131 static,
struct index,
132 i_link, i_magic, 0x43, 0x67, i_fid,
141 #define MAX_IDX_FNAME_LEN (256) 142 #define IDX_CSV_DELIMITER (',') 146 return sprintf(fname,
157 if (idx_fname ==
NULL)
161 rc = access(idx_fname, F_OK);
173 if (idx_fname ==
NULL)
177 rc =
remove(idx_fname);
186 char *idx_fname =
NULL;
194 if (idx_fname ==
NULL)
198 fp = fopen(idx_fname,
"r+");
207 midx->
i_fid = idx_fid;
216 while(fgets(line, 1024,
fp)) {
257 if (idx_fname ==
NULL)
261 fp = fopen(idx_fname,
"w+");
268 buf_len = 1024 * 1024;
287 rc = fwrite(
buf, cursor, 1,
fp);
314 fwrite(
buf, cursor, 1,
fp);
333 struct index **midx,
bool to_load)
336 struct index *found_midx;
339 if (found_midx !=
NULL) {
350 rc = (*midx !=
NULL) ? 1 : 0;
353 rc = (
rc == 0) ? 1 : 0;
380 midx->
i_fid = idx_fid;
457 return M0_RC(-ENOENT);
512 return M0_RC(-ENOENT);
518 for (
i = 0;
i < nr_kvp;
i++) {
565 rc = (nr_inserted > 0) ? 0 : -ENOMEM;
586 return M0_RC(-ENOENT);
592 for (
i = 0;
i < nr_kvp;
i++) {
611 rc = (nr_deleted > 0) ? 0 : -ENOENT;
627 return M0_RC(-ENOENT);
666 if (errno != ENOENT) {
753 .iqo_namei_lookup =
NULL,
754 .iqo_namei_list =
NULL,
774 #undef M0_TRACE_SUBSYSTEM static struct m0_idx_query_ops idx_mock_query_ops
static uint64_t kv_hash(const struct m0_htable *htable, const struct key *key)
static m0_bindex_t indices[ZEROVEC_UT_SEGS_NR]
#define IDX_CSV_DELIMITER
#define m0_htable_for(name, var, htable)
M0_INTERNAL void * m0_htable_lookup(const struct m0_htable *htable, const void *key)
M0_INTERNAL void m0_idx_service_register(int svc_id, struct m0_idx_service_ops *sops, struct m0_idx_query_ops *qops)
static int idx_mock_put(struct m0_op_idx *oi)
M0_INTERNAL void m0_idx_mock_register(void)
struct m0_bufvec * oi_keys
static int make_idx_fname(char *fname, struct m0_uint128 idx_fid)
static int idx_mock_namei_list(struct m0_op_idx *oi)
int(* iqo_namei_create)(struct m0_op_idx *oi)
struct m0_entity in_entity
static int idx_find(struct m0_uint128 idx_fid, struct index **midx, bool to_load)
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)
return M0_ERR(-EOPNOTSUPP)
static struct m0_htable idx_htable
struct m0_htable i_kv_pairs
static int idx_mock_init(void *svc)
static int idx_access(struct m0_uint128 idx_fid)
#define MAX_IDX_FNAME_LEN
static int idx_mock_del(struct m0_op_idx *oi)
static int idx_dump(struct index *midx)
void * m0_alloc(size_t size)
int(* iso_init)(void *svc)
M0_HT_DEFINE(kv_pairs, static, struct kv_pair, struct key)
static int kv_hash_key_eq(const struct key *k1, const struct key *k2)
M0_INTERNAL void m0_tlink_init(const struct m0_tl_descr *d, void *obj)
static struct fdmi_ctx ctx
static int idx_hash_key_eq(const struct m0_uint128 *key1, const struct m0_uint128 *key2)
static char * idx_store_path
struct m0_bufvec * oi_vals
static int idx_mock_fini(void *svc)
static struct m0_net_test_service svc
static int idx_mock_namei_del(struct m0_op_idx *oi)
static int idx_mock_get(struct m0_op_idx *oi)
M0_INTERNAL void m0_htable_del(struct m0_htable *htable, void *amb)
static int idx_mock_namei_lookup(struct m0_op_idx *oi)
static int idx_mock_next(struct m0_op_idx *oi)
static uint64_t idx_hash(const struct m0_htable *htable, const struct m0_uint128 *key)
static struct m0_idx_service_ops idx_mock_svc_ops
static int idx_rm(struct m0_uint128 idx_fid)
static struct index * idx_load(struct m0_uint128 idx_fid)
static int idx_mock_namei_new(struct m0_op_idx *oi)