From 7a5889bc5a817cacad26ed7bef9912ec6c58a2c8 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 17 Aug 2021 10:45:26 +0200 Subject: [PATCH] Introduce the highest_reverse_iter private method --- milli/src/search/facet/facet_string.rs | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/milli/src/search/facet/facet_string.rs b/milli/src/search/facet/facet_string.rs index c19a8d7de..777837bf1 100644 --- a/milli/src/search/facet/facet_string.rs +++ b/milli/src/search/facet/facet_string.rs @@ -497,6 +497,34 @@ impl<'t> FacetStringIter<'t> { .map(Right), } } + + fn highest_reverse_iter( + rtxn: &'t heed::RoTxn, + index: &'t Index, + db: Database, + field_id: FieldId, + ) -> heed::Result, FacetStringLevelZeroRevRange<'t>>> { + let highest_level = Self::highest_level(rtxn, db, field_id)?.unwrap_or(0); + match NonZeroU8::new(highest_level) { + Some(highest_level) => FacetStringGroupRevRange::new( + rtxn, + index.facet_id_string_docids, + field_id, + highest_level, + Unbounded, + Unbounded, + ) + .map(Left), + None => FacetStringLevelZeroRevRange::new( + rtxn, + index.facet_id_string_docids, + field_id, + Unbounded, + Unbounded, + ) + .map(Right), + } + } } impl<'t> Iterator for FacetStringIter<'t> {