in src/columnar_storage/src/manifest/encoding.rs [271:292]
fn try_from(bytes: Bytes) -> Result<Self> {
if bytes.is_empty() {
return Ok(Snapshot::default());
}
let bytes_len = bytes.len();
let mut cursor = Cursor::new(bytes);
let header = SnapshotHeader::try_new(&mut cursor)?;
let record_total_length = header.length as usize;
ensure!(
record_total_length > 0
&& record_total_length % SnapshotRecord::LENGTH == 0
&& record_total_length + SnapshotHeader::LENGTH == bytes_len,
"create snapshot from bytes failed, header:{header:?}, bytes_length: {bytes_len}",
);
let mut records = Vec::with_capacity(record_total_length / SnapshotRecord::LENGTH);
while cursor.has_remaining() {
let record = SnapshotRecord::try_new(&mut cursor)?;
records.push(record);
}
Ok(Self { header, records })
}