Vector columns → BinaryArray of packed f32 bytes. Each entry is `dim * 4` bytes of packed little-endian f32.
(
decoder: &TupleDecoder,
tuples: &[&[u8]],
col_idx: usize,
n: usize,
dim: usize,
)
| 336 | /// Vector columns → BinaryArray of packed f32 bytes. |
| 337 | /// Each entry is `dim * 4` bytes of packed little-endian f32. |
| 338 | fn extract_vector( |
| 339 | decoder: &TupleDecoder, |
| 340 | tuples: &[&[u8]], |
| 341 | col_idx: usize, |
| 342 | n: usize, |
| 343 | dim: usize, |
| 344 | ) -> Result<ArrayRef, StrictError> { |
| 345 | let (null_buf, null_count) = build_null_buffer(decoder, tuples, col_idx)?; |
| 346 | let vec_size = dim * 4; |
| 347 | let mut blobs: Vec<Option<&[u8]>> = Vec::with_capacity(n); |
| 348 | |
| 349 | for tuple in tuples { |
| 350 | if let Some(raw) = decoder.extract_fixed_raw(tuple, col_idx)? { |
| 351 | blobs.push(Some(&raw[..vec_size])); |
| 352 | } else { |
| 353 | blobs.push(None); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | let array = BinaryArray::from(blobs); |
| 358 | if null_count > 0 { |
| 359 | let data = array |
| 360 | .into_data() |
| 361 | .into_builder() |
| 362 | .null_bit_buffer(Some(null_buf.into_inner().into_inner())) |
| 363 | .build() |
| 364 | .expect("arrow array builder lengths are consistent"); |
| 365 | Ok(Arc::new(BinaryArray::from(data))) |
| 366 | } else { |
| 367 | Ok(Arc::new(array)) |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | #[cfg(test)] |
| 372 | mod tests { |
no test coverage detected