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

Method deserialize_raw

src/models/serializer/hnsw/node.rs:205–258  ·  view source on GitHub ↗
(
        bufman: &BufferManager,
        latest_version_links_bufman: &FilelessBufferManager,
        cursor: u64,
        latest_version_links_cursor: u64,
        FileOffset(offset): FileOffset,
  

Source from the content-addressed store, hash-verified

203 );
204
205 fn deserialize_raw(
206 bufman: &BufferManager,
207 latest_version_links_bufman: &FilelessBufferManager,
208 cursor: u64,
209 latest_version_links_cursor: u64,
210 FileOffset(offset): FileOffset,
211 file_id: IndexFileId,
212 cache: &HNSWIndexCache,
213 ) -> Result<Self::Raw, BufIoError> {
214 bufman.seek_with_cursor(cursor, offset as u64)?;
215 // Read basic fields
216 let hnsw_level = HNSWLevel(bufman.read_u8_with_cursor(cursor)?);
217 let version = VersionNumber::from(bufman.read_u32_with_cursor(cursor)?);
218 // Read prop_value
219 let prop_offset = FileOffset(bufman.read_u32_with_cursor(cursor)?);
220 let prop_length = BytesToRead(bufman.read_u32_with_cursor(cursor)?);
221 let prop = cache.get_prop(prop_offset, prop_length)?;
222
223 // Read prop_metadata
224 let metadata_offset = bufman.read_u32_with_cursor(cursor)?;
225 let metadata_length = bufman.read_u32_with_cursor(cursor)?;
226 let metadata = if metadata_offset != u32::MAX {
227 Some(
228 cache
229 .get_prop_metadata(FileOffset(metadata_offset), BytesToRead(metadata_length))?,
230 )
231 } else {
232 None
233 };
234
235 let parent_offset = FileOffset(bufman.read_u32_with_cursor(cursor)?);
236 let child_offset = FileOffset(bufman.read_u32_with_cursor(cursor)?);
237
238 let neighbors = Neighbors::deserialize_raw(
239 bufman,
240 latest_version_links_bufman,
241 cursor,
242 latest_version_links_cursor,
243 // @NOTE: 29 = 21 (properties) + 4 (parent) + 4 (child)
244 FileOffset(offset + 29),
245 file_id,
246 cache,
247 )?;
248
249 Ok((
250 hnsw_level,
251 version,
252 prop,
253 metadata,
254 neighbors,
255 parent_offset,
256 child_offset,
257 ))
258 }
259}

Callers

nothing calls this directly

Calls 8

HNSWLevelClass · 0.85
FileOffsetClass · 0.85
BytesToReadClass · 0.85
seek_with_cursorMethod · 0.80
read_u8_with_cursorMethod · 0.80
read_u32_with_cursorMethod · 0.80
get_propMethod · 0.80
get_prop_metadataMethod · 0.80

Tested by

no test coverage detected