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

Method try_append_view

arrow-array/src/builder/generic_bytes_view_builder.rs:255–279  ·  view source on GitHub ↗

Try to append a view of the given `block`, `offset` and `length` See [`Self::append_block`]

(&mut self, block: u32, offset: u32, len: u32)

Source from the content-addressed store, hash-verified

253 ///
254 /// See [`Self::append_block`]
255 pub fn try_append_view(&mut self, block: u32, offset: u32, len: u32) -> Result<(), ArrowError> {
256 let b = self.completed.get(block as usize).ok_or_else(|| {
257 ArrowError::InvalidArgumentError(format!("No block found with index {block}"))
258 })?;
259 let start = offset as usize;
260 let end = start.saturating_add(len as usize);
261
262 let b = b.get(start..end).ok_or_else(|| {
263 ArrowError::InvalidArgumentError(format!(
264 "Range {start}..{end} out of bounds for block of length {}",
265 b.len()
266 ))
267 })?;
268
269 if T::Native::from_bytes_checked(b).is_none() {
270 return Err(ArrowError::InvalidArgumentError(
271 "Invalid view data".to_string(),
272 ));
273 }
274
275 unsafe {
276 self.append_view_unchecked(block, offset, len);
277 }
278 Ok(())
279 }
280
281 /// Flushes the in progress block if any
282 #[inline]

Callers 4

test_caseFunction · 0.80
test_string_viewFunction · 0.80
test_gc_huge_arrayFunction · 0.80

Calls 2

append_view_uncheckedMethod · 0.80
getMethod · 0.45

Tested by 3

test_caseFunction · 0.64
test_string_viewFunction · 0.64
test_gc_huge_arrayFunction · 0.64