askoa commented on code in PR #3662:
URL: https://github.com/apache/arrow-rs/pull/3662#discussion_r1102137467
##########
arrow-array/src/array/run_array.rs:
##########
@@ -204,12 +222,36 @@ impl<R: RunEndIndexType> RunArray<R> {
.unwrap()
});
+ // Return early if all the logical indices cannot be converted to
physical indices.
+ let largest_logical_index =
+ logical_indices[*ordered_indices.last().unwrap()].as_usize();
+ if largest_logical_index >= self.len() {
+ return Err(ArrowError::InvalidArgumentError(format!(
+ "Cannot convert all logical indices to physical indices. The
logical index cannot be converted is {largest_logical_index}.",
+ )));
+ }
+
+ // Skip some physical indices based on offset.
+ let skip_value = if self.offset() > 0 {
+ Self::get_physical_index_from_run_ends_array(self.run_ends(),
self.offset())
Review Comment:
just to be more specific offset >= last value of run_ends array. `len` might
also refer to length of slice so wanted to be more specific.
--
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]