Read null bitmap from a FileRead at the given handle.
(
reader: &dyn FileRead,
handle: &BlockHandle,
)
| 368 | |
| 369 | /// Read null bitmap from a FileRead at the given handle. |
| 370 | async fn read_null_bitmap( |
| 371 | reader: &dyn FileRead, |
| 372 | handle: &BlockHandle, |
| 373 | ) -> io::Result<RoaringTreemap> { |
| 374 | let offset = handle.offset; |
| 375 | let size = handle.size as u64; |
| 376 | // Read bitmap bytes + CRC (4 bytes) |
| 377 | let bytes = reader |
| 378 | .read(offset..offset + size + 4) |
| 379 | .await |
| 380 | .map_err(|e| io::Error::other(e.to_string()))?; |
| 381 | let bitmap_bytes = &bytes[..size as usize]; |
| 382 | let crc_bytes = &bytes[size as usize..]; |
| 383 | |
| 384 | verify_null_bitmap_crc(bitmap_bytes, crc_bytes)?; |
| 385 | |
| 386 | RoaringTreemap::deserialize_from(bitmap_bytes) |
| 387 | .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) |
| 388 | } |
| 389 | |
| 390 | fn verify_null_bitmap_crc(bitmap_bytes: &[u8], crc_bytes: &[u8]) -> io::Result<()> { |
| 391 | let expected_crc = u32::from_le_bytes([crc_bytes[0], crc_bytes[1], crc_bytes[2], crc_bytes[3]]); |
no test coverage detected