Skip to content

Commit

Permalink
Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketkedia committed Nov 13, 2024
1 parent ba06e2b commit 4a5f285
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
5 changes: 1 addition & 4 deletions rust/index/src/hnsw.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{Index, IndexConfig, IndexUuid, PersistentIndex};
use chroma_error::{ChromaError, ErrorCodes};
use chroma_types::{Metadata, MetadataValue, MetadataValueConversionError, Segment};
use chroma_types::MetadataValueConversionError;
use std::ffi::CString;
use std::ffi::{c_char, c_int};
use std::path::Path;
Expand Down Expand Up @@ -400,12 +400,9 @@ pub mod test {
use super::*;
use crate::utils;
use chroma_distance::DistanceFunction;
use chroma_types::CollectionUuid;
use chroma_types::SegmentUuid;
use rand::seq::IteratorRandom;
use rayon::prelude::*;
use rayon::ThreadPoolBuilder;
use std::collections::HashMap;
use tempfile::tempdir;
use uuid::Uuid;

Expand Down
14 changes: 4 additions & 10 deletions rust/index/src/hnsw_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use chroma_distance::DistanceFunction;
use chroma_error::ChromaError;
use chroma_error::ErrorCodes;
use chroma_storage::Storage;
use chroma_types::{CollectionUuid, Segment};
use chroma_types::CollectionUuid;
use parking_lot::RwLock;
use std::fmt::Debug;
use std::path::Path;
Expand Down Expand Up @@ -211,9 +211,7 @@ impl HnswIndexProvider {
let index = HnswIndexRef {
inner: Arc::new(RwLock::new(index)),
};
self.cache
.insert(collection_id.clone(), index.clone())
.await;
self.cache.insert(*collection_id, index.clone()).await;
Ok(index)
}
}
Expand Down Expand Up @@ -395,15 +393,13 @@ impl HnswIndexProvider {
.map_err(|e| Box::new(HnswIndexProviderCreateError::IndexInitError(e)))?;

let _guard = self.write_mutex.lock().await;
match self.get(&id, &collection_id).await {
match self.get(&id, collection_id).await {
Some(index) => Ok(index.clone()),
None => {
let index = HnswIndexRef {
inner: Arc::new(RwLock::new(index)),
};
self.cache
.insert(collection_id.clone(), index.clone())
.await;
self.cache.insert(*collection_id, index.clone()).await;
Ok(index)
}
}
Expand Down Expand Up @@ -611,8 +607,6 @@ mod tests {
use super::*;
use chroma_cache::new_non_persistent_cache_for_test;
use chroma_storage::local::LocalStorage;
use chroma_types::{SegmentType, SegmentUuid};
use std::collections::HashMap;

#[tokio::test]
async fn test_fork() {
Expand Down
1 change: 0 additions & 1 deletion rust/index/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chroma_distance::{DistanceFunction, DistanceFunctionError};
use chroma_error::{ChromaError, ErrorCodes};
use chroma_types::{MetadataValue, Segment};
use thiserror::Error;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion rust/types/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ where
};
match res {
Ok(value) => Ok(value),
Err(e) => Err(Box::new(MetadataValueConversionError::InvalidValue)),
Err(_) => Err(Box::new(MetadataValueConversionError::InvalidValue)),
}
}

Expand Down
5 changes: 1 addition & 4 deletions rust/worker/src/segment/distributed_hnsw_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use chroma_index::hnsw_provider::{
HnswIndexParams, HnswIndexProvider, HnswIndexProviderCreateError, HnswIndexProviderForkError,
HnswIndexProviderOpenError, HnswIndexRef,
};
use chroma_index::{
HnswIndexConfig, HnswIndexFromSegmentError, Index, IndexConfig, IndexConfigFromSegmentError,
IndexUuid,
};
use chroma_index::{Index, IndexUuid};
use chroma_index::{DEFAULT_HNSW_EF_CONSTRUCTION, DEFAULT_HNSW_EF_SEARCH, DEFAULT_HNSW_M};
use chroma_types::SegmentUuid;
use chroma_types::{get_metadata_value_as, MaterializedLogOperation, MetadataValue, Segment};
Expand Down

0 comments on commit 4a5f285

Please sign in to comment.