Search code examples
hdf5hdfql

HDFql Get Size of Group


I am wondering how to get the number of datasets within a group using C++ and HDFql. Currently I have tried something like this (inspired by the HDFql manual):

char script[1024];
uint64_t group_size = 0;
sprintf(script, "SHOW my_group SIZE INTO MEMORY %d", HDFql::variableTransientRegister(&group_size));
HDFql::execute(script);

But unfortunately this doesn't work at all.

Many thanks!


Solution

  • One possible solution to solve your issue is to retrieve all the datasets stored in, e.g., group my_group like this:

    HDFql::execute("SHOW DATASET my_group/");
    

    And then, get the number of datasets found using HDFql function cursorGetCount (which returns the number of elements in the cursor). Example:

    std::cout << "Number of datasets: " << HDFql::cursorGetCount();
    

    As a side note, if you wish to retrieve all the datasets stored in group my_group and in sub-groups do the following (the LIKE option activates recursive search in HDFql):

    HDFql::execute("SHOW DATASET my_group/ LIKE **");
    

    For more information, please refer to HDFql reference manual and quick start.