Skip to content

Commit 89b81a5

Browse files
authored
update tantivy (#6006)
* update tantivy * allow deprecated * new TopDocs api
1 parent b6f853f commit 89b81a5

File tree

8 files changed

+50
-30
lines changed

8 files changed

+50
-30
lines changed

quickwit/Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quickwit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ quickwit-serve = { path = "quickwit-serve" }
346346
quickwit-storage = { path = "quickwit-storage" }
347347
quickwit-telemetry = { path = "quickwit-telemetry" }
348348

349-
tantivy = { git = "https://github.com/quickwit-oss/tantivy/", rev = "25d44fcec8", default-features = false, features = [
349+
tantivy = { git = "https://github.com/quickwit-oss/tantivy/", rev = "618e3bd", default-features = false, features = [
350350
"lz4-compression",
351351
"mmap",
352352
"quickwit",

quickwit/quickwit-doc-mapper/src/query_builder.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,20 +263,32 @@ fn extract_term_set_query_fields(
263263
Ok(visitor.term_dict_fields_to_warm_up)
264264
}
265265

266+
/// Converts a `prefix` term into the equivalent term range.
267+
///
268+
/// The resulting range is `[prefix, next_prefix)`, that is:
269+
/// - start bound: `Included(prefix)`
270+
/// - end bound: `Excluded(next lexicographic term after the prefix)`
271+
///
272+
/// "abc" -> start: "abc", end: "abd" (excluded)
273+
/// "ab\xFF" -> start: "ab\xFF", end: "ac" (excluded)
274+
/// "\xFF\xFF" -> start: "\xFF\xFF", end: Unbounded
266275
fn prefix_term_to_range(prefix: Term) -> (Bound<Term>, Bound<Term>) {
267-
let mut end_bound = prefix.serialized_term().to_vec();
268-
while !end_bound.is_empty() {
269-
let last_byte = end_bound.last_mut().unwrap();
276+
// Start from the given prefix and try to find the successor
277+
let mut end_bound = prefix.clone();
278+
let mut end_bound_value_bytes = prefix.serialized_value_bytes().to_vec();
279+
while !end_bound_value_bytes.is_empty() {
280+
let last_byte = end_bound_value_bytes.last_mut().unwrap();
270281
if *last_byte != u8::MAX {
271282
*last_byte += 1;
272-
return (
273-
Bound::Included(prefix),
274-
Bound::Excluded(Term::wrap(end_bound)),
275-
);
283+
// The last non-`u8::MAX` byte incremented
284+
// gives us the exclusive upper bound.
285+
end_bound.set_bytes(&end_bound_value_bytes);
286+
return (Bound::Included(prefix), Bound::Excluded(end_bound));
276287
}
277-
end_bound.pop();
288+
// pop u8::MAX byte and try next
289+
end_bound_value_bytes.pop();
278290
}
279-
// prefix is something like [255, 255, ..]
291+
// All bytes were `u8::MAX`: there is no successor, so the upper bound is unbounded.
280292
(Bound::Included(prefix), Bound::Unbounded)
281293
}
282294

quickwit/quickwit-indexing/src/actors/merge_executor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,8 @@ mod tests {
839839
let documents_left = searcher
840840
.search(
841841
&tantivy::query::AllQuery,
842-
&tantivy::collector::TopDocs::with_limit(result_docs.len() + 1),
842+
&tantivy::collector::TopDocs::with_limit(result_docs.len() + 1)
843+
.order_by_score(),
843844
)?
844845
.into_iter()
845846
.map(|(_, doc_address)| {

quickwit/quickwit-jaeger/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ impl SpanReaderPlugin for JaegerService {
562562
}
563563
}
564564

565+
#[allow(deprecated)]
565566
fn extract_term(term_bytes: &[u8]) -> String {
566567
tantivy::Term::wrap(term_bytes)
567568
.value()

quickwit/quickwit-search/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,17 @@ pub async fn single_node_search(
306306
#[cfg(any(test, feature = "testsuite"))]
307307
#[macro_export]
308308
macro_rules! encode_term_for_test {
309-
($field:expr, $value:expr) => {
310-
::tantivy::schema::Term::from_field_text(
311-
::tantivy::schema::Field::from_field_id($field),
312-
$value,
313-
)
314-
.serialized_term()
315-
.to_vec()
316-
};
309+
($field:expr, $value:expr) => {{
310+
#[allow(deprecated)]
311+
{
312+
::tantivy::schema::Term::from_field_text(
313+
::tantivy::schema::Field::from_field_id($field),
314+
$value,
315+
)
316+
.serialized_term()
317+
.to_vec()
318+
}
319+
}};
317320
($value:expr) => {
318321
encode_term_for_test!(0, $value)
319322
};

quickwit/quickwit-search/src/list_terms.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ pub fn jobs_to_leaf_requests(
206206

207207
/// Apply a leaf list terms on a single split.
208208
#[instrument(skip_all, fields(split_id = split.split_id))]
209+
#[allow(deprecated)]
209210
async fn leaf_list_terms_single_split(
210211
searcher_context: &SearcherContext,
211212
search_request: &ListTermsRequest,
@@ -308,6 +309,7 @@ fn term_from_data(field: Field, field_type: &FieldType, data: &[u8]) -> Term {
308309
term
309310
}
310311

312+
#[allow(deprecated)]
311313
fn term_to_data(field: Field, field_type: &FieldType, field_value: &[u8]) -> Vec<u8> {
312314
let mut term = Term::from_field_bool(field, false);
313315
term.clear_with_type(field_type.value_type());

quickwit/quickwit-search/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,11 +1646,12 @@ async fn test_single_node_range_queries() -> anyhow::Result<()> {
16461646
Ok(())
16471647
}
16481648

1649+
#[allow(deprecated)]
16491650
fn collect_str_terms(response: LeafListTermsResponse) -> Vec<String> {
16501651
response
16511652
.terms
16521653
.into_iter()
1653-
.map(|term| Term::wrap(term).value().as_str().unwrap().to_string())
1654+
.map(|term| Term::wrap(&term).value().as_str().unwrap().to_string())
16541655
.collect()
16551656
}
16561657

0 commit comments

Comments
 (0)