creates an inverted index for a collection
(
ctx: Arc<AppContext>,
collection: &Collection,
quantization_bits: u8,
sample_threshold: usize,
)
| 217 | |
| 218 | /// creates an inverted index for a collection |
| 219 | pub async fn init_inverted_index_for_collection( |
| 220 | ctx: Arc<AppContext>, |
| 221 | collection: &Collection, |
| 222 | quantization_bits: u8, |
| 223 | sample_threshold: usize, |
| 224 | ) -> Result<Arc<InvertedIndex>, WaCustomError> { |
| 225 | let collection_path: Arc<Path> = collection.get_path(); |
| 226 | let index_path = collection_path.join("sparse_inverted_index"); |
| 227 | fs::create_dir_all(&index_path).map_err(|e| WaCustomError::FsError(e.to_string()))?; |
| 228 | |
| 229 | let index = Arc::new(InvertedIndex::new( |
| 230 | index_path.clone(), |
| 231 | quantization_bits, |
| 232 | sample_threshold, |
| 233 | )?); |
| 234 | |
| 235 | ctx.ain_env |
| 236 | .collections_map |
| 237 | .insert_inverted_index(collection, index.clone())?; |
| 238 | Ok(index) |
| 239 | } |
| 240 | |
| 241 | /// creates an inverted index for a collection |
| 242 | pub async fn init_tf_idf_index_for_collection( |
no test coverage detected