From f0ddea821cd214254ce201d29410c25b61940f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 19 Feb 2021 15:14:00 +0100 Subject: [PATCH] Introduce the Typo criterion --- milli/src/search/criteria/mod.rs | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 milli/src/search/criteria/mod.rs diff --git a/milli/src/search/criteria/mod.rs b/milli/src/search/criteria/mod.rs new file mode 100644 index 000000000..4cc4512d7 --- /dev/null +++ b/milli/src/search/criteria/mod.rs @@ -0,0 +1,34 @@ +use crate::Index; + +use roaring::RoaringBitmap; + +use super::query_tree::Operation; + +pub mod typo; + +pub trait Criterion { + fn next(&mut self) -> anyhow::Result, RoaringBitmap)>>; +} + +/// Either a set of candidates that defines the candidates +/// that are allowed to be returned, +/// or the candidates that must never be returned. +enum Candidates { + Allowed(RoaringBitmap), + Forbidden(RoaringBitmap) +} + +impl Candidates { + fn into_inner(self) -> RoaringBitmap { + match self { + Self::Allowed(inner) => inner, + Self::Forbidden(inner) => inner, + } + } +} + +impl Default for Candidates { + fn default() -> Self { + Self::Forbidden(RoaringBitmap::new()) + } +}