30 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT 38 #include "lib/buf_xc.h" 53 {
CRT,
"create",
"create FID_PARAM, create index" },
54 {
DRP,
"drop",
"drop FID_PARAM, drop existing index"},
55 {
LST,
"list",
"list FID NUM, get indicies" },
56 {
LKP,
"lookup",
"lookup FID_PARAM, lookup index in storage" },
57 {
PUT,
"put",
"put FID_PARAM KEY_PARAM VAL_PARAM, put record" },
58 {
DEL,
"del",
"del FID_PARAM KEY_PARAM, delete record" },
59 {
GET,
"get",
"get FID KEY_PARAM, lookup and returns values by key" },
60 {
NXT,
"next",
"next FID KEY CNT, returns records larger than KEY " },
61 {
GENF,
"genf",
"genf CNT FILE, generate file with several FID" },
62 {
GENV,
"genv",
"genv CNT SIZE FILE, generate file with several " 63 "KEY_PARAM/VAL_PARAM. Note: SIZE > 16" },
86 while ((
c = fgetc(
f)) != EOF) {
109 fids->af_count = fids_nr;
114 f = fopen(&
val[1],
"r");
118 for (
i = 0;
i < fids_nr &&
rc == 0 &&
163 memcpy(target,
next,
sizeof buf - pos);
165 if (fgets(target + (
sizeof buf - pos),
192 if (
value[0] ==
'@') {
194 f = fopen(&
value[1],
"r");
199 for (
i = 0;
rc == 0 &&
i < vals_nr &&
212 keylen = strlen(
value);
331 (
char **)(
NULL), 10);
454 "\t- FID_PARAM - single FID value or @FIDFILENAME\n" 455 "\t- KEY_PARAM - single KEY value or @VFILENAME\n" 456 "\t- VAL_PARAM - single VALUE param or @VFILENAME\n" 457 "\t- FID - value in m0_fid_sscanf format, " 458 "e.g. '<0x780000000000000b:1>', '1:5' and etc\n" 459 "\t- KEY or VALUE - value in m0_xcode_read format, e.g. " 460 "'[0xa:0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a]'\n" 462 "\t\t>m0kv [common args] index create \"1:5\" \n" 463 "\t\t>m0kv [common args] index list \"1:5\" 2 \n" 464 "\t\t>m0kv [common args] index genf 10 fid.txt \n" 465 "\t\t>m0kv [common args] index genv 10 20 keys.txt \n" 466 "\t\t>m0kv [common args] index genv 10 20 vals.txt \n" 467 "\t\t>m0kv [common args] index put \"1:5\" @keys.txt " 469 "\t\t>m0kv [common args] index get \"1:5\" @keys.txt \n" 470 "\t\t>m0kv [common args] index next \"1:5\" " 471 "'[0x02:0x01,0x02]' 3 \n" 472 "\t\t>m0kv [common args] index next \"1:5\" \"0\" 3 -s \n" 473 "\tPossible to supply multiple commands on command line e.g.:\n" 474 "\t\t>m0kv [common args] index create \"1:5\" put \"1:5\"" 475 " \"[0x02:0x01,0x02]\" \"[0x09:0x01,0x02,0x03,0x04,0x05,0x06," 476 "0x07,0x08,0x09]\"\n" 477 "\t\t>m0kv [common args] index drop \"1:5\" create \"1:5\" " 478 "put \"1:5\" @keys.txt @vals.txt\n" 479 "\t\t>m0kv [common args] -s index put \"1:5\" \"Department\" " 481 "\t\tNote: If key already exists put over-write the old value.\n" 482 "\t\t>m0kv [common args] -s index get \"1:5\" \"Department\" " 486 #undef M0_TRACE_SUBSYSTEM static const struct command_descr commands[]
#define M0_ALLOC_ARR(arr, nr)
M0_INTERNAL int m0_xcode_read(struct m0_xcode_obj *obj, const char *str)
void m0_console_printf(const char *fmt,...)
static int fids_load(const char *val, struct m0_fid_arr *fids)
int const char const void * value
static struct m0_rpc_item * item
static int command_id(const char *name)
static struct nlx_ping_client_params * params
return M0_ERR(-EOPNOTSUPP)
static int item_load(FILE *f, char **item, int *size)
static struct m0_addb2_callback c
static int command_assign(struct index_cmd *cmd, int *argc, char ***argv)
const char * cd_help_descr
void * m0_alloc(size_t size)
static const struct m0_fid fids[]
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
void index_parser_print_command_help(void)
static int vals_load(const char *value, struct m0_bufvec *vals)
static bool command_is_valid(struct index_cmd *cmd)
#define M0_XCODE_OBJ(type, ptr)
static int file_lines_count(const char *filename)
static int vals_xcode(const char *value, void *buf, m0_bcount_t *size)
int index_parser_args_process(struct index_ctx *ctx, int argc, char **argv)
struct m0_fid_arr ic_fids
struct m0_cob_domain_id cd_id
M0_INTERNAL int m0_bufvec_empty_alloc(struct m0_bufvec *bufvec, uint32_t num_segs)
#define M0_IMPOSSIBLE(fmt,...)