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


##########
cpp/src/arrow/util/rle_util.cc:
##########
@@ -0,0 +1,32 @@
+#include "arrow/util/rle_util.h"
+#include <algorithm>
+#include "arrow/builder.h"
+
+namespace arrow {
+namespace rle_util {
+
+int64_t FindPhysicalOffset(const int32_t* accumulated_run_lengths,
+                           int64_t physical_length, int64_t logical_offset) {
+  auto it = std::upper_bound(accumulated_run_lengths,
+                             accumulated_run_lengths + physical_length, 
logical_offset);
+  return std::distance(accumulated_run_lengths, it);
+}
+
+int64_t FindPhysicalIndex(const int32_t* accumulated_run_lengths,
+                          int64_t physical_length, int64_t physical_offset, 
int64_t logical_offset, int64_t logical_index) {
+  auto it = std::upper_bound(accumulated_run_lengths + physical_offset,
+                             accumulated_run_lengths + physical_offset + 
physical_length,
+                             logical_index + logical_offset);
+  return std::distance(accumulated_run_lengths, it);

Review Comment:
   Yes! I ended up moving that logic to a function called GetPhysicalLength, 
since that is what it ended up being used for, but did not notice the wrong end 
iterator to upper_bound here



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