Commit 94d47c21 authored by Matthieu Dorier's avatar Matthieu Dorier

adapted to new SDSKV API and corrected a bug

parent 0a5b143b
......@@ -319,18 +319,18 @@ void read_op_exec_omap_get_keys(void* u, const char* start_after, uint64_t max_r
ERROR fprintf(stderr, "sdskv_list_keys returned %d\n", ret);
break;
}
const char* k;
const char* k = NULL;
for(auto i = 0; i < keys_retrieved && count < max_return; i++, count++) {
// extract the actual key part, without the oid
k = ((omap_key_t*)keys[i])->key;
/* this key is not part of the same object, we should leave the loop */
if(((omap_key_t*)keys[i])->oid != oid) goto out; /* ugly way of leaving the loop, I know ... */
omap_iter_append(*iter, k, nullptr, 0);
}
strcpy(lb->key, k);
lb_size = strlen(k) + sizeof(omap_key_t);
if(k != NULL) {
strcpy(lb->key, k);
lb_size = strlen(k) + sizeof(omap_key_t);
}
} while(keys_retrieved == max_keys && count < max_return);
out:
......
......@@ -22,15 +22,42 @@ int mobject_sdskv_provider_setup(sdskv_provider_t sdskv_prov)
{
int ret;
/* SDSKV provider initialization */
sdskv_provider_add_comparison_function(sdskv_prov, "mobject_oid_map_compare", oid_map_compare);
sdskv_provider_add_comparison_function(sdskv_prov, "mobject_name_map_compare", name_map_compare);
sdskv_provider_add_comparison_function(sdskv_prov, "mobject_seg_map_compare", seg_map_compare);
sdskv_provider_add_comparison_function(sdskv_prov, "mobject_omap_map_compare", omap_map_compare);
sdskv_database_id_t oid_map_id, name_map_id, seg_map_id, omap_map_id;
ret = sdskv_provider_add_database(sdskv_prov, "oid_map", "", KVDB_MAP, &oid_map_compare, &oid_map_id);
ASSERT(ret == 0, "sdskv_provider_add_database() failed to add database \"oid_map\" (ret = %d)\n", ret);
ret = sdskv_provider_add_database(sdskv_prov, "name_map", "", KVDB_MAP, &name_map_compare, &name_map_id);
ASSERT(ret == 0, "sdskv_provider_add_database() failed to add database \"name_map\" (ret = %d)\n", ret);
ret = sdskv_provider_add_database(sdskv_prov, "seg_map", "", KVDB_MAP, &seg_map_compare, &seg_map_id);
ASSERT(ret == 0, "sdskv_provider_add_database() failed to add database \"seg_map\" (ret = %d)\n", ret);
ret = sdskv_provider_add_database(sdskv_prov, "omap_map", "", KVDB_MAP, &omap_map_compare, &omap_map_id);
ASSERT(ret == 0, "sdskv_provider_add_database() failed to add database \"omap_map\" (ret = %d)\n", ret);
sdskv_config_t config;
memset(&config,0,sizeof(config));
config.db_name = "oid_map";
config.db_path = "";
config.db_type = KVDB_MAP;
config.db_comp_fn_name = "mobject_oid_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &oid_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"oid_map\" (ret = %d)\n", ret);
config.db_name = "name_map";
config.db_path = "";
config.db_type = KVDB_MAP;
config.db_comp_fn_name = "mobject_name_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &name_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"name_map\" (ret = %d)\n", ret);
config.db_name = "seg_map";
config.db_path = "";
config.db_type = KVDB_MAP;
config.db_comp_fn_name = "mobject_seg_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &seg_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"seg_map\" (ret = %d)\n", ret);
config.db_name = "omap_map";
config.db_path = "";
config.db_type = KVDB_MAP;
config.db_comp_fn_name = "mobject_omap_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &omap_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"omap_map\" (ret = %d)\n", ret);
}
static int oid_map_compare(const void* k1, size_t sk1, const void* k2, size_t sk2)
......
......@@ -21,18 +21,24 @@ int main(int argc, char** argv)
// Add a "create" operation
mobject_store_write_op_create(write_op, LIBMOBJECT_CREATE_EXCLUSIVE, NULL);
// Add a "write_full" operation to write "AAAABBBB"
// Content is now "AAAABBBB"
mobject_store_write_op_write_full(write_op, content, 8);
// Add a "write" operation to write "CCCC"
// Content is now "AAAABBBBCCCC"
mobject_store_write_op_write(write_op, content+8, 4, 8);
// Add a "writesame" operation to write "DDDD" in two "DD"
// Content is now "AAAABBBBCCCCDDDD"
mobject_store_write_op_writesame(write_op, content+12, 2, 4, 12);
// Add a "append" operation to append "EEEEFFFF"
// Content is now "AAAABBBBCCCCDDDDEEEEFFFF"
mobject_store_write_op_append(write_op, content+16, 8);
// Add a "remove" operation
// mobject_store_write_op_remove(write_op);
// Add a "truncate" operation to remove the "FFFF" part
// Content is now "AAAABBBBCCCCDDDDEEEE"
mobject_store_write_op_truncate(write_op, 20);
// Add a "zero" operation zero-ing the "BBBBCCCC"
// Content is now "AAAA********DDDDEEEE"
mobject_store_write_op_zero(write_op, 4, 8);
// Add a "omap_set" operation
const char* keys[] = { "matthieu", "rob", "shane", "phil", "robl" };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment