felipecrv commented on code in PR #34550:
URL: https://github.com/apache/arrow/pull/34550#discussion_r1136410804
##########
cpp/src/arrow/array/array_run_end.cc:
##########
@@ -85,6 +86,53 @@ void RunEndEncodedArray::SetData(const
std::shared_ptr<ArrayData>& data) {
values_array_ = MakeArray(this->data()->child_data[1]);
}
+namespace {
+
+template <typename RunEndType>
+Result<std::shared_ptr<Array>> MakeLogicalRunEnds(const RunEndEncodedArray&
self,
+ int64_t physical_offset,
+ int64_t physical_length) {
+ using RunEndCType = typename RunEndType::c_type;
+ const auto* run_ends = self.data()->child_data[0]->GetValues<RunEndCType>(1);
+ NumericBuilder<RunEndType> builder;
+ RETURN_NOT_OK(builder.Resize(physical_length));
+ if (physical_length > 0) {
+ for (int64_t i = 0; i < physical_length - 1; i++) {
+ const auto run_end = run_ends[physical_offset + i] - self.offset();
+ DCHECK_LT(run_end, self.length());
+ RETURN_NOT_OK(builder.Append(static_cast<RunEndCType>(run_end)));
+ }
+ DCHECK_GE(run_ends[physical_offset + physical_length - 1] - self.offset(),
+ self.length());
+ RETURN_NOT_OK(builder.Append(static_cast<RunEndCType>(self.length())));
+ }
Review Comment:
Check added. :heavy_check_mark:
--
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]