MCPcopy Create free account
hub / github.com/apache/arrow-rs / get_physical_index

Method get_physical_index

arrow-buffer/src/buffer/run.rs:232–240  ·  view source on GitHub ↗

Performs a binary search to find the physical index for the given logical index. Useful for extracting the corresponding physical `run_ends` when this buffer is logically sliced. The result is arbitrary if `logical_index >= self.len()`.

(&self, logical_index: usize)

Source from the content-addressed store, hash-verified

230 ///
231 /// The result is arbitrary if `logical_index >= self.len()`.
232 pub fn get_physical_index(&self, logical_index: usize) -> usize {
233 let logical_index = E::usize_as(self.logical_offset + logical_index);
234 let cmp = |p: &E| p.partial_cmp(&logical_index).unwrap();
235
236 match self.run_ends.binary_search_by(cmp) {
237 Ok(idx) => idx + 1,
238 Err(idx) => idx,
239 }
240 }
241
242 /// Returns the physical index at which the logical array starts.
243 ///

Calls 1

partial_cmpMethod · 0.45