HDFql Reference Manual v2.6.0

5.2.57hdfql_variable_get_count

Syntax

long long hdfql_variable_get_count(const void *variable)

Description

Get the number of elements of the result set stored in a variable named variable. The number of elements refers to the result of a DATA QUERY LANGUAGE (DQL) or DATA INTROSPECTION LANGUAGE (DIL) operation redirected into memory – and not to the number of elements that variable has in the program. If the result set stores data from a dataset or attribute that does not have a dimension (i.e. if it is scalar), the returned number of elements is one. Otherwise, if the result set stores data from a dataset or attribute that has dimensions, the returned number of elements equals the multiplication of all its dimensions’ sizes (e.g. if a variable stores a result set of two dimensions of size 10x3, the number of elements is 30). Of note, if a hyperslab or point selection is specified (in a DATA QUERY LANGUAGE (DQL) operation), the number of elements in the selection will be returned instead. If variable has been registered but has never been populated through a redirection operation, the returned number of elements is zero.

Parameter(s)

variable – pointer to a variable whose number of elements (i.e. result set size) is to be obtained.

Return

long long – depending on the success in getting the number of elements of the variable, it can be equal to or greater than zero (i.e. the number of elements), HDFQL_ERROR_NO_ADDRESS, or HDFQL_ERROR_NOT_REGISTERED.

Example(s)

// declare variables 
char script[1024];
int data[5][3];

// create an HDF5 dataset named "my_dataset" of data type int of two dimensions (size 5x3) 
hdfql_execute("CREATE DATASET my_dataset AS INT(5, 3)");

// register variable "data" for subsequent use (by HDFql) 
hdfql_variable_register(data);

// prepare script to select (i.e. read) data from dataset "my_dataset" and populate variable "data" with it
sprintf(script, "SELECT FROM my_dataset INTO MEMORY %d", hdfql_variable_get_number(data));

// execute script 
hdfql_execute(script);

// display number of elements in variable "data" (should be "Number of elements in variable is 15")
printf("Number of elements in variable is %lld\n", hdfql_variable_get_count(data));