Skip to content

Commit e962bf5

Browse files
committed
Rename to search
1 parent 2fcfdb1 commit e962bf5

File tree

10 files changed

+105
-110
lines changed

10 files changed

+105
-110
lines changed

idl/chromadb/proto/query_executor.proto

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,26 @@ message ProjectOperator {
154154
repeated string fields = 1;
155155
}
156156

157-
message RetrievePayload {
157+
message SearchPayload {
158158
FilterOperator filter = 1;
159159
ScoreOperator score = 2;
160160
LimitOperator limit = 3;
161161
ProjectOperator project = 4;
162162
}
163163

164-
message RetrievePlan {
164+
message SearchPlan {
165165
ScanOperator scan = 1;
166-
repeated RetrievePayload payloads = 2;
166+
repeated SearchPayload payloads = 2;
167167
}
168168

169-
message RetrieveResult {
169+
message SearchResult {
170170
repeated string results = 1;
171171
}
172172

173173
service QueryExecutor {
174174
rpc Count(CountPlan) returns (CountResult) {}
175175
rpc Get(GetPlan) returns (GetResult) {}
176176
rpc KNN(KNNPlan) returns (KNNBatchResult) {}
177-
rpc Retrieve(RetrievePlan) returns (RetrieveResult) {}
177+
rpc Search(SearchPlan) returns (SearchResult) {}
178178
}
179179

rust/frontend/src/executor/distributed.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use chroma_system::System;
1515
use chroma_types::chroma_proto::query_executor_client::QueryExecutorClient;
1616
use chroma_types::SegmentType;
1717
use chroma_types::{
18-
operator::{CountResult, GetResult, KnnBatchResult, RetrieveResult},
19-
plan::{Count, Get, Knn, Retrieve},
18+
operator::{CountResult, GetResult, KnnBatchResult, SearchResult},
19+
plan::{Count, Get, Knn, Search},
2020
ExecutorError,
2121
};
2222

@@ -210,7 +210,7 @@ impl DistributedExecutor {
210210
Ok(res.into_inner().try_into()?)
211211
}
212212

213-
pub async fn retrieve(&mut self, plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
213+
pub async fn search(&mut self, plan: Search) -> Result<SearchResult, ExecutorError> {
214214
// Get the collection ID from the plan
215215
let collection_id = &plan
216216
.scan
@@ -225,7 +225,7 @@ impl DistributedExecutor {
225225
.map_err(|e| ExecutorError::Internal(e.boxed()))?;
226226

227227
// Convert plan to proto
228-
let request: chroma_types::chroma_proto::RetrievePlan = plan.try_into()?;
228+
let request: chroma_types::chroma_proto::SearchPlan = plan.try_into()?;
229229

230230
let attempt_count = std::sync::Arc::new(std::sync::atomic::AtomicU32::new(0));
231231
let config = self.client_selection_config.clone();
@@ -236,7 +236,7 @@ impl DistributedExecutor {
236236
attempt_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
237237
let is_retry = current_attempt > 0;
238238
choose_query_client_weighted(&clients, &config, is_retry)?
239-
.retrieve(Request::new(request.clone()))
239+
.search(Request::new(request.clone()))
240240
.await
241241
})
242242
.retry(self.backoff)

rust/frontend/src/executor/local.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use chroma_system::ComponentHandle;
1212
use chroma_types::{
1313
operator::{
1414
CountResult, Filter, GetResult, KnnBatchResult, KnnProjectionOutput, KnnProjectionRecord,
15-
Projection, ProjectionRecord, RecordDistance, RetrieveResult,
15+
Projection, ProjectionRecord, RecordDistance, SearchResult,
1616
},
17-
plan::{Count, Get, Knn, Retrieve},
17+
plan::{Count, Get, Knn, Search},
1818
CollectionAndSegments, CollectionUuid, ExecutorError, HnswSpace, SegmentType,
1919
};
2020
use std::{
@@ -306,9 +306,9 @@ impl LocalExecutor {
306306
})
307307
}
308308

309-
pub async fn retrieve(&mut self, _plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
309+
pub async fn search(&mut self, _plan: Search) -> Result<SearchResult, ExecutorError> {
310310
Err(ExecutorError::NotImplemented(
311-
"Retrieve operation is not implemented for local executor".to_string(),
311+
"Search operation is not implemented for local executor".to_string(),
312312
))
313313
}
314314

rust/frontend/src/executor/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use chroma_types::{
2-
operator::{CountResult, GetResult, KnnBatchResult, RetrieveResult},
3-
plan::{Count, Get, Knn, Retrieve},
2+
operator::{CountResult, GetResult, KnnBatchResult, SearchResult},
3+
plan::{Count, Get, Knn, Search},
44
ExecutorError, SegmentType,
55
};
66
use distributed::DistributedExecutor;
@@ -38,12 +38,10 @@ impl Executor {
3838
Executor::Local(local_executor) => local_executor.knn(plan).await,
3939
}
4040
}
41-
pub async fn retrieve(&mut self, plan: Retrieve) -> Result<RetrieveResult, ExecutorError> {
41+
pub async fn search(&mut self, plan: Search) -> Result<SearchResult, ExecutorError> {
4242
match self {
43-
Executor::Distributed(distributed_executor) => {
44-
distributed_executor.retrieve(plan).await
45-
}
46-
Executor::Local(local_executor) => local_executor.retrieve(plan).await,
43+
Executor::Distributed(distributed_executor) => distributed_executor.search(plan).await,
44+
Executor::Local(local_executor) => local_executor.search(plan).await,
4745
}
4846
}
4947
pub async fn is_ready(&self) -> bool {

rust/frontend/src/impls/service_based_frontend.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use chroma_sysdb::{GetCollectionsOptions, SysDb};
1818
use chroma_system::System;
1919
use chroma_types::{
2020
operator::{Filter, KnnBatch, KnnProjection, Limit, Projection, Scan},
21-
plan::{Count, Get, Knn, Retrieve},
21+
plan::{Count, Get, Knn, Search},
2222
AddCollectionRecordsError, AddCollectionRecordsRequest, AddCollectionRecordsResponse,
2323
Collection, CollectionUuid, CountCollectionsError, CountCollectionsRequest,
2424
CountCollectionsResponse, CountRequest, CountResponse, CreateCollectionError,
@@ -34,7 +34,7 @@ use chroma_types::{
3434
HeartbeatError, HeartbeatResponse, Include, KnnIndex, ListCollectionsRequest,
3535
ListCollectionsResponse, ListDatabasesError, ListDatabasesRequest, ListDatabasesResponse,
3636
Operation, OperationRecord, QueryError, QueryRequest, QueryResponse, ResetError, ResetResponse,
37-
RetrieveRequest, RetrieveResponse, Segment, SegmentScope, SegmentType, SegmentUuid,
37+
SearchRequest, SearchResponse, Segment, SegmentScope, SegmentType, SegmentUuid,
3838
UpdateCollectionError, UpdateCollectionRecordsError, UpdateCollectionRecordsRequest,
3939
UpdateCollectionRecordsResponse, UpdateCollectionRequest, UpdateCollectionResponse,
4040
UpdateTenantError, UpdateTenantRequest, UpdateTenantResponse, UpsertCollectionRecordsError,
@@ -63,7 +63,7 @@ struct Metrics {
6363
add_retries_counter: Counter<u64>,
6464
update_retries_counter: Counter<u64>,
6565
upsert_retries_counter: Counter<u64>,
66-
retrieve_retries_counter: Counter<u64>,
66+
search_retries_counter: Counter<u64>,
6767
}
6868

6969
#[derive(Clone, Debug)]
@@ -103,7 +103,7 @@ impl ServiceBasedFrontend {
103103
let add_retries_counter = meter.u64_counter("add_retries").build();
104104
let update_retries_counter = meter.u64_counter("update_retries").build();
105105
let upsert_retries_counter = meter.u64_counter("upsert_retries").build();
106-
let retrieve_retries_counter = meter.u64_counter("retrieve_retries").build();
106+
let search_retries_counter = meter.u64_counter("search_retries").build();
107107
let metrics = Arc::new(Metrics {
108108
fork_retries_counter,
109109
delete_retries_counter,
@@ -113,7 +113,7 @@ impl ServiceBasedFrontend {
113113
add_retries_counter,
114114
update_retries_counter,
115115
upsert_retries_counter,
116-
retrieve_retries_counter,
116+
search_retries_counter,
117117
});
118118
// factor: 2.0,
119119
// min_delay_ms: 100,
@@ -1581,47 +1581,44 @@ impl ServiceBasedFrontend {
15811581
res
15821582
}
15831583

1584-
pub async fn retryable_retrieve(
1584+
pub async fn retryable_search(
15851585
&mut self,
1586-
request: RetrieveRequest,
1587-
) -> Result<RetrieveResponse, QueryError> {
1586+
request: SearchRequest,
1587+
) -> Result<SearchResponse, QueryError> {
15881588
// Get collection and segments once for all queries
15891589
let collection_and_segments = self
15901590
.collections_with_segments_provider
15911591
.get_collection_with_segments(request.collection_id)
15921592
.await
15931593
.map_err(|err| QueryError::Other(Box::new(err) as Box<dyn ChromaError>))?;
15941594

1595-
// Create a single Retrieve plan with one scan and the payloads from the request
1596-
let retrieve_plan = Retrieve {
1595+
// Create a single Search plan with one scan and the payloads from the request
1596+
let search_plan = Search {
15971597
scan: Scan {
15981598
collection_and_segments,
15991599
},
1600-
payloads: request.retrievals,
1600+
payloads: request.searches,
16011601
};
16021602

1603-
// Execute the single retrieve plan using the executor
1604-
let result = self.executor.retrieve(retrieve_plan).await?;
1603+
// Execute the single search plan using the executor
1604+
let result = self.executor.search(search_plan).await?;
16051605

1606-
Ok(RetrieveResponse {
1606+
Ok(SearchResponse {
16071607
results: result.results,
16081608
})
16091609
}
16101610

1611-
pub async fn retrieve(
1612-
&mut self,
1613-
request: RetrieveRequest,
1614-
) -> Result<RetrieveResponse, QueryError> {
1611+
pub async fn search(&mut self, request: SearchRequest) -> Result<SearchResponse, QueryError> {
16151612
let retries = Arc::new(AtomicUsize::new(0));
1616-
let retrieve_to_retry = || {
1613+
let search_to_retry = || {
16171614
let mut self_clone = self.clone();
16181615
let request_clone = request.clone();
16191616
let cache_clone = self
16201617
.collections_with_segments_provider
16211618
.collections_with_segments_cache
16221619
.clone();
16231620
async move {
1624-
let res = self_clone.retryable_retrieve(request_clone).await;
1621+
let res = self_clone.retryable_search(request_clone).await;
16251622
match res {
16261623
Ok(res) => Ok(res),
16271624
Err(e) => {
@@ -1637,22 +1634,22 @@ impl ServiceBasedFrontend {
16371634
}
16381635
}
16391636
};
1640-
let res = retrieve_to_retry
1637+
let res = search_to_retry
16411638
.retry(self.collections_with_segments_provider.get_retry_backoff())
16421639
// NOTE: Transport level errors will manifest as unknown errors, and they should also be retried
16431640
.when(|e| matches!(e.code(), ErrorCodes::NotFound | ErrorCodes::Unknown))
16441641
.notify(|_, _| {
16451642
let retried = retries.fetch_add(1, Ordering::Relaxed);
16461643
if retried > 0 {
16471644
tracing::info!(
1648-
"Retrying retrieve() request for collection {}",
1645+
"Retrying search() request for collection {}",
16491646
request.collection_id
16501647
);
16511648
}
16521649
})
16531650
.await;
16541651
self.metrics
1655-
.retrieve_retries_counter
1652+
.search_retries_counter
16561653
.add(retries.load(Ordering::Relaxed) as u64, &[]);
16571654
res
16581655
}

0 commit comments

Comments
 (0)