fenfeng9 commented on code in PR #50768:
URL: https://github.com/apache/arrow/pull/50768#discussion_r4125391223
##########
cpp/gdb_arrow.py:
##########
@@ -1831,6 +1862,40 @@ def children(self):
yield self._null_child(i)
+class RunEndEncodedArrayDataPrinter(ArrayDataPrinter):
+ """
+ ArrayDataPrinter specialization for run-end encoded arrays.
+ """
+
+ def __init__(self, name, val):
+ if self.length == 0:
+ return
+ child_data = StdVector(self.val['child_data'])
+ self._run_ends_printer = ArrayDataPrinter(
+ "arrow::ArrayData", deref(child_data[0]))
+ self._values_printer = ArrayDataPrinter(
+ "arrow::ArrayData", deref(child_data[1]))
+
+ def display_hint(self):
+ return "array"
+
+ def children(self):
+ if self.length == 0:
+ return
+ run_ends = self._run_ends_printer._unpacked_buffer_values(
+ 1, self._run_ends_printer.type_id)
+ values = iter(self._values_printer.children() or ())
+ physical_index, value = 0, None
+ for i in range(self.length):
+ target = bisect_right(run_ends, self.offset + i)
+ while physical_index <= target:
+ value = next(values, None)
+ if value is None:
+ return
+ physical_index += 1
+ yield self._valid_child(i, value[1])
Review Comment:
Thanks! I now use one `bisect_right()` call, then iterate through the runs
in order.
--
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]