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

Function update_background_version

src/models/meta_persist.rs:36–58  ·  view source on GitHub ↗

updates the current version of a collection

(
    lmdb: &MetaDb,
    version: VersionNumber,
)

Source from the content-addressed store, hash-verified

34
35/// updates the current version of a collection
36pub fn update_background_version(
37 lmdb: &MetaDb,
38 version: VersionNumber,
39) -> Result<(), WaCustomError> {
40 let env = lmdb.env.clone();
41 let db = lmdb.db;
42
43 let mut txn = env
44 .begin_rw_txn()
45 .map_err(|e| WaCustomError::DatabaseError(format!("Failed to begin transaction: {}", e)))?;
46
47 let key = key!(m:background_version);
48 let bytes = version.to_le_bytes();
49
50 txn.put(db, &key, &bytes, WriteFlags::empty())
51 .map_err(|e| WaCustomError::DatabaseError(format!("Failed to put data: {}", e)))?;
52
53 txn.commit().map_err(|e| {
54 WaCustomError::DatabaseError(format!("Failed to commit transaction: {}", e))
55 })?;
56
57 Ok(())
58}
59
60pub fn store_values_range(lmdb: &MetaDb, range: (f32, f32)) -> lmdb::Result<()> {
61 let env = lmdb.env.clone();

Callers 4

create_collectionFunction · 0.85
index_explicit_txnMethod · 0.85
index_implicit_txnMethod · 0.85
pre_commitMethod · 0.85

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected