I’ve been using range reads in the FoundationDB C API with the following code:
FDBFuture *future = fdb_transaction_get_range(tr, beginKey, beginKeySize, 0, 0,
endKey, endKeySize, 0, 0, limit, 0, FDB_STREAMING_MODE_WANT_ALL, 0, 0, 0);
//Wait for future and check errors...
int outMore, outCount;
FDBKeyValue *keyValue = fdb_future_get_keyvalue_array(future, &keyValue, &outCount, &outMore);
printf("%d\n", outCount);
printf("%.*s\n", keyValue[0].key_length, keyValue[0].key);
printf("%.*s\n", keyValue[1].key_length, keyValue[1].key);
printf("%.*s\n", keyValue[2].key_length, keyValue[2].key);
printf("%.*s\n", keyValue[3].key_length, keyValue[3].key);
When I run getrange '' \xff
, I get:
`hello' is `world'
`hi' is `everyone'
`mykey` is `myvalue'
However, the output of my C program is:
3
hello
hi
The first pair (keyValue[0]
) is empty. The next pairs are present, however I would expect hello
to be at position 0, and hi
to be at position 1. When reading keyValue[3]
, nothing is present, as expected.
I have a few questions:
- How can I get all 3 pairs?
- Why is
keyValue[0]
empty?
I would appreciate any help. Thanks!