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

Function tests_basic_usage

src/models/tree_map.rs:686–716  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

684
685 #[test]
686 fn tests_basic_usage() {
687 let tempdir = tempdir().unwrap();
688 let file = OpenOptions::new()
689 .read(true)
690 .write(true)
691 .truncate(false)
692 .create(true)
693 .open(tempdir.as_ref().join("tree_map.dim"))
694 .unwrap();
695 let dim_bufman = BufferManager::new(file, 8192).unwrap();
696 let data_bufmans = BufferManagerFactory::new(
697 tempdir.as_ref().into(),
698 |root, version: &VersionNumber| root.join(format!("tree_map.{}.data", **version)),
699 8192,
700 );
701 let map: TreeMap<u64, u64> = TreeMap::new(dim_bufman, data_bufmans);
702 map.insert(0.into(), &65536, 0);
703 map.insert(0.into(), &0, 23);
704 assert_eq!(map.get_latest(&0), Some(&23));
705 map.insert(1.into(), &0, 29);
706 assert_eq!(map.get_latest(&0), Some(&29));
707 assert_eq!(
708 map.get_versioned(&0).as_deref(),
709 Some(&VersionedItem {
710 version: 0.into(),
711 serialized_at: RwLock::new(None),
712 value: Some(23),
713 next: Some(Box::new(VersionedItem::new(1.into(), 29)))
714 })
715 );
716 }
717}

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected