Read compound data to buffer

Hello,

I have a file which contains a dataset with compound datatype.

I need to read this data row by row to a string (or whatever) buffer, but I cannot find an example how to do it.
I managed to open file, to open the dataset and to read the structure, but I cannot fid a way to read the data to buffer.

Any help is appreciated.
Best regards,

Ovi

Hi @ovi_s,

Looking at the screenshot you have posted, it seems that your compound dataset could be represented by the following structure and read into a buffer as follows (in C++ using HDFql):

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

struct data
{
    unsigned long long timestamp;
    int order;
    int serial_number;
    double temperature;
    double pressure;
    int int_array[2][2];
};

int main(int argc, char *argv[])
{
   struct data values[4];

   HDFql::variableRegister(values);

   HDFql::execute("select from h5ex_t_cmpd.h5 DS1 into memory 0");

   for(int i = 0; i < 4; i++)
   {
       std::cout << "Timestamp=" << values[i].timestamp << std::endl;
       std::cout << "Order=" << values[i].order << std::endl;
       std::cout << "Serial number=" << values[i].serial_number << std::endl;
       std::cout << "Temperature=" << values[i].temperature << std::endl;
       std::cout << "Pressure=" << values[i].pressure << std::endl;
       std::cout << "IntArray[0][0]=" << values[i].int_array[0][0] << std::endl;
       std::cout << "IntArray[0][1]=" << values[i].int_array[0][1] << std::endl;
       std::cout << "IntArray[1][0]=" << values[i].int_array[1][0] << std::endl;
       std::cout << "IntArray[1][1]=" << values[i].int_array[1][1] << std::endl;
   }

   return 0;
}

Please refer to HDFql reference manual and examples for additional information.

1 Like