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

Method deserialize

src/models/tf_idf_index.rs:369–401  ·  view source on GitHub ↗
(root_path: PathBuf)

Source from the content-addressed store, hash-verified

367 }
368
369 pub fn deserialize(root_path: PathBuf) -> Result<Self, BufIoError> {
370 let dim_file = OpenOptions::new()
371 .read(true)
372 .write(true)
373 .create(true)
374 .truncate(false)
375 .open(root_path.join("index-tree.dim"))?;
376 let node_size = TFIDFIndexNode::get_serialized_size();
377 let dim_bufman = Arc::new(BufferManager::new(dim_file, node_size as usize * 1000)?);
378 let offset_counter = AtomicU32::new(dim_bufman.file_size() as u32);
379 let data_bufmans = Arc::new(BufferManagerFactory::new(
380 root_path.clone().into(),
381 |root, version: &VersionNumber| root.join(format!("{}.idat", **version)),
382 8192,
383 ));
384 let cache = TFIDFIndexCache::new(dim_bufman, data_bufmans, offset_counter);
385 let root = TFIDFIndexNode::deserialize(
386 &cache.dim_bufman,
387 &cache.data_bufmans,
388 FileOffset(4),
389 VersionNumber::from(u32::MAX), // not used
390 &cache,
391 )?;
392 let cursor = cache.dim_bufman.open_cursor()?;
393 let total_documents_count = AtomicU32::new(cache.dim_bufman.read_u32_with_cursor(cursor)?);
394 cache.dim_bufman.close_cursor(cursor)?;
395
396 Ok(Self {
397 root,
398 cache,
399 total_documents_count,
400 })
401 }
402}

Callers

nothing calls this directly

Calls 7

FileOffsetClass · 0.85
file_sizeMethod · 0.80
cloneMethod · 0.80
open_cursorMethod · 0.80
read_u32_with_cursorMethod · 0.80
close_cursorMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected