From 392472f4bb9f1f16aa27e6b9feef249f2d1f31f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Thu, 16 Jun 2022 06:19:33 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Tamo --- filter-parser/src/lib.rs | 6 +++--- infos/src/main.rs | 2 +- milli/src/index.rs | 3 +-- .../index_documents/extract/extract_facet_exists_docids.rs | 2 -- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/filter-parser/src/lib.rs b/filter-parser/src/lib.rs index e40519e87..5cce5f4c3 100644 --- a/filter-parser/src/lib.rs +++ b/filter-parser/src/lib.rs @@ -170,7 +170,7 @@ fn ws<'a, O>(inner: impl FnMut(Span<'a>) -> IResult) -> impl FnMut(Span<'a>) delimited(multispace0, inner, multispace0) } -/// or = and ("OR" and) +/// or = and ("OR" and)* fn parse_or(input: Span) -> IResult { let (input, lhs) = parse_and(input)?; // if we found a `OR` then we MUST find something next @@ -200,7 +200,7 @@ fn parse_not(input: Span) -> IResult { alt((map(preceded(tag("NOT"), cut(parse_not)), |e| e.negate()), parse_primary))(input) } -/// geoRadius = WS* "_geoRadius(float "," float "," float) +/// geoRadius = WS* "_geoRadius(float WS* "," WS* float WS* "," WS* float) /// If we parse `_geoRadius` we MUST parse the rest of the expression. fn parse_geo_radius(input: Span) -> IResult { // we want to forbid space BEFORE the _geoRadius but not after @@ -224,7 +224,7 @@ fn parse_geo_radius(input: Span) -> IResult { Ok((input, res)) } -/// geoPoint = WS* "_geoPoint(float "," float "," float) +/// geoPoint = WS* "_geoPoint(float WS* "," WS* float WS* "," WS* float) fn parse_geo_point(input: Span) -> IResult { // we want to forbid space BEFORE the _geoPoint but not after tuple(( diff --git a/infos/src/main.rs b/infos/src/main.rs index 89aec6182..feec17557 100644 --- a/infos/src/main.rs +++ b/infos/src/main.rs @@ -551,7 +551,7 @@ fn biggest_value_sizes(index: &Index, rtxn: &heed::RoTxn, limit: usize) -> anyho let db = facet_id_exists_docids.remap_data_type::(); for result in facet_values_iter(rtxn, db, facet_id)? { let (_fid, value) = result?; - let key = format!("{}", facet_name); + let key = facet_name.to_string(); heap.push(Reverse((value.len(), key, facet_id_exists_docids_name))); if heap.len() > limit { heap.pop(); diff --git a/milli/src/index.rs b/milli/src/index.rs index 816112178..b0897271e 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -156,8 +156,7 @@ impl Index { let word_prefix_position_docids = env.create_database(Some(WORD_PREFIX_POSITION_DOCIDS))?; let facet_id_f64_docids = env.create_database(Some(FACET_ID_F64_DOCIDS))?; let facet_id_string_docids = env.create_database(Some(FACET_ID_STRING_DOCIDS))?; - let facet_id_exists_docids: Database = - env.create_database(Some(FACET_ID_EXISTS_DOCIDS))?; + let facet_id_exists_docids = env.create_database(Some(FACET_ID_EXISTS_DOCIDS))?; let field_id_docid_facet_f64s = env.create_database(Some(FIELD_ID_DOCID_FACET_F64S))?; let field_id_docid_facet_strings = diff --git a/milli/src/update/index_documents/extract/extract_facet_exists_docids.rs b/milli/src/update/index_documents/extract/extract_facet_exists_docids.rs index e7a001c08..d25c57aea 100644 --- a/milli/src/update/index_documents/extract/extract_facet_exists_docids.rs +++ b/milli/src/update/index_documents/extract/extract_facet_exists_docids.rs @@ -32,9 +32,7 @@ pub fn extract_facet_exists_docids( let mut cursor = docid_fid_facet_number.into_cursor()?; while let Some((key_bytes, _)) = cursor.move_on_next()? { let (field_id, document_id) = FieldIdDocIdCodec::bytes_decode(key_bytes).unwrap(); - let key_bytes = FieldIdCodec::bytes_encode(&field_id).unwrap(); - facet_exists_docids_sorter.insert(key_bytes, document_id.to_ne_bytes())?; }