rok commented on code in PR #14293:
URL: https://github.com/apache/arrow/pull/14293#discussion_r1053554906


##########
cpp/src/parquet/encoding.cc:
##########
@@ -2537,6 +2537,100 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual 
public TypedDecoder<DTyp
 // ----------------------------------------------------------------------
 // DELTA_LENGTH_BYTE_ARRAY
 
+// ----------------------------------------------------------------------
+// DeltaLengthByteArrayEncoder
+
+class DeltaLengthByteArrayEncoder : public EncoderImpl,
+                                    virtual public TypedEncoder<ByteArrayType> 
{
+ public:
+  using T = typename ByteArrayType::c_type;
+
+  explicit DeltaLengthByteArrayEncoder(const ColumnDescriptor* descr, 
MemoryPool* pool)
+      : EncoderImpl(descr, Encoding::DELTA_LENGTH_BYTE_ARRAY,
+                    pool = ::arrow::default_memory_pool()),
+        sink_(pool),
+        length_encoder_(nullptr, pool),
+        encoded_size_{0},
+        lengths_{0} {}
+
+  std::shared_ptr<Buffer> FlushValues() override;
+
+  int64_t EstimatedDataEncodedSize() override { return encoded_size_; }
+
+  using TypedEncoder<ByteArrayType>::Put;
+
+  void Put(const ::arrow::Array& values) override;
+
+  void Put(const T* buffer, int num_values) override;
+
+  void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits,
+                 int64_t valid_bits_offset) override;
+
+ protected:
+  ::arrow::BufferBuilder sink_;
+  DeltaBitPackEncoder<Int32Type> length_encoder_;
+  uint32_t encoded_size_;
+  std::vector<int32_t> lengths_;
+};
+
+void DeltaLengthByteArrayEncoder::Put(const ::arrow::Array& values) {
+  auto src = values.data()->GetValues<ByteArray>(1);
+  Put(src, static_cast<int>(values.length()));
+}
+
+void DeltaLengthByteArrayEncoder::Put(const T* src, int num_values) {
+  if (num_values == 0) {
+    return;
+  }
+  lengths_.resize(num_values);

Review Comment:
   Do you mean something like:
   ```cpp
   void DeltaLengthByteArrayEncoder::Put(const T* src, int num_values) {
     [...]
     for (int idx = 0; idx < num_values; idx++) {
       const int32_t len = src[idx].len;
       length_encoder_.Put(&len, 1);
       encoded_size_ += len;
     }
   
     for (int idx = 0; idx < num_values; idx++) {
       sink_.UnsafeAppend(src[idx].ptr, src[idx].len);
     }
   }
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to