diff --git a/plugins/parquet/parquetembed.cpp b/plugins/parquet/parquetembed.cpp index c35337ffc50..749b14d35b6 100644 --- a/plugins/parquet/parquetembed.cpp +++ b/plugins/parquet/parquetembed.cpp @@ -872,6 +872,21 @@ unsigned __int64 getUnsigned(std::shared_ptr *array_visitor } } +double getReal(std::shared_ptr *array_visitor, int index) +{ + switch ((*array_visitor)->size) + { + case 2: + return (*array_visitor)->half_float_arr->Value(index); + case 4: + return (*array_visitor)->float_arr->Value(index); + case 8: + return (*array_visitor)->double_arr->Value(index); + default: + failx("getReal: Invalid size %i", (*array_visitor)->size); + } +} + std::string_view ParquetRowBuilder::getCurrView(const RtlFieldInfo *field) { serialized.clear(); @@ -885,14 +900,8 @@ std::string_view ParquetRowBuilder::getCurrView(const RtlFieldInfo *field) return (*array_visitor)->bin_arr->GetView(currArrayIndex()); case LargeBinaryType: return (*array_visitor)->large_bin_arr->GetView(currArrayIndex()); - case DoubleType: - tokenSerializer.serialize((*array_visitor)->double_arr->Value(currArrayIndex()), serialized); - return serialized.str(); - case HalfFloatType: - tokenSerializer.serialize((*array_visitor)->half_float_arr->Value(currArrayIndex()), serialized); - return serialized.str(); - case FloatType: - tokenSerializer.serialize((*array_visitor)->float_arr->Value(currArrayIndex()), serialized); + case RealType: + tokenSerializer.serialize(getReal(array_visitor, currArrayIndex()), serialized); return serialized.str(); case IntType: tokenSerializer.serialize(getSigned(array_visitor, currArrayIndex()), serialized); @@ -923,7 +932,7 @@ std::string_view ParquetRowBuilder::getCurrView(const RtlFieldInfo *field) } } -__int64 ParquetRowBuilder::getCurrValue(const RtlFieldInfo *field) +__int64 ParquetRowBuilder::getCurrIntValue(const RtlFieldInfo *field) { switch ((*array_visitor)->type) { @@ -933,12 +942,8 @@ __int64 ParquetRowBuilder::getCurrValue(const RtlFieldInfo *field) return getSigned(array_visitor, currArrayIndex()); case UIntType: return getUnsigned(array_visitor, currArrayIndex()); - case DoubleType: - return (*array_visitor)->double_arr->Value(currArrayIndex()); - case HalfFloatType: - return (*array_visitor)->half_float_arr->Value(currArrayIndex()); - case FloatType: - return (*array_visitor)->float_arr->Value(currArrayIndex()); + case RealType: + return getReal(array_visitor, currArrayIndex()); case DateType: return (*array_visitor)->size == 32 ? (*array_visitor)->date32_arr->Value(currArrayIndex()) : (*array_visitor)->date64_arr->Value(currArrayIndex()); case TimestampType: @@ -973,7 +978,7 @@ bool ParquetRowBuilder::getBooleanResult(const RtlFieldInfo *field) return p.boolResult; } - return getCurrValue(field); + return getCurrIntValue(field); } /** @@ -1015,14 +1020,10 @@ double ParquetRowBuilder::getRealResult(const RtlFieldInfo *field) return p.doubleResult; } - switch((*array_visitor)->type) - { case DoubleType: - return (*array_visitor)->double_arr->Value(currArrayIndex()); - case FloatType: - return (*array_visitor)->float_arr->Value(currArrayIndex()); - default: - return getCurrValue(field); - } + if ((*array_visitor)->type == RealType) + return getReal(array_visitor, currArrayIndex()); + else + return getCurrIntValue(field); } /** @@ -1041,7 +1042,7 @@ __int64 ParquetRowBuilder::getSignedResult(const RtlFieldInfo *field) return p.intResult; } - return getCurrValue(field); + return getCurrIntValue(field); } /** @@ -1063,7 +1064,7 @@ unsigned __int64 ParquetRowBuilder::getUnsignedResult(const RtlFieldInfo *field) if ((*array_visitor)->type == UIntType) return getUnsigned(array_visitor, currArrayIndex()); else - return getCurrValue(field); + return getCurrIntValue(field); } /** diff --git a/plugins/parquet/parquetembed.hpp b/plugins/parquet/parquetembed.hpp index f8d32e620c5..9f1bb2015e0 100644 --- a/plugins/parquet/parquetembed.hpp +++ b/plugins/parquet/parquetembed.hpp @@ -136,8 +136,6 @@ enum ParquetArrayType TimestampType, TimeType, DurationType, - HalfFloatType, - FloatType, StringType, LargeStringType, BinaryType, @@ -145,7 +143,7 @@ enum ParquetArrayType DecimalType, ListType, StructType, - DoubleType + RealType }; class ParquetArrayVisitor : public arrow::ArrayVisitor @@ -261,19 +259,22 @@ class ParquetArrayVisitor : public arrow::ArrayVisitor arrow::Status Visit(const arrow::HalfFloatArray &array) { half_float_arr = &array; - type = HalfFloatType; + type = RealType; + size = 2; return arrow::Status::OK(); } arrow::Status Visit(const arrow::FloatArray &array) { float_arr = &array; - type = FloatType; + type = RealType; + size = 4; return arrow::Status::OK(); } arrow::Status Visit(const arrow::DoubleArray &array) { double_arr = &array; - type = DoubleType; + type = RealType; + size = 8; return arrow::Status::OK(); } arrow::Status Visit(const arrow::StringArray &array) @@ -897,7 +898,7 @@ class ParquetRowBuilder : public CInterfaceOf protected: const std::shared_ptr &getChunk(std::shared_ptr *column); std::string_view getCurrView(const RtlFieldInfo *field); - __int64 getCurrValue(const RtlFieldInfo *field); + __int64 getCurrIntValue(const RtlFieldInfo *field); void nextField(const RtlFieldInfo *field); void nextFromStruct(const RtlFieldInfo *field); void xpathOrName(StringBuffer &outXPath, const RtlFieldInfo *field) const;