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

Method sliced_values

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

Returns an iterator yielding run ends adjusted for the logical slice. Each yielded value is subtracted by the [`logical_offset`] and capped at the [`logical_length`]. [`logical_offset`]: Self::offset [`logical_length`]: Self::len

(&self)

Source from the content-addressed store, hash-verified

197 /// [`logical_offset`]: Self::offset
198 /// [`logical_length`]: Self::len
199 pub fn sliced_values(&self) -> impl Iterator<Item = E> + '_ {
200 let offset = self.logical_offset;
201 let len = self.logical_length;
202 // Doing this roundabout way since the iterator type we return must be
203 // the same (i.e. cannot use std::iter::empty())
204 let physical_slice = if self.is_empty() {
205 &self.run_ends[0..0]
206 } else {
207 let start = self.get_start_physical_index();
208 let end = self.get_end_physical_index();
209 &self.run_ends[start..=end]
210 };
211 physical_slice.iter().map(move |&val| {
212 let val = val.as_usize().saturating_sub(offset).min(len);
213 E::from_usize(val).unwrap()
214 })
215 }
216
217 /// Returns the maximum run-end encoded in the underlying buffer; that is, the
218 /// last physical run of the buffer. This does not take into account any logical

Callers 7

test_sliced_valuesFunction · 0.80
run_end_encoded_castFunction · 0.80
compute_lengthsFunction · 0.80
encodeFunction · 0.80
concat_run_arraysFunction · 0.80
foldFunction · 0.80
run_equal_innerFunction · 0.80

Calls 5

as_usizeMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by 1

test_sliced_valuesFunction · 0.64