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

Function init_key_value_index_for_collection

src/api_service.rs:267–281  ·  view source on GitHub ↗

creates an key value index for a collection

(
    ctx: Arc<AppContext>,
    collection: &Collection,
)

Source from the content-addressed store, hash-verified

265
266/// creates an key value index for a collection
267pub async fn init_key_value_index_for_collection(
268 ctx: Arc<AppContext>,
269 collection: &Collection,
270) -> Result<Arc<KeyValueIndex>, WaCustomError> {
271 let collection_path: Arc<Path> = collection.get_path();
272 let index_path = collection_path.join("key_value_index");
273 fs::create_dir_all(&index_path).map_err(|e| WaCustomError::FsError(e.to_string()))?;
274
275 let index = Arc::new(KeyValueIndex::new(index_path.clone())?);
276
277 ctx.ain_env
278 .collections_map
279 .insert_key_value_index(collection, index.clone())?;
280 Ok(index)
281}
282
283/// creates an USV for a collection
284pub async fn init_usv_index_for_collection(

Callers 1

create_key_value_indexFunction · 0.85

Calls 3

get_pathMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected