On Friday, June 18, 2021 5:49:50 PM EDT FLAME KAISER wrote: > Hello Everyone, I am working on a Project-Based on ceph which Integrates > PDC API with Ceph Rados with the help of librados Library. > I am working under the UC Santa Cruz organization Under the Google summer > of code 2021 Program. I am stuck at storing the Key-Value(integer form) > Pairs in RADOS. > I tried running the code, but I am unable to read the values from > associated keys, Can anyone please help me in reading/Write operations of It's not entirely clear from this description what the intended result is and what the actual result is, leaving us to guess at things from the structure of your code snippet below. > Key-value pairs. > My dummy code is : > rados_write_op_t write_op = rados_create_write_op(); > printf("Created an Func for Object Operations"); > rados_write_op_create(write_op(),LIBRADOS_CREATE_EXCLUSIVE, NULL); This could possibly be a typo in your email because I don't think `write_op(),` will compile. I do not think write_op is callable. > printf("Created an Object For operation"); > > size_t p = 2; //No.of key value Pairs > char *key1="key1", *key2 = "key2"; //keys > > char *key_arr[2] = {key1,key2}; //Pointer array to keys > int v1 = 21,v2 = 22; //values to associate to each key (integer > form) This is the first thing that jumped out at me when I skimmed your message. While this may work I don't recommend it as the API is based on strings/ buffers. If you haven't already got experience working with (human readable) string data, do that first and then only move on to storing raw data in the values. Try using one of the many functions to create a string representation of the ints. Secondly, even if you ultimately want to store binary data in the value, I suggest using a function that encodes the integer value into a binary representation. This could be important if your code needs to be portable across different architectures. And is, IMO, just a good practice. > int *vals[2] = {&v1,&v2}; //pointer array storing the location of > values to set > > int lens[2] = {4,4}; Similar to my note above, hard-coding this is not a good practice and while it may work in the short term, can come back and cause problems for you sooner than you think. > rados_write_op_omap_set(write_op, key_arr, vals, lens, p); //func > used to set those key-value pairs > printf("Set the key/value pairs on an object\n"); > rados_write_op_operate(write_op,io,"keytest",NULL,0); //operated on > object "keytest" The `rados_write_op_operate` returns a (negative) error code. You should check this in your real code and see if the write op succeeded (error is zero) or failed. > rados_release_write_op(write_op); > rados_read_op_t read_op = rados_create_read_op(); > rados_omap_iter_t iter_vals; > int r_vals; > > > rados_read_op_omap_get_vals_by_keys(read_op,key_arr,p,&iter_vals,&r_vals); > //To read the values of keys > rados_read_op_operate(read_op,io,"keytest",0); Again, you will want to check the return from this function. > printf("%D\n",r_vals); I don't know if "%D" is a typo for "%d" but I don't think it will print anything useful. Next, I'm not sure if printing r_vals alone will help you much, as the documentation comment says this is "prval" - "where to store the return value from this action". IIRC this means it will be zero on success. If you want to see any values returned from this read op, you'll need to interact with the rados_omap_iter_t and the functions made for interacting with this type like rados_omap_get_next and rados_omap_get_end. > rados_release_read_op(read_op); General debugging tip: start small and confirm as much as you can as you go along. So in this case, try making sure all of the omap set functionality works w/o error before trying to read the omap OR use another tool that you know properly sets omap values and then write your omap read function based on that test. > Thanks > Mishal > LNM IIT JAIPUR > India Hope this was useful & good luck! _______________________________________________ Dev mailing list -- dev@xxxxxxx To unsubscribe send an email to dev-leave@xxxxxxx