I'm writing a program using Apache Arrow C++ library to extract metadata from a parquet file, and I've been having a lot of trouble finding documentation and examples.
After some try and error I managed to do the job using this code:
std::unique_ptr<parquet::RowGroupMetaData> rowGroup = file_metadata->RowGroup(0);
std::shared_ptr<parquet::Statistics> stats = (rowGroup->ColumnChunk(0))->statistics();
const parquet::TypedStatistics<arrow::Int32Type> *typed_stats =
static_cast<const parquet::TypedStatistics<arrow::Int32Type>*>(stats.get());
std::cout << "Min(" << i << "): " << typed_stats->min() << std::endl;
std::cout << "Max(" << i << "): " << typed_stats->max() << std::endl;
Is there a different/better way of doing this?
And is there a way of automatically detect the type or will I have to write if/else or switch statements for each type?
I'm using Apache Arrow 11.0 and g++ 11.3.0