Getting the number of records in a set


#1

Is there any function in the C client library to find out the number of records present in a given set? Aql shows this in ‘objects’ column. Is the same data available via the C client library as well?


#2

Use aerospike_info_any() with request string in format: sets/{namespace}/{set}

char* res = NULL;
as_status status = aerospike_info_any(as, &err, NULL, "sets/test/myset", &res);

The result string will look something like this:

objects=287:tombstones=0:memory_data_bytes=51430:truncate_lut=0:stop-writes-count=0:set-enable-xdr=use-default:disable-eviction=false;

You are responsible for parsing the “objects” value from this string and destroying string when done.


#3

In a multi-node cluster, will this function return the number of total objects or the number of objects stored on a particular node?


#4

The function will return the total objects for the entire cluster in that namespace/set.


#5

Hi Brian,

My observation was different. Please find below the details. Replication factor: 1 No. of nodes: 2

aerospike_info_any returned the count of objects on just 1 of the 2 nodes(The count was returned from the node which I had given to “aerospike_init()”).

Therefore, I used, aerospike_info_foreach() to get the count from each node and then summed them and divided by the replication factor(which was 1 in this case), to get the correct total count.


#6

Sorry, my mistake. The object count is indeed per node. Getting the count from each node, summing and then dividing by replication factor is correct.


#7

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.