Skip to content

Commit bd4398d

Browse files
authored
[ENH] Optimize FTS (#5592)
## Description of changes _Summarize the changes made by this PR._ - Improvements & Bug fixes - Replace usage of `get_range` with `get_prefix` - New functionality - N/A ## Test plan _How are these changes tested?_ - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan _Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?_ ## Observability plan _What is the plan to instrument and monitor this change?_ ## Documentation Changes _Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the_ [_docs section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_
1 parent ff77a60 commit bd4398d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

rust/index/src/fulltext/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'me> FullTextIndexReader<'me> {
325325
.then(|token| async move {
326326
let positional_posting_list = self
327327
.posting_lists_blockfile_reader
328-
.get_range(token.text.as_str()..=token.text.as_str(), ..)
328+
.get_prefix(token.text.as_str())
329329
.await?
330330
.collect::<Vec<_>>();
331331
Ok::<_, FullTextIndexError>(positional_posting_list)
@@ -346,7 +346,7 @@ impl<'me> FullTextIndexReader<'me> {
346346
.enumerate()
347347
.map(|(i, posting_list)| {
348348
if pointers[i] < posting_list.len() {
349-
Some(posting_list[pointers[i]].1)
349+
Some(posting_list[pointers[i]].0)
350350
} else {
351351
None
352352
}
@@ -372,15 +372,15 @@ impl<'me> FullTextIndexReader<'me> {
372372

373373
// Seed with the positions of the first token.
374374
let mut adjusted = posting_lists[0][pointers[0]]
375-
.2
375+
.1
376376
.iter()
377377
.copied()
378378
.collect::<HashSet<_>>();
379379

380380
for i in 1..num_tokens {
381381
let byte_delta_from_first_token =
382382
tokens[i].offset_from as u32 - tokens[0].offset_from as u32;
383-
let positions = &posting_lists[i][pointers[i]].2;
383+
let positions = &posting_lists[i][pointers[i]].1;
384384

385385
let shifted = positions
386386
.iter()
@@ -424,10 +424,10 @@ impl<'me> FullTextIndexReader<'me> {
424424
) -> Result<Vec<(u32, Vec<u32>)>, FullTextIndexError> {
425425
let positional_posting_list = self
426426
.posting_lists_blockfile_reader
427-
.get_range(token..=token, ..)
427+
.get_prefix(token)
428428
.await?;
429429
let mut results = vec![];
430-
for (_, doc_id, positions) in positional_posting_list {
430+
for (doc_id, positions) in positional_posting_list {
431431
results.push((doc_id, positions.to_vec()));
432432
}
433433
Ok(results)

0 commit comments

Comments
 (0)