diff options
| author | ilezhankin <[email protected]> | 2024-12-10 12:20:10 +0300 |
|---|---|---|
| committer | ilezhankin <[email protected]> | 2024-12-10 13:31:46 +0300 |
| commit | 216714b7c3f99f49851c2396c0d46bc4134a803f (patch) | |
| tree | a2153babbdcc8ab94563cfb31efc8f5c9cadd1d7 | |
| parent | 7e49cd560df7f43217fe6bbd6a20235e29f0d168 (diff) | |
Pass params to all array builders
Follow-up to <https://nda.ya.ru/t/qM41fmwb7AGmMo>
commit_hash:1ba96815c597bb1e9d74e10889417cca329354f8
| -rw-r--r-- | yql/essentials/public/udf/arrow/block_builder.h | 14 | ||||
| -rw-r--r-- | yql/essentials/public/udf/arrow/util.h | 9 |
2 files changed, 13 insertions, 10 deletions
diff --git a/yql/essentials/public/udf/arrow/block_builder.h b/yql/essentials/public/udf/arrow/block_builder.h index 7954c428832..93d084d2c21 100644 --- a/yql/essentials/public/udf/arrow/block_builder.h +++ b/yql/essentials/public/udf/arrow/block_builder.h @@ -1436,19 +1436,19 @@ inline std::unique_ptr<TArrayBuilderBase> MakeArrayBuilderImpl( return std::make_unique<TStringArrayBuilder<arrow::BinaryType, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::Utf8: case NUdf::EDataSlot::Json: - return std::make_unique<TStringArrayBuilder<arrow::StringType, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TStringArrayBuilder<arrow::StringType, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzDate: - return std::make_unique<TTzDateArrayBuilder<TTzDate, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzDate, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzDatetime: - return std::make_unique<TTzDateArrayBuilder<TTzDatetime, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzDatetime, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzTimestamp: - return std::make_unique<TTzDateArrayBuilder<TTzTimestamp, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzTimestamp, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzDate32: - return std::make_unique<TTzDateArrayBuilder<TTzDate32, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzDate32, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzDatetime64: - return std::make_unique<TTzDateArrayBuilder<TTzDatetime64, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzDatetime64, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::TzTimestamp64: - return std::make_unique<TTzDateArrayBuilder<TTzTimestamp64, Nullable>>(typeInfoHelper, type, pool, maxLen); + return std::make_unique<TTzDateArrayBuilder<TTzTimestamp64, Nullable>>(typeInfoHelper, type, pool, maxLen, params); case NUdf::EDataSlot::Decimal: return std::make_unique<TFixedSizeArrayBuilder<NYql::NDecimal::TInt128, Nullable>>(typeInfoHelper, type, pool, maxLen, params); default: diff --git a/yql/essentials/public/udf/arrow/util.h b/yql/essentials/public/udf/arrow/util.h index c7db1cc51b5..b4068f10c91 100644 --- a/yql/essentials/public/udf/arrow/util.h +++ b/yql/essentials/public/udf/arrow/util.h @@ -82,7 +82,7 @@ public: return arrow::Status::Invalid("Negative buffer resize: ", newSize); } uint8_t* ptr = mutable_data(); - if (ptr && shrink_to_fit && newSize <= size_) { + if (ptr && shrink_to_fit) { int64_t newCapacity = arrow::BitUtil::RoundUpToMultipleOf64(newSize); if (capacity_ != newCapacity) { ARROW_RETURN_NOT_OK(Pool->Reallocate(capacity_, newCapacity, &ptr)); @@ -204,8 +204,11 @@ public: } inline std::shared_ptr<arrow::Buffer> Finish() { - bool shrinkToFit = MinFillPercentage ? Buffer->size() <= Buffer->capacity() / 100 * *MinFillPercentage: false; - ARROW_OK(Buffer->Resize(Len * sizeof(T), shrinkToFit)); + int64_t newSize = Len * sizeof(T); + bool shrinkToFit = MinFillPercentage + ? newSize <= Buffer->capacity() * *MinFillPercentage / 100 + : false; + ARROW_OK(Buffer->Resize(newSize, shrinkToFit)); std::shared_ptr<arrow::ResizableBuffer> result; std::swap(result, Buffer); Len = 0; |
