rok commented on code in PR #14341:
URL: https://github.com/apache/arrow/pull/14341#discussion_r1122203542
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2900,6 +2900,124 @@ class RleBooleanDecoder : public DecoderImpl, virtual
public BooleanDecoder {
// ----------------------------------------------------------------------
// DELTA_BYTE_ARRAY
+// This is also known as incremental encoding or front compression: for each
element in a
+// sequence of strings, store the prefix length of the previous entry plus the
suffix.
+//
+// This is stored as a sequence of delta-encoded prefix lengths
(DELTA_BINARY_PACKED),
+// followed by the suffixes encoded as delta length byte arrays
(DELTA_LENGTH_BYTE_ARRAY).
+
+// ----------------------------------------------------------------------
+// DeltaByteArrayEncoder
+
+template <typename DType>
+class DeltaByteArrayEncoder : public EncoderImpl, virtual public
TypedEncoder<DType> {
+ public:
+ using T = typename DType::c_type;
+
+ explicit DeltaByteArrayEncoder(const ColumnDescriptor* descr, MemoryPool*
pool)
+ : EncoderImpl(descr, Encoding::DELTA_BYTE_ARRAY,
+ pool = ::arrow::default_memory_pool()),
+ sink_(pool),
+ prefix_length_encoder_(nullptr, pool),
+ suffix_encoder_(nullptr, pool) {}
+
+ std::shared_ptr<Buffer> FlushValues() override;
+
+ int64_t EstimatedDataEncodedSize() override {
+ return prefix_length_encoder_.EstimatedDataEncodedSize() +
+ suffix_encoder_.EstimatedDataEncodedSize();
+ }
+
+ using TypedEncoder<DType>::Put;
+
+ void Put(const ::arrow::Array& values) override {
+ AssertBaseBinary(values);
+ const auto& data = values.data();
Review Comment:
Indeed. Added.
--
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]