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

Function init_usv_index_for_collection

src/api_service.rs:284–304  ·  view source on GitHub ↗

creates an USV for a collection

(
    ctx: Arc<AppContext>,
    collection: &Collection,
    quantization_bits: u8,
    sample_threshold: usize,
)

Source from the content-addressed store, hash-verified

282
283/// creates an USV for a collection
284pub async fn init_usv_index_for_collection(
285 ctx: Arc<AppContext>,
286 collection: &Collection,
287 quantization_bits: u8,
288 sample_threshold: usize,
289) -> Result<Arc<USVIndex>, WaCustomError> {
290 let collection_path: Arc<Path> = collection.get_path();
291 let index_path = collection_path.join("usv_index");
292 fs::create_dir_all(&index_path).map_err(|e| WaCustomError::FsError(e.to_string()))?;
293
294 let index = Arc::new(USVIndex::new(
295 index_path.clone(),
296 quantization_bits,
297 sample_threshold,
298 )?);
299
300 ctx.ain_env
301 .collections_map
302 .insert_usv_index(collection, index.clone())?;
303 Ok(index)
304}

Callers 1

create_usv_indexFunction · 0.85

Calls 3

get_pathMethod · 0.80
cloneMethod · 0.80
insert_usv_indexMethod · 0.80

Tested by

no test coverage detected