From 4f37bc4cac55b31236d5f8eb4b8210bac8fd203b Mon Sep 17 00:00:00 2001 From: Zehua Zou Date: Wed, 2 Dec 2026 20:35:13 +0800 Subject: [PATCH 1/2] use validity bitmap runs when encoding and decoding nullable values --- cpp/src/arrow/buffer_builder.h | 8 +- cpp/src/parquet/column_writer.cc | 107 ++++---- cpp/src/parquet/decoder.cc | 227 ++++++--------- cpp/src/parquet/encoder.cc | 457 ++++++++++++------------------- cpp/src/parquet/encoding_test.cc | 12 +- 5 files changed, 336 insertions(+), 475 deletions(-) diff --git a/cpp/src/arrow/buffer_builder.h b/cpp/src/arrow/buffer_builder.h index 5ad46b055596..18a338a15696 100644 --- a/cpp/src/arrow/buffer_builder.h +++ b/cpp/src/arrow/buffer_builder.h @@ -419,7 +419,13 @@ class TypedBufferBuilder { /// \brief Append bits from a packed bitmap void UnsafeAppend(const uint8_t* bitmap, int64_t offset, int64_t num_elements) { - if (num_elements == 0) return; + if (num_elements < 8) { + // For less than a byte, copy and count the bits in one pass. + for (int64_t i = 0; i < num_elements; ++i) { + UnsafeAppend(bit_util::GetBit(bitmap, offset + i)); + } + return; + } internal::CopyBitmap(bitmap, offset, num_elements, mutable_data(), bit_length_); false_count_ += num_elements - internal::CountSetBits(bitmap, offset, num_elements); bit_length_ += num_elements; diff --git a/cpp/src/parquet/column_writer.cc b/cpp/src/parquet/column_writer.cc index 826fd4f32118..033939a32198 100644 --- a/cpp/src/parquet/column_writer.cc +++ b/cpp/src/parquet/column_writer.cc @@ -33,6 +33,7 @@ #include "arrow/status.h" #include "arrow/type.h" #include "arrow/type_traits.h" +#include "arrow/util/bit_run_reader.h" #include "arrow/util/bit_stream_utils_internal.h" #include "arrow/util/bit_util.h" #include "arrow/util/bitmap_ops.h" @@ -2110,6 +2111,27 @@ Status TypedColumnWriterImpl::WriteArrowDictionary( // ---------------------------------------------------------------------- // Direct Arrow write path +namespace { + +// Keep one output slot per Arrow value; WriteBatchSpacedInternal uses the same indices. +template +Status SerializeSpacedValues(const Array& array, T* out, Convert&& convert) { + return ::arrow::internal::VisitBitRuns( + array.null_count() == 0 ? nullptr : array.null_bitmap_data(), array.offset(), + array.length(), [&](int64_t start, int64_t length, bool valid) { + if (valid) { + for (int64_t i = start; i < start + length; ++i) { + out[i] = convert(i); + } + } else { + std::fill_n(out + start, length, T{}); + } + return Status::OK(); + }); +} + +} // namespace + template struct SerializeFunctor { using ArrowCType = typename ArrowType::c_type; @@ -2223,17 +2245,8 @@ struct SerializeFunctor< Status Serialize(const typename ::arrow::TypeTraits::ArrayType& array, ArrowWriteContext* ctx, value_type* out) { - if (array.null_count() == 0) { - for (int64_t i = 0; i < array.length(); i++) { - out[i] = TransferValue(array.Value(i)); - } - } else { - for (int64_t i = 0; i < array.length(); i++) { - out[i] = array.IsValid(i) ? TransferValue(array.Value(i)) : 0; - } - } - - return Status::OK(); + return SerializeSpacedValues( + array, out, [&](int64_t i) { return TransferValue(array.Value(i)); }); } private: @@ -2363,29 +2376,36 @@ struct SerializeFunctor { auto target_type = ::arrow::timestamp(target_unit); bool truncation_allowed = ctx->properties->truncated_timestamps_allowed(); + const auto* valid_bits = array.null_count() == 0 ? nullptr : array.null_bitmap_data(); + auto DivideBy = [&](const int64_t factor) { - for (int64_t i = 0; i < array.length(); i++) { - if (!truncation_allowed && array.IsValid(i) && (values[i] % factor != 0)) { - return Status::Invalid("Casting from ", source_type.ToString(), " to ", - target_type->ToString(), - " would lose data: ", values[i]); - } - out[i] = values[i] / factor; - } - return Status::OK(); + return ::arrow::internal::VisitSetBitRuns( + valid_bits, array.offset(), array.length(), [&](int64_t start, int64_t length) { + for (int64_t i = start; i < start + length; ++i) { + if (!truncation_allowed && values[i] % factor != 0) { + return Status::Invalid("Casting from ", source_type.ToString(), " to ", + target_type->ToString(), + " would lose data: ", values[i]); + } + out[i] = values[i] / factor; + } + return Status::OK(); + }); }; auto MultiplyBy = [&](const int64_t factor) { - for (int64_t i = 0; i < array.length(); i++) { - if (array.IsValid(i) && - ARROW_PREDICT_FALSE(::arrow::internal::MultiplyWithOverflowGeneric( - values[i], factor, &out[i]))) { - return Status::Invalid("Integer overflow when casting timestamp value ", - values[i], " from ", source_type.ToString(), " to ", - target_type->ToString()); - } - } - return Status::OK(); + return ::arrow::internal::VisitSetBitRuns( + valid_bits, array.offset(), array.length(), [&](int64_t start, int64_t length) { + for (int64_t i = start; i < start + length; ++i) { + if (ARROW_PREDICT_FALSE(::arrow::internal::MultiplyWithOverflowGeneric( + values[i], factor, &out[i]))) { + return Status::Invalid("Integer overflow when casting timestamp value ", + values[i], " from ", source_type.ToString(), + " to ", target_type->ToString()); + } + } + return Status::OK(); + }); }; const auto& coercion = kTimestampCoercionFactors[static_cast(source_unit)] @@ -2596,18 +2616,9 @@ struct SerializeFunctor< AllocateScratch(array, ctx); auto offset = Offset(array); - if (array.null_count() == 0) { - for (int64_t i = 0; i < array.length(); i++) { - out[i] = FixDecimalEndianness(array.GetValue(i), offset); - } - } else { - for (int64_t i = 0; i < array.length(); i++) { - out[i] = array.IsValid(i) ? FixDecimalEndianness(array.GetValue(i), offset) - : FixedLenByteArray(); - } - } - - return Status::OK(); + return SerializeSpacedValues(array, out, [&](int64_t i) { + return FixDecimalEndianness(array.GetValue(i), offset); + }); } private: @@ -2668,16 +2679,8 @@ template <> struct SerializeFunctor<::parquet::FLBAType, ::arrow::HalfFloatType> { Status Serialize(const ::arrow::HalfFloatArray& array, ArrowWriteContext*, FLBA* out) { const uint16_t* values = array.raw_values(); - if (array.null_count() == 0) { - for (int64_t i = 0; i < array.length(); ++i) { - out[i] = ToFLBA(&values[i]); - } - } else { - for (int64_t i = 0; i < array.length(); ++i) { - out[i] = array.IsValid(i) ? ToFLBA(&values[i]) : FLBA{}; - } - } - return Status::OK(); + return SerializeSpacedValues(array, out, + [&](int64_t i) { return ToFLBA(&values[i]); }); } private: diff --git a/cpp/src/parquet/decoder.cc b/cpp/src/parquet/decoder.cc index d83bf3188937..a3e6bfa50565 100644 --- a/cpp/src/parquet/decoder.cc +++ b/cpp/src/parquet/decoder.cc @@ -43,6 +43,7 @@ #include "arrow/util/bit_stream_utils_internal.h" #include "arrow/util/bit_util.h" #include "arrow/util/bitmap_ops.h" +#include "arrow/util/bitmap_visit.h" #include "arrow/util/byte_stream_split_internal.h" #include "arrow/util/checked_cast.h" #include "arrow/util/int_util_overflow.h" @@ -102,8 +103,9 @@ struct ArrowBinaryHelper { // If a new chunk is created and estimated_remaining_data_length is provided, // it will also reserve the estimated data length for this chunk. - Status AppendValue(const uint8_t* data, int32_t length, - std::optional estimated_remaining_data_length = {}) { + ARROW_FORCE_INLINE Status + AppendValue(const uint8_t* data, int32_t length, + std::optional estimated_remaining_data_length = {}) { DCHECK_GT(entries_remaining_, 0); if (ARROW_PREDICT_FALSE(!CanFit(length))) { @@ -122,12 +124,6 @@ struct ArrowBinaryHelper { } } - void UnsafeAppendNull() { - DCHECK_GT(entries_remaining_, 0); - --entries_remaining_; - builder_->UnsafeAppendNull(); - } - Status AppendNulls(int64_t length) { DCHECK_GE(entries_remaining_, length); entries_remaining_ -= length; @@ -198,8 +194,6 @@ struct ArrowBinaryHelper { } } - void UnsafeAppendNull() { builder_->UnsafeAppendNull(); } - Status AppendNulls(int64_t length) { return builder_->AppendNulls(length); } private: @@ -222,8 +216,6 @@ struct ArrowBinaryHelper { return Status::OK(); } - void UnsafeAppendNull() { acc_->UnsafeAppendNull(); } - Status AppendNulls(int64_t length) { return acc_->AppendNulls(length); } private: @@ -954,6 +946,10 @@ class DictDecoderImpl : public TypedDecoderImpl, public DictDecoder int DecodeIndicesSpaced(int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset, ::arrow::ArrayBuilder* builder) override { + if (null_count == num_values) { + PARQUET_THROW_NOT_OK(builder->AppendNulls(num_values)); + return 0; + } if (num_values > 0) { // TODO(wesm): Refactor to batch reads for improved memory use. It is not // trivial because the null_count is relative to the entire bitmap @@ -968,16 +964,19 @@ class DictDecoderImpl : public TypedDecoderImpl, public DictDecoder ParquetException::EofException(); } - // XXX(wesm): Cannot append "valid bits" directly to the builder - std::vector valid_bytes(num_values, 0); - size_t i = 0; - VisitNullBitmapInline( - valid_bits, valid_bits_offset, num_values, null_count, - [&]() { valid_bytes[i++] = 1; }, [&]() { ++i; }); - auto binary_builder = checked_cast<::arrow::BinaryDictionary32Builder*>(builder); - PARQUET_THROW_NOT_OK( - binary_builder->AppendIndices(indices_buffer, num_values, valid_bytes.data())); + if (null_count == 0) { + PARQUET_THROW_NOT_OK(binary_builder->AppendIndices(indices_buffer, num_values)); + } else { + // AppendIndices takes a byte validity mask, not a bitmap. + std::vector valid_bytes(num_values); + auto* out = valid_bytes.data(); + auto unpack_bit = [&](bool valid) { *out++ = static_cast(valid); }; + ::arrow::internal::VisitBitsUnrolled(valid_bits, valid_bits_offset, num_values, + unpack_bit); + PARQUET_THROW_NOT_OK( + binary_builder->AppendIndices(indices_buffer, num_values, valid_bytes.data())); + } this->num_values_ -= num_values - null_count; return num_values - null_count; } @@ -1290,10 +1289,13 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl { int result = 0; if (null_count == 0) { PARQUET_THROW_NOT_OK(DecodeArrowNonNull(num_values, builder, &result)); - } else { - PARQUET_THROW_NOT_OK(DecodeArrow(num_values, null_count, valid_bits, - valid_bits_offset, builder, &result)); + return result; } + PARQUET_THROW_NOT_OK(builder->Reserve(num_values)); + PARQUET_THROW_NOT_OK(DecodeArrowRuns( + num_values, null_count, valid_bits, valid_bits_offset, &result, + [&](const ByteArray& value) { return builder->Append(value.ptr, value.len); }, + [&](int64_t length) { return builder->AppendNulls(length); })); return result; } @@ -1301,139 +1303,80 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl { int64_t valid_bits_offset, typename EncodingTraits::Accumulator* out) override { int result = 0; - PARQUET_THROW_NOT_OK(DecodeArrowDense(num_values, null_count, valid_bits, - valid_bits_offset, out, &result)); + // The encoded indices size doesn't tell us how many bytes the values will occupy. + PARQUET_THROW_NOT_OK(DispatchArrowBinaryHelper( + out, num_values, /*estimated_data_length=*/{}, [&](auto* helper) { + return DecodeArrowRuns( + num_values, null_count, valid_bits, valid_bits_offset, &result, + [&](const ByteArray& value) { + return helper->AppendValue(value.ptr, static_cast(value.len)); + }, + [&](int64_t length) { return helper->AppendNulls(length); }); + })); return result; } private: - Status DecodeArrowDense(int num_values, int null_count, const uint8_t* valid_bits, - int64_t valid_bits_offset, - typename EncodingTraits::Accumulator* out, - int* out_num_values) { + template + Status DecodeArrowRuns(int num_values, int null_count, const uint8_t* valid_bits, + int64_t valid_bits_offset, int* out_num_values, + AppendValue&& append_value, AppendNulls&& append_nulls) { constexpr int32_t kBufferSize = 1024; int32_t indices[kBufferSize]; - - auto visit_binary_helper = [&](auto* helper) { - const auto* dict_values = dictionary_->data_as(); - const int values_to_decode = num_values - null_count; - int values_decoded = 0; - int num_indices = 0; - auto refill_indices = [&]() { - const int batch_size = - std::min(kBufferSize, values_to_decode - values_decoded); - num_indices = idx_decoder_.GetBatch(indices, batch_size); - if (ARROW_PREDICT_FALSE(num_indices < 1)) { - return Status::Invalid("Invalid number of indices: ", num_indices); - } - return Status::OK(); - }; - auto append_indices = [&](const int32_t* batch, int length) { - for (int i = 0; i < length; ++i) { - const auto index = batch[i]; - RETURN_NOT_OK(IndexInBounds(index)); - const auto& val = dict_values[index]; - RETURN_NOT_OK(helper->AppendValue(val.ptr, static_cast(val.len))); - } - values_decoded += length; - return Status::OK(); - }; - - if (null_count == 0) { - while (values_decoded < num_values) { - RETURN_NOT_OK(refill_indices()); - RETURN_NOT_OK(append_indices(indices, num_indices)); - } - *out_num_values = values_decoded; - return Status::OK(); + const auto* dict_values = dictionary_->data_as(); + const int values_to_decode = num_values - null_count; + int values_decoded = 0; + int num_indices = 0; + auto refill_indices = [&]() { + const int batch_size = + std::min(kBufferSize, values_to_decode - values_decoded); + num_indices = idx_decoder_.GetBatch(indices, batch_size); + if (ARROW_PREDICT_FALSE(num_indices < 1)) { + return Status::Invalid("Invalid number of indices: ", num_indices); } - - int pos_indices = 0; - auto visit_bit_run = [&](int64_t position, int64_t length, bool valid) { - if (valid) { - while (length > 0) { - if (num_indices == pos_indices) { - RETURN_NOT_OK(refill_indices()); - pos_indices = 0; - } - const int batch_size = - std::min(num_indices - pos_indices, static_cast(length)); - RETURN_NOT_OK(append_indices(indices + pos_indices, batch_size)); - pos_indices += batch_size; - length -= batch_size; - } - } else { - for (int64_t i = 0; i < length; ++i) { - helper->UnsafeAppendNull(); - } - } - return Status::OK(); - }; - - RETURN_NOT_OK( - VisitBitRuns(valid_bits, valid_bits_offset, num_values, visit_bit_run)); - *out_num_values = values_decoded; return Status::OK(); }; - // The `len_` in the ByteArrayDictDecoder is the total length of the - // RLE/Bit-pack encoded data size, so, we cannot use `len_` to reserve - // space for binary data. - return DispatchArrowBinaryHelper( - out, num_values, /*estimated_data_length=*/{}, visit_binary_helper); - } - - template - Status DecodeArrow(int num_values, int null_count, const uint8_t* valid_bits, - int64_t valid_bits_offset, BuilderType* builder, - int* out_num_values) { - constexpr int32_t kBufferSize = 1024; - int32_t indices[kBufferSize]; - - RETURN_NOT_OK(builder->Reserve(num_values)); - ::arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); + auto append_indices = [&](const int32_t* batch, int length) { + for (int i = 0; i < length; ++i) { + const auto index = batch[i]; + RETURN_NOT_OK(IndexInBounds(index)); + const auto& val = dict_values[index]; + RETURN_NOT_OK(append_value(val)); + } + values_decoded += length; + return Status::OK(); + }; - const auto* dict_values = dictionary_->data_as(); + if (null_count == 0) { + while (values_decoded < num_values) { + RETURN_NOT_OK(refill_indices()); + RETURN_NOT_OK(append_indices(indices, num_indices)); + } + *out_num_values = values_decoded; + return Status::OK(); + } - int values_decoded = 0; - int num_appended = 0; - while (num_appended < num_values) { - bool is_valid = bit_reader.IsSet(); - bit_reader.Next(); - - if (is_valid) { - int32_t batch_size = - std::min(kBufferSize, num_values - num_appended - null_count); - int num_indices = idx_decoder_.GetBatch(indices, batch_size); - - int i = 0; - while (true) { - // Consume all indices - if (is_valid) { - auto idx = indices[i]; - RETURN_NOT_OK(IndexInBounds(idx)); - const auto& val = dict_values[idx]; - RETURN_NOT_OK(builder->Append(val.ptr, val.len)); - ++i; - ++values_decoded; - } else { - RETURN_NOT_OK(builder->AppendNull()); - --null_count; - } - ++num_appended; - if (i == num_indices) { - // Do not advance the bit_reader if we have fulfilled the decode - // request - break; + int pos_indices = 0; + auto visit_bit_run = [&](int64_t position, int64_t length, bool valid) { + if (valid) { + while (length > 0) { + if (num_indices == pos_indices) { + RETURN_NOT_OK(refill_indices()); + pos_indices = 0; } - is_valid = bit_reader.IsSet(); - bit_reader.Next(); + const int batch_size = + std::min(num_indices - pos_indices, static_cast(length)); + RETURN_NOT_OK(append_indices(indices + pos_indices, batch_size)); + pos_indices += batch_size; + length -= batch_size; } } else { - RETURN_NOT_OK(builder->AppendNull()); - --null_count; - ++num_appended; + return append_nulls(length); } - } + return Status::OK(); + }; + + RETURN_NOT_OK(VisitBitRuns(valid_bits, valid_bits_offset, num_values, visit_bit_run)); *out_num_values = values_decoded; return Status::OK(); } diff --git a/cpp/src/parquet/encoder.cc b/cpp/src/parquet/encoder.cc index 049eed1bf0eb..9d22567b09e8 100644 --- a/cpp/src/parquet/encoder.cc +++ b/cpp/src/parquet/encoder.cc @@ -34,6 +34,7 @@ #include "arrow/type_traits.h" #include "arrow/util/alp/alp_codec_internal.h" #include "arrow/util/alp/alp_constants_internal.h" +#include "arrow/util/bit_run_reader.h" #include "arrow/util/bit_stream_utils_internal.h" #include "arrow/util/bit_util.h" #include "arrow/util/bitmap_ops.h" @@ -63,6 +64,7 @@ using arrow::Status; using arrow::internal::AddWithOverflow; using arrow::internal::checked_cast; using arrow::internal::SafeSignedSubtract; +using arrow::internal::VisitSetBitRunsVoid; using arrow::util::SafeLoad; using arrow::util::SafeLoadAs; @@ -113,6 +115,10 @@ class EncoderImpl : virtual public Encoder { } protected: + template + int64_t AppendNumericArray(const ::arrow::Array& values, + ::arrow::BufferBuilder& sink) const; + // For accessing type-specific metadata, like FIXED_LEN_BYTE_ARRAY const ColumnDescriptor* descr_; const Encoding::type encoding_; @@ -124,6 +130,105 @@ class EncoderImpl : virtual public Encoder { int64_t unencoded_byte_array_data_bytes_ = 0; }; +// A valid run in an Arrow fixed-width values buffer is contiguous in bytes. +int64_t AppendFixedWidthArray(const ::arrow::Array& array, const uint8_t* values, + int64_t byte_width, ::arrow::BufferBuilder& sink) { + const int64_t num_valid = array.length() - array.null_count(); + if (num_valid == 0 || byte_width == 0) { + return num_valid; + } + if (num_valid == array.length()) { + PARQUET_THROW_NOT_OK(sink.Append(values, num_valid * byte_width)); + } else { + PARQUET_THROW_NOT_OK(sink.Reserve(num_valid * byte_width)); + VisitSetBitRunsVoid(array.null_bitmap_data(), array.offset(), array.length(), + [&](int64_t start, int64_t length) { + sink.UnsafeAppend(values + start * byte_width, + length * byte_width); + }); + } + return num_valid; +} + +template +int64_t EncoderImpl::AppendNumericArray(const ::arrow::Array& values, + ::arrow::BufferBuilder& sink) const { + using ArrowType = typename EncodingTraits::ArrowType; + using ArrayType = typename ::arrow::TypeTraits::ArrayType; + if (values.type_id() != ArrowType::type_id) { + if (encoding_ == Encoding::PLAIN) { + throw ParquetException("direct put to ", ArrowType::type_name(), " from ", + values.type()->ToString(), " not supported"); + } + throw ParquetException("direct put from ", values.type()->ToString(), + " not supported"); + } + + const auto& array = checked_cast(values); + return AppendFixedWidthArray(array, + reinterpret_cast(array.raw_values()), + sizeof(typename ArrayType::value_type), sink); +} + +template +void PutSpacedRuns(Encoder* encoder, const T* src, int num_values, + const uint8_t* valid_bits, int64_t valid_bits_offset) { + if (valid_bits == nullptr || num_values == 0) { + return encoder->Put(src, num_values); + } + VisitSetBitRunsVoid(valid_bits, valid_bits_offset, num_values, + [&](int64_t start, int64_t length) { + encoder->Put(src + start, static_cast(length)); + }); +} + +template +int64_t AppendSpacedValues(::arrow::BufferBuilder& sink, const T* src, int num_values, + const uint8_t* valid_bits, int64_t valid_bits_offset) { + if (num_values <= 0) { + return 0; + } + if (valid_bits == nullptr) { + PARQUET_THROW_NOT_OK(sink.Append(src, num_values * static_cast(sizeof(T)))); + return num_values; + } + const int64_t count = + ::arrow::internal::CountSetBits(valid_bits, valid_bits_offset, num_values); + if (count != 0) { + const int64_t bytes = count * static_cast(sizeof(T)); + PARQUET_THROW_NOT_OK(sink.Reserve(bytes)); + T* out = reinterpret_cast(sink.mutable_data() + sink.length()); + ::arrow::util::internal::SpacedCompress(src, num_values, valid_bits, + valid_bits_offset, out); + sink.UnsafeAdvance(bytes); + } + return count; +} + +int64_t AppendSpacedFLBA(::arrow::BufferBuilder& sink, const FLBA* src, int num_values, + const uint8_t* valid_bits, int64_t valid_bits_offset, + int byte_width) { + if (num_values == 0) { + return 0; + } + const int64_t num_valid = + valid_bits == nullptr + ? num_values + : ::arrow::internal::CountSetBits(valid_bits, valid_bits_offset, num_values); + if (num_valid == 0 || byte_width == 0) { + return num_valid; + } + PARQUET_THROW_NOT_OK(sink.Reserve(num_valid * byte_width)); + VisitSetBitRunsVoid(valid_bits, valid_bits_offset, num_values, + [&](int64_t start, int64_t length) { + for (int64_t i = start; i < start + length; ++i) { + DCHECK(src[i].ptr != nullptr) << "Value ptr cannot be NULL"; + sink.UnsafeAppend(src[i].ptr, byte_width); + } + }); + return num_valid; +} + // ---------------------------------------------------------------------- // PLAIN encoder @@ -151,28 +256,13 @@ class PlainEncoder : public EncoderImpl, virtual public TypedEncoder { void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - if (valid_bits == nullptr || num_values == 0) { - return Put(src, num_values); - } - if constexpr (::arrow::internal::IsOneOf::value) { - // Binary input contains descriptors; Put encodes the bytes they reference. - ::arrow::internal::VisitSetBitRunsVoid(valid_bits, valid_bits_offset, num_values, - [&](int64_t start, int64_t length) { - Put(src + start, static_cast(length)); - }); + if constexpr (std::is_same_v) { + AppendSpacedFLBA(sink_, src, num_values, valid_bits, valid_bits_offset, + type_length_); + } else if constexpr (std::is_same_v) { + PutSpacedRuns(this, src, num_values, valid_bits, valid_bits_offset); } else { - // Compact directly into the page, reserving only space for present values. - const int64_t count = - ::arrow::internal::CountSetBits(valid_bits, valid_bits_offset, num_values); - if (count == 0) { - return; - } - const int64_t bytes = count * static_cast(sizeof(T)); - PARQUET_THROW_NOT_OK(sink_.Reserve(bytes)); - T* out = reinterpret_cast(sink_.mutable_data() + sink_.length()); - ::arrow::util::internal::SpacedCompress(src, num_values, valid_bits, - valid_bits_offset, out); - sink_.UnsafeAdvance(bytes); + AppendSpacedValues(sink_, src, num_values, valid_bits, valid_bits_offset); } } @@ -228,41 +318,9 @@ inline void PlainEncoder::Put(const ByteArray* src, int num_value } } -template -void DirectPutImpl(const ::arrow::Array& values, ::arrow::BufferBuilder* sink) { - if (values.type_id() != ArrayType::TypeClass::type_id) { - std::string type_name = ArrayType::TypeClass::type_name(); - throw ParquetException("direct put to " + type_name + " from " + - values.type()->ToString() + " not supported"); - } - - using value_type = typename ArrayType::value_type; - constexpr auto value_size = sizeof(value_type); - auto raw_values = checked_cast(values).raw_values(); - - if (values.null_count() == 0) { - // no nulls, just dump the data - PARQUET_THROW_NOT_OK(sink->Append(raw_values, values.length() * value_size)); - } else { - PARQUET_THROW_NOT_OK( - sink->Reserve((values.length() - values.null_count()) * value_size)); - - for (int64_t i = 0; i < values.length(); i++) { - if (values.IsValid(i)) { - sink->UnsafeAppend(&raw_values[i], value_size); - } - } - } -} - -template <> -void PlainEncoder::Put(const ::arrow::Array& values) { - DirectPutImpl<::arrow::Int32Array>(values, &sink_); -} - -template <> -void PlainEncoder::Put(const ::arrow::Array& values) { - DirectPutImpl<::arrow::Int64Array>(values, &sink_); +template +void PlainEncoder::Put(const ::arrow::Array& values) { + AppendNumericArray(values, sink_); } template <> @@ -270,21 +328,6 @@ void PlainEncoder::Put(const ::arrow::Array& values) { ParquetException::NYI("direct put to Int96"); } -template <> -void PlainEncoder::Put(const ::arrow::Array& values) { - DirectPutImpl<::arrow::FloatArray>(values, &sink_); -} - -template <> -void PlainEncoder::Put(const ::arrow::Array& values) { - DirectPutImpl<::arrow::DoubleArray>(values, &sink_); -} - -template -void PlainEncoder::Put(const ::arrow::Array& values) { - ParquetException::NYI("direct put of " + values.type()->ToString()); -} - void AssertVarLengthBinary(const ::arrow::Array& values) { if (!::arrow::is_base_binary_like(values.type_id()) && !::arrow::is_binary_view_like(values.type_id())) { @@ -320,25 +363,8 @@ void AssertFixedSizeBinary(const ::arrow::Array& values, int type_length) { template <> inline void PlainEncoder::Put(const ::arrow::Array& values) { AssertFixedSizeBinary(values, descr_->type_length()); - if (values.length() == 0) { - return; - } const auto& data = checked_cast(values); - - if (data.null_count() == 0) { - // no nulls, just dump the data - PARQUET_THROW_NOT_OK( - sink_.Append(data.raw_values(), data.length() * data.byte_width())); - } else { - const int64_t total_bytes = - data.length() * data.byte_width() - data.null_count() * data.byte_width(); - PARQUET_THROW_NOT_OK(sink_.Reserve(total_bytes)); - for (int64_t i = 0; i < data.length(); i++) { - if (data.IsValid(i)) { - sink_.UnsafeAppend(data.Value(i), data.byte_width()); - } - } - } + AppendFixedWidthArray(data, data.raw_values(), data.byte_width(), sink_); } template <> @@ -369,16 +395,19 @@ class PlainEncoder : public EncoderImpl, virtual public BooleanEnco void PutSpaced(const bool* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->mutable_data_as(); - int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); - } else { - Put(src, num_values); + const int64_t num_valid = + valid_bits == nullptr + ? num_values + : ::arrow::internal::CountSetBits(valid_bits, valid_bits_offset, num_values); + if (num_valid == 0) { + return; } + PARQUET_THROW_NOT_OK(sink_.Reserve(num_valid)); + VisitSetBitRunsVoid( + valid_bits, valid_bits_offset, num_values, [&](int64_t first, int64_t length) { + const bool* ptr = src + first; + sink_.UnsafeAppend(length, [&] { return *ptr++; }); + }); } void Put(const ::arrow::Array& values) override { @@ -388,19 +417,16 @@ class PlainEncoder : public EncoderImpl, virtual public BooleanEnco } const auto& data = checked_cast(values); - if (data.null_count() == 0) { - // no nulls, just dump the data - PARQUET_THROW_NOT_OK(sink_.Reserve(data.length())); - sink_.UnsafeAppend(data.data()->GetValues(1, 0), data.offset(), - data.length()); - } else { - PARQUET_THROW_NOT_OK(sink_.Reserve(data.length() - data.null_count())); - for (int64_t i = 0; i < data.length(); i++) { - if (data.IsValid(i)) { - sink_.UnsafeAppend(data.Value(i)); - } - } + const int64_t num_valid = data.length() - data.null_count(); + if (num_valid == 0) { + return; } + PARQUET_THROW_NOT_OK(sink_.Reserve(num_valid)); + const auto* bits = data.data()->GetValues(1, 0); + VisitSetBitRunsVoid(num_valid == data.length() ? nullptr : data.null_bitmap_data(), + data.offset(), data.length(), [&](int64_t start, int64_t length) { + sink_.UnsafeAppend(bits, data.offset() + start, length); + }); } private: @@ -541,12 +567,7 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - ::arrow::internal::VisitSetBitRunsVoid(valid_bits, valid_bits_offset, num_values, - [&](int64_t position, int64_t length) { - for (int64_t i = 0; i < length; i++) { - Put(SafeLoad(src + i + position)); - } - }); + PutSpacedRuns(this, src, num_values, valid_bits, valid_bits_offset); } using TypedEncoder::Put; @@ -763,39 +784,18 @@ void DictEncoderImpl::PutDictionary(const ::arrow::Array& values) { template void DictEncoderImpl::Put(const ::arrow::Array& values) { - using ArrayType = typename ::arrow::CTypeTraits::ArrayType; - const auto& data = checked_cast(values); - if (data.null_count() == 0) { - // no nulls, just dump the data - for (int64_t i = 0; i < data.length(); i++) { - Put(data.Value(i)); - } - } else { - for (int64_t i = 0; i < data.length(); i++) { - if (data.IsValid(i)) { - Put(data.Value(i)); - } - } - } -} - -template <> -void DictEncoderImpl::Put(const ::arrow::Array& values) { - AssertFixedSizeBinary(values, type_length_); - const auto& data = checked_cast(values); - if (data.null_count() == 0) { - // no nulls, just dump the data - for (int64_t i = 0; i < data.length(); i++) { - Put(FixedLenByteArray(data.Value(i))); - } - } else { - std::vector empty(type_length_, 0); - for (int64_t i = 0; i < data.length(); i++) { - if (data.IsValid(i)) { - Put(FixedLenByteArray(data.Value(i))); - } - } + using ArrowType = typename EncodingTraits::ArrowType; + using ArrayType = typename ::arrow::TypeTraits::ArrayType; + if constexpr (std::is_same_v) { + AssertFixedSizeBinary(values, type_length_); } + const auto& data = checked_cast(values); + VisitSetBitRunsVoid(data.null_count() == 0 ? nullptr : data.null_bitmap_data(), + data.offset(), data.length(), [&](int64_t start, int64_t length) { + for (int64_t i = start; i < start + length; ++i) { + Put(T{data.Value(i)}); + } + }); } template <> @@ -907,15 +907,12 @@ class ByteStreamSplitEncoderBase : public EncoderImpl, void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->template mutable_data_as(); - int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); + if constexpr (std::is_same_v) { + num_values_in_buffer_ += AppendSpacedFLBA(sink_, src, num_values, valid_bits, + valid_bits_offset, byte_width_); } else { - Put(src, num_values); + num_values_in_buffer_ += + AppendSpacedValues(sink_, src, num_values, valid_bits, valid_bits_offset); } } @@ -932,7 +929,6 @@ template class ByteStreamSplitEncoder : public ByteStreamSplitEncoderBase { public: using T = typename DType::c_type; - using ArrowType = typename EncodingTraits::ArrowType; ByteStreamSplitEncoder(const ColumnDescriptor* descr, ::arrow::MemoryPool* pool = ::arrow::default_memory_pool()) @@ -953,14 +949,8 @@ class ByteStreamSplitEncoder : public ByteStreamSplitEncoderBase { } void Put(const ::arrow::Array& values) override { - if (values.type_id() != ArrowType::type_id) { - throw ParquetException(std::string() + "direct put from " + - values.type()->ToString() + " not supported"); - } - const auto& data = *values.data(); - this->PutSpaced(data.GetValues(1), - static_cast(data.length), data.GetValues(0, 0), - data.offset); + this->num_values_in_buffer_ += + this->template AppendNumericArray(values, this->sink_); } }; @@ -996,26 +986,9 @@ class ByteStreamSplitEncoder : public ByteStreamSplitEncoderBase(values); - if (data.null_count() == 0) { - // no nulls, just buffer the data - PARQUET_THROW_NOT_OK(sink_.Append(data.raw_values(), data.length() * byte_width_)); - this->num_values_in_buffer_ += data.length(); - } else { - const int64_t num_values = data.length() - data.null_count(); - const int64_t total_bytes = num_values * byte_width_; - PARQUET_THROW_NOT_OK(sink_.Reserve(total_bytes)); - // TODO use VisitSetBitRunsVoid - for (int64_t i = 0; i < data.length(); i++) { - if (data.IsValid(i)) { - sink_.UnsafeAppend(data.Value(i), byte_width_); - } - } - this->num_values_in_buffer_ += num_values; - } + num_values_in_buffer_ += + AppendFixedWidthArray(data, data.raw_values(), byte_width_, sink_); } }; @@ -1032,7 +1005,6 @@ template class AlpEncoder : public EncoderImpl, virtual public TypedEncoder { public: using T = typename DType::c_type; - using ArrowType = typename EncodingTraits::ArrowType; using TypedEncoder::Put; static_assert(std::is_same_v || std::is_same_v, @@ -1082,27 +1054,11 @@ class AlpEncoder : public EncoderImpl, virtual public TypedEncoder { void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->template mutable_data_as(); - const int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); - } else { - Put(src, num_values); - } + AppendSpacedValues(sink_, src, num_values, valid_bits, valid_bits_offset); } void Put(const ::arrow::Array& values) override { - if (values.type_id() != ArrowType::type_id) { - throw ParquetException(std::string() + "direct put from " + - values.type()->ToString() + " not supported"); - } - const auto& data = *values.data(); - this->PutSpaced(data.GetValues(1), - static_cast(data.length), data.GetValues(0, 0), - data.offset); + AppendNumericArray(values, sink_); } private: @@ -1229,14 +1185,14 @@ void DeltaBitPackEncoder::Put(const T* src, int num_values) { int idx = 0; if (total_value_count_ == 0) { - current_value_ = src[0]; + current_value_ = SafeLoad(src); first_value_ = current_value_; idx = 1; } total_value_count_ += num_values; while (idx < num_values) { - T value = src[idx]; + T value = SafeLoad(src + idx); // Calculate deltas. The possible overflow is handled by use of unsigned integers // making subtraction operations well-defined and correct even in case of overflow. // Encoded integers will wrap back around on decoding. @@ -1345,57 +1301,27 @@ std::shared_ptr DeltaBitPackEncoder::FlushValues() { return SliceBuffer(std::move(buffer), offset_bytes); } -template <> -void DeltaBitPackEncoder::Put(const ::arrow::Array& values) { +template +void DeltaBitPackEncoder::Put(const ::arrow::Array& values) { + using ArrowType = typename EncodingTraits::ArrowType; const ::arrow::ArrayData& data = *values.data(); - if (values.type_id() != ::arrow::Type::INT32) { - throw ParquetException("Expected Int32TArray, got ", values.type()->ToString()); + if (values.type_id() != ArrowType::type_id) { + throw ParquetException("Expected ", ArrowType::type_name(), " array, got ", + values.type()->ToString()); } if (data.length > std::numeric_limits::max()) { throw ParquetException("Array cannot be longer than ", std::numeric_limits::max()); } - - if (values.null_count() == 0) { - Put(data.GetValues(1), static_cast(data.length)); - } else { - PutSpaced(data.GetValues(1), static_cast(data.length), - data.GetValues(0, 0), data.offset); - } -} - -template <> -void DeltaBitPackEncoder::Put(const ::arrow::Array& values) { - const ::arrow::ArrayData& data = *values.data(); - if (values.type_id() != ::arrow::Type::INT64) { - throw ParquetException("Expected Int64TArray, got ", values.type()->ToString()); - } - if (data.length > std::numeric_limits::max()) { - throw ParquetException("Array cannot be longer than ", - std::numeric_limits::max()); - } - if (values.null_count() == 0) { - Put(data.GetValues(1), static_cast(data.length)); - } else { - PutSpaced(data.GetValues(1), static_cast(data.length), - data.GetValues(0, 0), data.offset); - } + const auto* valid_bits = values.null_count() == 0 ? nullptr : values.null_bitmap_data(); + PutSpaced(data.GetValues(1), static_cast(data.length), valid_bits, data.offset); } template void DeltaBitPackEncoder::PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->template mutable_data_as(); - int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); - } else { - Put(src, num_values); - } + PutSpacedRuns(this, src, num_values, valid_bits, valid_bits_offset); } // ---------------------------------------------------------------------- @@ -1502,16 +1428,7 @@ void DeltaLengthByteArrayEncoder::Put(const T* src, int num_values) { void DeltaLengthByteArrayEncoder::PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->template mutable_data_as(); - int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); - } else { - Put(src, num_values); - } + PutSpacedRuns(this, src, num_values, valid_bits, valid_bits_offset); } std::shared_ptr DeltaLengthByteArrayEncoder::FlushValues() { @@ -1779,34 +1696,18 @@ class RleBooleanEncoder final : public EncoderImpl, virtual public BooleanEncode values.type()->ToString()); } const auto& boolean_array = checked_cast(values); - if (values.null_count() == 0) { - for (int i = 0; i < boolean_array.length(); ++i) { - // null_count == 0, so just call Value directly is ok. - buffered_append_values_.push_back(boolean_array.Value(i)); - } - } else { - PARQUET_THROW_NOT_OK(::arrow::VisitArraySpanInline<::arrow::BooleanType>( - *boolean_array.data(), - [&](bool value) { - buffered_append_values_.push_back(value); - return Status::OK(); - }, - []() { return Status::OK(); })); - } + VisitSetBitRunsVoid(values.null_count() == 0 ? nullptr : values.null_bitmap_data(), + values.offset(), values.length(), + [&](int64_t start, int64_t length) { + for (int64_t i = start; i < start + length; ++i) { + buffered_append_values_.push_back(boolean_array.Value(i)); + } + }); } void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - if (valid_bits != NULLPTR) { - PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), - this->memory_pool())); - T* data = buffer->mutable_data_as(); - int num_valid_values = ::arrow::util::internal::SpacedCompress( - src, num_values, valid_bits, valid_bits_offset, data); - Put(data, num_valid_values); - } else { - Put(src, num_values); - } + PutSpacedRuns(this, src, num_values, valid_bits, valid_bits_offset); } void Put(const std::vector& src, int num_values) override; diff --git a/cpp/src/parquet/encoding_test.cc b/cpp/src/parquet/encoding_test.cc index a8a6dcb05036..7183abaa5db6 100644 --- a/cpp/src/parquet/encoding_test.cc +++ b/cpp/src/parquet/encoding_test.cc @@ -576,8 +576,16 @@ class TestArrowBuilderDecoding : public ::testing::Test { for (auto np : null_probabilities_) { InitTestCase(dense_type, np, /*create_dict=*/true); auto builder = CreateDictBuilder(); - auto actual_num_values = decoder_->DecodeArrow(num_values_, null_count_, - valid_bits_, 0, builder.get()); + // Cross an index refill within a call and resume at a non-byte-aligned offset. + constexpr int kBatchSize = 4097; + int actual_num_values = 0; + for (int offset = 0; offset < num_values_; offset += kBatchSize) { + const int length = std::min(kBatchSize, num_values_ - offset); + const auto slice = binary_dense_->Slice(offset, length); + actual_num_values += + decoder_->DecodeArrow(length, static_cast(slice->null_count()), + valid_bits_, offset, builder.get()); + } CheckDict(actual_num_values, *builder); } } From 4690168cc40bc4d103161dd261599088378ab285 Mon Sep 17 00:00:00 2001 From: Zehua Zou Date: Thu, 3 Dec 2026 16:50:22 +0800 Subject: [PATCH 2/2] address comments --- cpp/src/arrow/array/builder_binary.h | 4 ++-- cpp/src/parquet/column_writer.cc | 2 +- cpp/src/parquet/decoder.cc | 10 +++++----- cpp/src/parquet/encoder.cc | 18 ++++-------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/cpp/src/arrow/array/builder_binary.h b/cpp/src/arrow/array/builder_binary.h index 12f7e45f3421..20c803fb65cd 100644 --- a/cpp/src/arrow/array/builder_binary.h +++ b/cpp/src/arrow/array/builder_binary.h @@ -109,8 +109,8 @@ class BaseBinaryBuilder Status AppendNulls(int64_t length) final { const int64_t num_bytes = value_data_builder_.length(); ARROW_RETURN_NOT_OK(Reserve(length)); - for (int64_t i = 0; i < length; ++i) { - offsets_builder_.UnsafeAppend(static_cast(num_bytes)); + if (length > 0) { + offsets_builder_.UnsafeAppend(length, static_cast(num_bytes)); } UnsafeAppendToBitmap(length, false); return Status::OK(); diff --git a/cpp/src/parquet/column_writer.cc b/cpp/src/parquet/column_writer.cc index 033939a32198..b087307a4bb3 100644 --- a/cpp/src/parquet/column_writer.cc +++ b/cpp/src/parquet/column_writer.cc @@ -2382,7 +2382,7 @@ struct SerializeFunctor { return ::arrow::internal::VisitSetBitRuns( valid_bits, array.offset(), array.length(), [&](int64_t start, int64_t length) { for (int64_t i = start; i < start + length; ++i) { - if (!truncation_allowed && values[i] % factor != 0) { + if (ARROW_PREDICT_FALSE(!truncation_allowed && values[i] % factor != 0)) { return Status::Invalid("Casting from ", source_type.ToString(), " to ", target_type->ToString(), " would lose data: ", values[i]); diff --git a/cpp/src/parquet/decoder.cc b/cpp/src/parquet/decoder.cc index a3e6bfa50565..1cf7278e3034 100644 --- a/cpp/src/parquet/decoder.cc +++ b/cpp/src/parquet/decoder.cc @@ -103,9 +103,8 @@ struct ArrowBinaryHelper { // If a new chunk is created and estimated_remaining_data_length is provided, // it will also reserve the estimated data length for this chunk. - ARROW_FORCE_INLINE Status - AppendValue(const uint8_t* data, int32_t length, - std::optional estimated_remaining_data_length = {}) { + Status AppendValue(const uint8_t* data, int32_t length, + std::optional estimated_remaining_data_length = {}) { DCHECK_GT(entries_remaining_, 0); if (ARROW_PREDICT_FALSE(!CanFit(length))) { @@ -1303,9 +1302,10 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl { int64_t valid_bits_offset, typename EncodingTraits::Accumulator* out) override { int result = 0; - // The encoded indices size doesn't tell us how many bytes the values will occupy. PARQUET_THROW_NOT_OK(DispatchArrowBinaryHelper( - out, num_values, /*estimated_data_length=*/{}, [&](auto* helper) { + out, num_values, + // The encoded index stream length cannot predict the decoded payload size. + /*estimated_data_length=*/std::nullopt, [&](auto* helper) { return DecodeArrowRuns( num_values, null_count, valid_bits, valid_bits_offset, &result, [&](const ByteArray& value) { diff --git a/cpp/src/parquet/encoder.cc b/cpp/src/parquet/encoder.cc index 9d22567b09e8..cb12ac4b7460 100644 --- a/cpp/src/parquet/encoder.cc +++ b/cpp/src/parquet/encoder.cc @@ -115,10 +115,6 @@ class EncoderImpl : virtual public Encoder { } protected: - template - int64_t AppendNumericArray(const ::arrow::Array& values, - ::arrow::BufferBuilder& sink) const; - // For accessing type-specific metadata, like FIXED_LEN_BYTE_ARRAY const ColumnDescriptor* descr_; const Encoding::type encoding_; @@ -151,17 +147,12 @@ int64_t AppendFixedWidthArray(const ::arrow::Array& array, const uint8_t* values } template -int64_t EncoderImpl::AppendNumericArray(const ::arrow::Array& values, - ::arrow::BufferBuilder& sink) const { +int64_t AppendNumericArray(const ::arrow::Array& values, ::arrow::BufferBuilder& sink) { using ArrowType = typename EncodingTraits::ArrowType; using ArrayType = typename ::arrow::TypeTraits::ArrayType; if (values.type_id() != ArrowType::type_id) { - if (encoding_ == Encoding::PLAIN) { - throw ParquetException("direct put to ", ArrowType::type_name(), " from ", - values.type()->ToString(), " not supported"); - } - throw ParquetException("direct put from ", values.type()->ToString(), - " not supported"); + throw ParquetException("Expected ", ArrowType::type_name(), " array, got ", + values.type()->ToString()); } const auto& array = checked_cast(values); @@ -949,8 +940,7 @@ class ByteStreamSplitEncoder : public ByteStreamSplitEncoderBase { } void Put(const ::arrow::Array& values) override { - this->num_values_in_buffer_ += - this->template AppendNumericArray(values, this->sink_); + this->num_values_in_buffer_ += AppendNumericArray(values, this->sink_); } };