Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for converted int types #673

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 86 additions & 9 deletions plotjuggler_plugins/DataLoadParquet/dataload_parquet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void DataLoadParquet::setupDialog(QDialog* dialog)
bool DataLoadParquet::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_data)
{
using parquet::Type;
using parquet::ConvertedType;

parquet_reader_ = parquet::ParquetFileReader::OpenFile(info->filename.toStdString());

Expand All @@ -84,13 +85,17 @@ bool DataLoadParquet::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_
setupDialog(dialog);

std::vector<parquet::Type::type> column_type;
std::vector<parquet::ConvertedType::type> converted_column_type;
std::vector<bool> valid_column( num_columns, true );

for( size_t col=0; col<num_columns; col++ )
{
auto column = schema->Column(col);
auto type = column->physical_type();
auto converted_type = column->converted_type();

column_type.push_back( type );
converted_column_type.push_back( converted_type );

valid_column[col] = (type == Type::BOOLEAN ||
type == Type::INT32 ||
Expand Down Expand Up @@ -178,6 +183,7 @@ bool DataLoadParquet::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_
continue;
}
auto type = column_type[col];
auto converted_type = converted_column_type[col];

switch(type)
{
Expand All @@ -187,16 +193,87 @@ bool DataLoadParquet::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_
row_values[col] = static_cast<double>(tmp);
break;
}
case Type::INT32: {
int32_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case Type::INT32:
case Type::INT64: {
int64_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
switch(converted_type)
{
case ConvertedType::INT_8:
{
int8_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::INT_16:
{
int16_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::INT_32:
{
int32_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::INT_64:
{
int64_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::UINT_8:
{
uint8_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::UINT_16:
{
uint16_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::UINT_32:
{
uint32_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case ConvertedType::UINT_64:
{
uint64_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
default: {
//Fallback in case no converted type is provided
switch(type)
{
case Type::INT32:
{
int32_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
case Type::INT64:
{
int64_t tmp;
os >> tmp;
row_values[col] = static_cast<double>(tmp);
break;
}
}
}
}
break;
}
case Type::FLOAT: {
Expand Down