5.2.13hdfql_subcursor_get_count
Syntax
long long hdfql_subcursor_get_count(const HDFQL_CURSOR *cursor)
Description
Get the number of elements (i.e. result subset size) stored in the subcursor in use. The number of elements refers to the result of a DATA QUERY LANGUAGE (DQL) or DATA INTROSPECTION LANGUAGE (DIL) operation redirected into a cursor. If the cursor that the subcursor belongs to has never been populated or has been initialized or cleared, the returned number of elements is zero.
Parameter(s)
cursor – pointer to a cursor to get the number of elements (i.e. result subset size) stored in the subcursor in use. If the pointer is NULL (in C), the number of elements of the subcursor of the cursor in use is returned instead. The equivalent of a NULL pointer in C++, Java, Python, C#, Fortran, R, and MATLAB HDFql wrappers is NULL, null, None, null, NULL(), NULL, and NaN, respectively. While in C cursor is mandatory, in C++, Java, Python, C#, Fortran, R, and MATLAB it is optional (when not specified, the number of elements of the subcursor of the cursor in use is returned instead).
Return
long long – number of elements (i.e. result subset size) stored in the subcursor.
Example(s)
// create an HDF5 dataset named "my_dataset" of data type variable-length int of two dimensions (size 2x2)
hdfql_execute("CREATE DATASET my_dataset AS VARINT(2, 2)");
// insert (i.e. write) values into dataset "my_dataset"
hdfql_execute("INSERT INTO my_dataset VALUES(((7, 8, 5), (9)), ((6, 1, 2, 3), (4, 0)))");
// select (i.e. read) data from dataset "my_dataset" and populate cursor in use with it
hdfql_execute("SELECT FROM my_dataset");
// display number of elements in the cursor in use (should be "Number of elements in cursor is 4")
printf("Number of elements in cursor is %lld\n", hdfql_cursor_get_count(NULL));
// move the cursor in use to next position within the result set (i.e. first position)
hdfql_cursor_next(NULL);
// display number of elements in the subcursor in use (should be "Number of elements in subcursor is 3")
printf("Number of elements in subcursor is %lld\n", hdfql_subcursor_get_count(NULL));
// move the cursor in use to next position within the result set (i.e. second position)
hdfql_cursor_next(NULL);
// display number of elements in the subcursor in use (should be "Number of elements in subcursor is 1")
printf("Number of elements in subcursor is %lld\n", hdfql_subcursor_get_count(NULL));