drin commented on code in PR #13330:
URL: https://github.com/apache/arrow/pull/13330#discussion_r952032146


##########
cpp/src/arrow/array/array_encoded.cc:
##########
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "arrow/array/array_encoded.h"
+#include "arrow/array/util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/rle_util.h"
+
+namespace arrow {
+
+// ----------------------------------------------------------------------
+// RunLengthEncodedArray
+
+RunLengthEncodedArray::RunLengthEncodedArray(const std::shared_ptr<ArrayData>& 
data) {
+  ARROW_CHECK_EQ(data->type->id(), Type::RUN_LENGTH_ENCODED);
+  SetData(data);
+}
+
+RunLengthEncodedArray::RunLengthEncodedArray(const std::shared_ptr<DataType>& 
type,
+                                             int64_t length,
+                                             const std::shared_ptr<Array>& 
run_ends_array,
+                                             const std::shared_ptr<Array>& 
values_array,
+                                             int64_t offset) {
+  ARROW_CHECK_EQ(type->id(), Type::RUN_LENGTH_ENCODED);
+  SetData(ArrayData::Make(type, length, {NULLPTR}, 0, offset));
+  data_->child_data.push_back(std::move(run_ends_array->data()));
+  data_->child_data.push_back(std::move(values_array->data()));

Review Comment:
   Is there design documentation somewhere?
   
   I think this approach makes sense, but I'm just wondering what the 
trade-offs are compared to having run ends and values in a single Array, in a 
similar layout as [variable-sized 
binary](https://arrow.apache.org/docs/format/Columnar.html#variable-size-binary-layout)?
 I suspect this approach is just more flexible, especially for run length 
encoding a nested type array; though, there is likely more to it than that.



-- 
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]

Reply via email to