Commit 5c1e7320 authored by David Rich's avatar David Rich Committed by Rob Latham
Browse files

Use in/out argument to communicate size transferred for bulk gets.

parent 60544ef6
......@@ -161,7 +161,7 @@ hg_return_t kv_get(kv_context *context, void *key, void *value)
return ret;
}
std::pair<size_t, int32_t> kv_bulk_get(kv_context *context, void *key, void *data, hg_size_t data_size)
hg_return_t kv_bulk_get(kv_context *context, void *key, void *data, hg_size_t &data_size)
{
hg_return_t ret;
bulk_get_in_t bgin;
......@@ -179,11 +179,10 @@ std::pair<size_t, int32_t> kv_bulk_get(kv_context *context, void *key, void *dat
ret = margo_get_output(context->bulk_get_handle, &bgout);
assert(ret == HG_SUCCESS);
assert(bgout.ret == HG_SUCCESS); // make sure the server side says all is OK
bgsize = bgout.size;
bgret = bgout.ret;
data_size = bgout.size; // report actual size of data transferred to caller
margo_free_output(context->bulk_get_handle, &bgout);
return (bgsize, bgret);
return HG_SUCCESS;
}
hg_return_t kv_close(kv_context *context)
......
......@@ -139,9 +139,9 @@ hg_return_t kv_client_signal_shutdown(kv_context *context);
hg_return_t kv_open(kv_context *context, char *server, char *name,
kv_type keytype, kv_type valtype);
hg_return_t kv_put(kv_context *context, void *key, void *value);
hg_return_t kv_bulk_put(kv_context *context, void *key, void *data, hg_size_t data_size);
hg_return_t kv_bulk_put(kv_context *context, void *key, void *data, hg_size_t &data_size);
hg_return_t kv_get(kv_context *context, void *key, void *value);
std::pair<size_t, int32_t> kv_bulk_get(kv_context *context, void *key, void *data, hg_size_t data_size);
hg_return_t kv_bulk_get(kv_context *context, void *key, void *data, hg_size_t &data_size);
hg_return_t kv_close(kv_context *context);
bench_result *kv_benchmark(kv_context *context, int count);
......
......@@ -102,31 +102,36 @@ int main(int argc, char *argv[])
hret = kv_open(context, server_addr_str, (char*)db, KV_UINT, KV_BULK);
DIE_IF(hret != HG_SUCCESS, "kv_open");
// put
uint64_t key = rank;
int put_val = rank;
std::vector<char> put_data;
put_data.resize(sizeof(put_val));
memcpy(put_data.data(), &put_val, sizeof(put_val));
hret = kv_bulk_put(context, (void*)&key, (void*)put_data.data(), put_data.size());
printf("(put) key %lu, size=%lu, rc=%d\n", key, put_data.size(), (int32_t)ret);
DIE_IF(hret != HG_SUCCESS, "kv_bulk_put");
sleep(2);
// get
int get_val;
std::vector<char> get_data;
get_data.resize(sizeof(get_val));
std::pair<size_t, int32_t> get_ret = kv_bulk_get(context, (void*)&key, (void*)get_data.data(), get_data.size());
size_t data_size = get_ret.first;
int32_t ret = get_ret.second;
printf("(get) key %lu, size=%lu, rc=%d\n", key, data_size, ret);
DIE_IF(ret != HG_SUCCESS, "kv_bulk_get");
memcpy(&get_val, get_data.data(), sizeof(get_val));
printf("key: %lu in: %d out: %d\n", key, put_val, get_val);
// do a set of puts/gets
for (i=0; i<rank; i++) {
uint64_t key = rank+i;
// put
int put_val = rank+i;
std::vector<char> put_data;
put_data.resize(sizeof(put_val));
memcpy(put_data.data(), &put_val, sizeof(put_val));
hret = kv_bulk_put(context, (void*)&key, (void*)put_data.data(), put_data.size());
printf("(put) key %lu, size=%lu, rc=%d\n", key, put_data.size(), (int32_t)ret);
DIE_IF(hret != HG_SUCCESS, "kv_bulk_put");
sleep(2);
// get
int get_val;
std::vector<char> get_data;
get_data.resize(sizeof(get_val));
uint64_t data_size = get_data.size();
printf("(get) key %lu, estimated size=%lu\n", key, data_size);
hret = kv_bulk_get(context, (void*)&key, (void*)get_data.data(), data_size);
DIE_IF(hret != HG_SUCCESS, "kv_bulk_get");
printf("(get) key %lu, actual size=%lu\n", key, data_size);
get_data.resize(data_size);
memcpy(&get_val, get_data.data(), sizeof(get_val));
printf("key: %lu in: %d out: %d\n", key, put_val, get_val);
}
// close
hret = kv_close(context);
......
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