felipecrv commented on code in PR #34526:
URL: https://github.com/apache/arrow/pull/34526#discussion_r1139111508
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2838,6 +2839,109 @@ class DeltaLengthByteArrayDecoder : public DecoderImpl,
std::shared_ptr<ResizableBuffer> buffered_data_;
};
+// ----------------------------------------------------------------------
+// RLE_BOOLEAN_ENCODER
+
+class RleBooleanEncoder final : public EncoderImpl, virtual public
BooleanEncoder {
+ public:
+ explicit RleBooleanEncoder(const ColumnDescriptor* descr,
::arrow::MemoryPool* pool)
+ : EncoderImpl(descr, Encoding::RLE, pool) {}
+
+ int64_t EstimatedDataEncodedSize() override {
+ return kRleLengthInBytes + MaxRleBufferSize();
+ }
+
+ std::shared_ptr<Buffer> FlushValues() override;
+
+ void Put(const T* buffer, int num_values) override;
+ void Put(const ::arrow::Array& values) override {
+ if (values.type_id() != ::arrow::Type::BOOL) {
+ throw ParquetException("RleBooleanEncoder expects BooleanArray, got ",
+ values.type()->ToString());
+ }
+ const auto& boolean_array = checked_cast<const
::arrow::BooleanArray&>(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(); }));
Review Comment:
Not handling nulls?
--
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]