pitrou commented on code in PR #40094:
URL: https://github.com/apache/arrow/pull/40094#discussion_r1494371128
##########
cpp/src/parquet/encoding.cc:
##########
@@ -801,98 +804,154 @@ void DictEncoderImpl<ByteArrayType>::PutDictionary(const
::arrow::Array& values)
// ----------------------------------------------------------------------
// ByteStreamSplitEncoder<T> implementations
+// Common base class for all types
+
template <typename DType>
-class ByteStreamSplitEncoder : public EncoderImpl, virtual public
TypedEncoder<DType> {
+class ByteStreamSplitEncoderBase : public EncoderImpl,
+ virtual public TypedEncoder<DType> {
public:
using T = typename DType::c_type;
using TypedEncoder<DType>::Put;
- explicit ByteStreamSplitEncoder(
- const ColumnDescriptor* descr,
- ::arrow::MemoryPool* pool = ::arrow::default_memory_pool());
+ ByteStreamSplitEncoderBase(const ColumnDescriptor* descr, int byte_width,
+ ::arrow::MemoryPool* pool =
::arrow::default_memory_pool())
+ : EncoderImpl(descr, Encoding::BYTE_STREAM_SPLIT, pool),
+ sink_{pool},
+ byte_width_(byte_width),
+ num_values_in_buffer_{0} {}
- int64_t EstimatedDataEncodedSize() override;
- std::shared_ptr<Buffer> FlushValues() override;
+ int64_t EstimatedDataEncodedSize() override { return sink_.length(); }
- void Put(const T* buffer, int num_values) override;
- void Put(const ::arrow::Array& values) override;
- void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits,
- int64_t valid_bits_offset) override;
+ std::shared_ptr<Buffer> FlushValues() override {
+ if (byte_width_ == 1) {
+ // Special-cased fast path
+ PARQUET_ASSIGN_OR_THROW(auto buf, sink_.Finish());
+ return buf;
+ }
+ auto output_buffer = AllocateBuffer(this->memory_pool(),
EstimatedDataEncodedSize());
+ uint8_t* output_buffer_raw = output_buffer->mutable_data();
+ const uint8_t* raw_values = sink_.data();
+ ::arrow::util::internal::ByteStreamSplitEncode(
+ raw_values, /*width=*/byte_width_, num_values_in_buffer_,
output_buffer_raw);
+ sink_.Reset();
+ num_values_in_buffer_ = 0;
+ return std::move(output_buffer);
Review Comment:
Will remove.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]