ConfD User Community

Maapi_query_result_count

Hi,

Where can i get the the document of this function maapi_query_result_count?

Sometimes this function return -1, and the error message is "Unexpected data on socket! ", I don’t know what happened.

And by the way what the exact value of chunk_size parameter should be of function maapi_query_start(), I set it to 1000 as the example code shows, but I don’t know the proper value.

Hi,

See for example these previous posts:


@cohult Thanks for the reply, I’ll check my threads.

By the way , would you please provide me the explaination of maapi_query_result_count?

The expression provided as argument to maapi_query_start must evaluate to a node set; maapi_query_result_count returns CONFD_ERR or size of this node set.

As you mentioned this api:

int maapi_query_start(int sock, int thandle, const char *expr,
const char *context_node, int chunk_size, 
int initial_offset, enum
confd_query_result_type result_as, int nselect, const char *select[],
int nsort, const char *sort[]);

and User Guide says:

chunk_size How many results to return at a time. If set to 0 a default number will be used.

so, if I have list that has more than 2000 instances inside, and I set chunk_size = 1000, what does maapi_query_result_count returns? 2000 or 1000?

It returns the size of the whole node set, i.e. 2000 in your case. It is useful right after maapi_start_query, it tells you what you should expect. You do not need to call any API function to know how large a particular chunk is - the structure confd_query_result contains field nresults that indicates it.