MCPcopy Create free account
hub / github.com/cosdata/cosdata / serialize

Method serialize

src/models/serializer/usv/atomic_array.rs:14–47  ·  view source on GitHub ↗
(
        &self,
        dim_bufman: &BufferManager,
        data_bufmans: &BufferManagerFactory<VersionNumber>,
        quantization_bits: u8,
        offset_counter: &AtomicU32,
        cursor: u64,

Source from the content-addressed store, hash-verified

12
13impl<T: USVIndexSerialize, const N: usize> USVIndexSerialize for AtomicArray<T, N> {
14 fn serialize(
15 &self,
16 dim_bufman: &BufferManager,
17 data_bufmans: &BufferManagerFactory<VersionNumber>,
18 quantization_bits: u8,
19 offset_counter: &AtomicU32,
20 cursor: u64,
21 ) -> Result<u32, BufIoError> {
22 let start = dim_bufman.cursor_position(cursor)?;
23 dim_bufman.update_with_cursor(cursor, &vec![u8::MAX; 4 * N])?;
24 dim_bufman.seek_with_cursor(cursor, start)?;
25
26 for i in 0..N {
27 let Some(item_ptr) = self.get(i) else {
28 dim_bufman.update_with_cursor(cursor, &[u8::MAX; 4])?;
29 continue;
30 };
31
32 let item = unsafe { &*item_ptr };
33 let current_pos = dim_bufman.cursor_position(cursor)?;
34 let item_offset = item.serialize(
35 dim_bufman,
36 data_bufmans,
37 quantization_bits,
38 offset_counter,
39 cursor,
40 )?;
41 dim_bufman.seek_with_cursor(cursor, current_pos)?;
42
43 dim_bufman.update_u32_with_cursor(cursor, item_offset)?;
44 }
45
46 Ok(start as u32)
47 }
48
49 fn deserialize(
50 dim_bufman: &BufferManager,

Callers

nothing calls this directly

Calls 5

cursor_positionMethod · 0.80
update_with_cursorMethod · 0.80
seek_with_cursorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected