Skip to content

Commit

Permalink
[CLN] Clean up unused imports (chroma-core#1959)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - ...
 - New functionality
- This PR cleans up unused import and addresses some warnings by cargo
build and cargo test.
	 - Unused variables are not touched. 

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Apr 2, 2024
1 parent d3f61b1 commit fdfda56
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 181 deletions.
4 changes: 0 additions & 4 deletions rust/worker/src/assignment/assignment_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ impl RendezvousHashingAssignmentPolicy {
members: vec![],
};
}

pub(crate) fn set_members(&mut self, members: Vec<String>) {
self.members = members;
}
}

#[async_trait]
Expand Down
3 changes: 1 addition & 2 deletions rust/worker/src/blockstore/arrow_blockfile/block/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::blockstore::types::{BlockfileKey, Key, KeyType, Value, ValueType};
use crate::errors::{ChromaError, ErrorCodes};
use arrow::array::{
BinaryArray, BinaryBuilder, BooleanArray, BooleanBuilder, Float32Array, Float32Builder,
GenericByteBuilder, UInt32Array, UInt32Builder,
BinaryArray, BinaryBuilder, BooleanArray, BooleanBuilder, Float32Array, Float32Builder, UInt32Array, UInt32Builder,
};
use arrow::{
array::{Array, Int32Array, Int32Builder, ListArray, ListBuilder, StringArray, StringBuilder},
Expand Down
2 changes: 1 addition & 1 deletion rust/worker/src/blockstore/arrow_blockfile/sparse_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod tests {

#[test]
fn test_sparse_index() {
let mut block_id_1 = uuid::Uuid::new_v4();
let block_id_1 = uuid::Uuid::new_v4();
let mut sparse_index = SparseIndex::new(block_id_1);
let mut blockfile_key =
BlockfileKey::new("prefix".to_string(), Key::String("a".to_string()));
Expand Down
7 changes: 4 additions & 3 deletions rust/worker/src/compactor/compaction_manager.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::scheduler::Scheduler;
use super::scheduler_policy::LasCompactionTimeSchedulerPolicy;
use crate::assignment::assignment_policy::AssignmentPolicy;
use crate::compactor::types::CompactionJob;
use crate::compactor::types::ScheduleMessage;
use crate::config::CompactionServiceConfig;
Expand Down Expand Up @@ -230,16 +231,16 @@ impl Debug for CompactionManager {
impl Handler<ScheduleMessage> for CompactionManager {
async fn handle(
&mut self,
message: ScheduleMessage,
ctx: &ComponentContext<CompactionManager>,
_message: ScheduleMessage,
_ctx: &ComponentContext<CompactionManager>,
) {
self.compact_batch().await;
}
}

#[async_trait]
impl Handler<Memberlist> for CompactionManager {
async fn handle(&mut self, message: Memberlist, ctx: &ComponentContext<CompactionManager>) {
async fn handle(&mut self, message: Memberlist, _ctx: &ComponentContext<CompactionManager>) {
self.scheduler.set_memberlist(message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/worker/src/compactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ mod scheduler_policy;
mod types;

pub(crate) use compaction_manager::*;
pub use types::*;
pub(crate) use types::*;
2 changes: 1 addition & 1 deletion rust/worker/src/distance/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod types;

pub use types::*;
pub(crate) use types::*;
6 changes: 2 additions & 4 deletions rust/worker/src/execution/data/data_chunk.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::{LogRecord, OperationRecord};
use crate::types::LogRecord;
use std::sync::Arc;

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -110,12 +110,10 @@ mod tests {
use super::*;
use crate::types::LogRecord;
use crate::types::Operation;
use std::str::FromStr;
use uuid::Uuid;
use crate::types::OperationRecord;

#[test]
fn test_data_chunk() {
let collection_uuid_1 = Uuid::from_str("00000000-0000-0000-0000-000000000001").unwrap();
let data = vec![
LogRecord {
log_offset: 1,
Expand Down
8 changes: 4 additions & 4 deletions rust/worker/src/execution/dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{operator::TaskMessage, worker_thread::WorkerThread};
use crate::execution::config::DispatcherConfig;
use crate::{
config::{Configurable, QueryServiceConfig},
config::Configurable,
errors::ChromaError,
system::{Component, ComponentContext, Handler, Receiver, System},
};
Expand Down Expand Up @@ -249,7 +249,7 @@ mod tests {
impl Handler<Result<String, ()>> for MockDispatchUser {
async fn handle(
&mut self,
message: Result<String, ()>,
_message: Result<String, ()>,
ctx: &ComponentContext<MockDispatchUser>,
) {
self.counter.fetch_add(1, Ordering::SeqCst);
Expand All @@ -263,15 +263,15 @@ mod tests {

#[async_trait]
impl Handler<()> for MockDispatchUser {
async fn handle(&mut self, message: (), ctx: &ComponentContext<MockDispatchUser>) {
async fn handle(&mut self, _message: (), ctx: &ComponentContext<MockDispatchUser>) {
let task = wrap(Box::new(MockOperator {}), 42.0, ctx.sender.as_receiver());
let res = self.dispatcher.send(task).await;
}
}

#[tokio::test]
async fn test_dispatcher() {
let mut system = System::new();
let system = System::new();
let dispatcher = Dispatcher::new(THREAD_COUNT, 1000, 1000);
let dispatcher_handle = system.start_component(dispatcher);
let counter = Arc::new(AtomicUsize::new(0));
Expand Down
1 change: 0 additions & 1 deletion rust/worker/src/execution/operators/brute_force_knn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ mod tests {
use crate::types::LogRecord;
use crate::types::Operation;
use crate::types::OperationRecord;
use uuid::Uuid;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion rust/worker/src/execution/orchestration/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Handler<PartitionResult> for CompactOrchestrator {
async fn handle(
&mut self,
message: PartitionResult,
ctx: &crate::system::ComponentContext<CompactOrchestrator>,
_ctx: &crate::system::ComponentContext<CompactOrchestrator>,
) {
let records = match message {
Ok(result) => result.records,
Expand Down
2 changes: 1 addition & 1 deletion rust/worker/src/execution/orchestration/hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Handler<BruteForceKnnOperatorResult> for HnswQueryOrchestrator {
async fn handle(
&mut self,
message: BruteForceKnnOperatorResult,
ctx: &crate::system::ComponentContext<HnswQueryOrchestrator>,
_ctx: &crate::system::ComponentContext<HnswQueryOrchestrator>,
) {
// This is an example of the final state transition and result
let result_channel = match self.result_channel.take() {
Expand Down
2 changes: 0 additions & 2 deletions rust/worker/src/index/fulltext/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
pub mod tokenizer;
mod types;

pub use types::*;
18 changes: 6 additions & 12 deletions rust/worker/src/index/fulltext/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
use crate::errors::{ChromaError, ErrorCodes};

use tantivy::tokenizer::{NgramTokenizer, Token, Tokenizer, TokenStream};
use tantivy::tokenizer::{NgramTokenizer, Token, TokenStream, Tokenizer};

pub(crate) trait ChromaTokenStream {
fn process(&mut self, sink: &mut dyn FnMut(&Token));
fn get_tokens(&self) -> &Vec<Token>;
}

pub(crate) struct TantivyChromaTokenStream {
tokens: Vec<Token>
tokens: Vec<Token>,
}

impl TantivyChromaTokenStream {
pub fn new(tokens: Vec<Token>) -> Self {
TantivyChromaTokenStream {
tokens,
}
TantivyChromaTokenStream { tokens }
}
}

Expand All @@ -36,14 +32,12 @@ pub(crate) trait ChromaTokenizer {
}

pub(crate) struct TantivyChromaTokenizer {
tokenizer: Box<NgramTokenizer>
tokenizer: Box<NgramTokenizer>,
}

impl TantivyChromaTokenizer {
pub fn new(tokenizer: Box<NgramTokenizer>) -> Self {
TantivyChromaTokenizer {
tokenizer,
}
TantivyChromaTokenizer { tokenizer }
}
}

Expand Down Expand Up @@ -85,4 +79,4 @@ mod test {
assert_eq!(tokens[0].text, "h");
assert_eq!(tokens[1].text, "e");
}
}
}
4 changes: 2 additions & 2 deletions rust/worker/src/index/fulltext/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl FullTextIndex for BlockfileFullTextIndex {
.entry(token.text.to_string())
.and_modify(|e| *e += 1)
.or_insert(1);
let mut builder = self
let builder = self
.uncommitted
.entry(token.text.to_string())
.or_insert(PositionalPostingListBuilder::new());
Expand Down Expand Up @@ -219,7 +219,7 @@ impl FullTextIndex for BlockfileFullTextIndex {
mod tests {
use super::*;
use crate::blockstore::provider::{BlockfileProvider, HashMapBlockfileProvider};
use crate::blockstore::{HashMapBlockfile, KeyType, ValueType};
use crate::blockstore::{KeyType, ValueType};
use crate::index::fulltext::tokenizer::TantivyChromaTokenizer;
use tantivy::tokenizer::NgramTokenizer;

Expand Down
6 changes: 3 additions & 3 deletions rust/worker/src/index/hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ pub mod test {
let tmp_dir = tempdir().unwrap();
let persist_path = tmp_dir.path().to_str().unwrap().to_string();
let distance_function = DistanceFunction::Euclidean;
let mut index = HnswIndex::init(
let index = HnswIndex::init(
&IndexConfig {
dimensionality: d as i32,
distance_function: distance_function,
Expand Down Expand Up @@ -382,9 +382,9 @@ pub mod test {

let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
let mut datas = Vec::new();
for i in 0..n {
for _ in 0..n {
let mut data: Vec<f32> = Vec::new();
for i in 0..960 {
for _ in 0..960 {
data.push(rng.gen());
}
datas.push(data);
Expand Down
Loading

0 comments on commit fdfda56

Please sign in to comment.