1

I am trying to use the HDFql C++ library to select groups that have attributes with specific values. There are an arbitrary number of groups in the root group, and each group has the same attribute names but possibly different values. For example, I might have two groups, group1 and group2, and each group has two attributes, attribute1 and attribute2. The values for the groups and attributes might be,

group1 attribute1 is "Water" group1 attribute2 is "Database1" group2 attribute1 is "Water" group2 attribute2 is "Database2"

I would like to form a query to select the group that has attribute1 set to "Water" and attribute2 set to "Database1". It should always be a single group after filtering in this way.

Here is the above example and my attempt to do the selection in code,

#include <iostream>
#include "HDFql.hpp" 

int main()
{
    // Create h5 and groups
    HDFql::execute("CREATE AND USE FILE testing.h5");
    HDFql::execute("CREATE GROUP group1");
    HDFql::execute("CREATE GROUP group2");

    // Create group attributes
    HDFql::execute("CREATE ATTRIBUTE group1/attribute1 AS VARCHAR VALUES(Water)");
    HDFql::execute("CREATE ATTRIBUTE group1/attribute2 AS VARCHAR VALUES(Database1)");
    HDFql::execute("CREATE ATTRIBUTE group2/attribute1 AS VARCHAR VALUES(Water)");
    HDFql::execute("CREATE ATTRIBUTE group2/attribute2 AS VARCHAR VALUES(Database2)");

    // Attempt the query (prints -1, corresponds to HDFQL_ERROR_PARSE)
    // Want it give back group1 instead (and print 0).
    std::cout << HDFql::execute("SHOW GROUP WHERE **/attribute1=Water AND **/attribute2=Database1") << "\n";
}

I understand that the asterisks would be used with LIKE and not WHERE, but the idea is that they are wildcards.

Is this sort of query possible with HDFql and, if so, how should it be formed? If not, is there another good way to do this?

Similar question but for Python: Filter HDF dataset from H5 file using attribute

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.