felipecrv commented on code in PR #33641:
URL: https://github.com/apache/arrow/pull/33641#discussion_r1104731628


##########
cpp/src/arrow/array/array_run_end.cc:
##########
@@ -0,0 +1,88 @@
+// 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_run_end.h"
+#include "arrow/array/util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/ree_util.h"
+
+namespace arrow {
+
+// ----------------------------------------------------------------------
+// RunEndEncodedArray
+
+RunEndEncodedArray::RunEndEncodedArray(const std::shared_ptr<ArrayData>& data) 
{
+  this->SetData(data);
+}
+
+RunEndEncodedArray::RunEndEncodedArray(const std::shared_ptr<DataType>& type,
+                                       int64_t length,
+                                       const std::shared_ptr<Array>& run_ends,
+                                       const std::shared_ptr<Array>& values,
+                                       int64_t offset) {
+  this->SetData(ArrayData::Make(type, length,
+                                /*buffers=*/{NULLPTR},
+                                /*child_data=*/{run_ends->data(), 
values->data()},
+                                /*null_count=*/0, offset));

Review Comment:
   `SetData` itself checks against `RUN_END_ENCODED`
   
   ```cpp
   void RunEndEncodedArray::SetData(const std::shared_ptr<ArrayData>& data) {
     ARROW_CHECK_EQ(data->type->id(), Type::RUN_END_ENCODED);
     ...
   ```
   
   I looked at other arrays with parameterized types and the prevalent style 
seems to be: check only the top-level type id and leave the deeper checks to 
`Validate`.
   
   ```cpp
   ListArray::ListArray(std::shared_ptr<ArrayData> data) { 
SetData(std::move(data)); }
   
   LargeListArray::LargeListArray(const std::shared_ptr<ArrayData>& data) { 
SetData(data); }
   
   ListArray::ListArray(std::shared_ptr<DataType> type, int64_t length,
                        std::shared_ptr<Buffer> value_offsets, 
std::shared_ptr<Array> values,
                        std::shared_ptr<Buffer> null_bitmap, int64_t null_count,
                        int64_t offset) {
     ARROW_CHECK_EQ(type->id(), Type::LIST);
     auto internal_data = ArrayData::Make(
         std::move(type), length,
         BufferVector{std::move(null_bitmap), std::move(value_offsets)}, 
null_count, offset);
     internal_data->child_data.emplace_back(values->data());
     SetData(std::move(internal_data));
   }
   
   void ListArray::SetData(const std::shared_ptr<ArrayData>& data) {
     internal::SetListData(this, data);
   }
   ```



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