Skip to content

Commit

Permalink
Add direct conversion for primitive types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdelv committed Oct 11, 2023
1 parent 24a2547 commit da57f90
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
58 changes: 41 additions & 17 deletions plugins/parquet/parquetembed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,36 @@ std::string_view ParquetRowBuilder::getCurrView(const RtlFieldInfo *field)
}
}

__int64 ParquetRowBuilder::getCurrValue(const RtlFieldInfo *field)
{
switch ((*array_visitor)->type)
{
case BoolType:
return (*array_visitor)->bool_arr->Value(currArrayIndex());
case IntType:
return getSigned(array_visitor, currArrayIndex());
case UIntType:
return getUnsigned(array_visitor, currArrayIndex());
case DoubleType:
return (*array_visitor)->double_arr->Value(currArrayIndex());
case DateType:
return (*array_visitor)->size == 32 ? (*array_visitor)->date32_arr->Value(currArrayIndex()) : (*array_visitor)->date64_arr->Value(currArrayIndex());
case TimestampType:
return (*array_visitor)->timestamp_arr->Value(currArrayIndex());
case TimeType:
return (*array_visitor)->size == 32 ? (*array_visitor)->time32_arr->Value(currArrayIndex()) : (*array_visitor)->time64_arr->Value(currArrayIndex());
case DurationType:
return (*array_visitor)->duration_arr->Value(currArrayIndex());
default:
{
__int64 myint64 = 0;
auto scalar = getCurrView(field);
handleDeserializeOutcome(tokenDeserializer.deserialize(scalar.data(), myint64), "signed", scalar.data());
return myint64;
}
}
}

/**
* @brief Gets a Boolean result for an ECL Row
*
Expand All @@ -938,10 +968,8 @@ bool ParquetRowBuilder::getBooleanResult(const RtlFieldInfo *field)
NullFieldProcessor p(field);
return p.boolResult;
}
bool mybool;
auto scalar = getCurrView(field);
handleDeserializeOutcome(tokenDeserializer.deserialize(scalar.data(), mybool), "bool", scalar.data());
return mybool;

return getCurrValue(field);
}

/**
Expand Down Expand Up @@ -983,10 +1011,10 @@ double ParquetRowBuilder::getRealResult(const RtlFieldInfo *field)
return p.doubleResult;
}

double mydouble = 0.0;
auto value = getCurrView(field);
handleDeserializeOutcome(tokenDeserializer.deserialize(value.data(), mydouble), "real", value.data());
return mydouble;
if ((*array_visitor)->type == DoubleType)
return (*array_visitor)->double_arr->Value(currArrayIndex());
else
return getCurrValue(field);
}

/**
Expand All @@ -1005,10 +1033,7 @@ __int64 ParquetRowBuilder::getSignedResult(const RtlFieldInfo *field)
return p.intResult;
}

__int64 myint64 = 0;
auto scalar = getCurrView(field);
handleDeserializeOutcome(tokenDeserializer.deserialize(scalar.data(), myint64), "signed", scalar.data());
return myint64;
return getCurrValue(field);
}

/**
Expand All @@ -1023,15 +1048,14 @@ unsigned __int64 ParquetRowBuilder::getUnsignedResult(const RtlFieldInfo *field)

if ((*array_visitor)->type == NullType)
{

NullFieldProcessor p(field);
return p.uintResult;
}

unsigned __int64 myuint64 = 0;
auto scalar = getCurrView(field);
handleDeserializeOutcome(tokenDeserializer.deserialize(scalar.data(), myuint64), "unsigned", scalar.data());
return myuint64;
if ((*array_visitor)->type == UIntType)
return getUnsigned(array_visitor, currArrayIndex());
else
return getCurrValue(field);
}

/**
Expand Down
1 change: 1 addition & 0 deletions plugins/parquet/parquetembed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ class ParquetRowBuilder : public CInterfaceOf<IFieldSource>
protected:
const std::shared_ptr<arrow::Array> &getChunk(std::shared_ptr<arrow::ChunkedArray> *column);
std::string_view getCurrView(const RtlFieldInfo *field);
__int64 getCurrValue(const RtlFieldInfo *field);
void nextField(const RtlFieldInfo *field);
void nextFromStruct(const RtlFieldInfo *field);
void xpathOrName(StringBuffer &outXPath, const RtlFieldInfo *field) const;
Expand Down

0 comments on commit da57f90

Please sign in to comment.