Try to append a view of the given `block`, `offset` and `length` See [`Self::append_block`]
(&mut self, block: u32, offset: u32, len: u32)
| 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] |