mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-06 18:10:58 -05:00
Refactor bool index (#5524)
* rename binary->bool * restructure bool_index module * rename Boolean->Bool * rename memory_bool_index -> simple_bool_index
This commit is contained in:
1
lib/segment/src/index/field_index/bool_index/mod.rs
Normal file
1
lib/segment/src/index/field_index/bool_index/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod simple_bool_index;
|
||||
@@ -6,15 +6,15 @@ use parking_lot::RwLock;
|
||||
use rocksdb::DB;
|
||||
use serde_json::Value;
|
||||
|
||||
use self::memory::{BinaryItem, BinaryMemory};
|
||||
use super::map_index::IdIter;
|
||||
use super::{
|
||||
CardinalityEstimation, FieldIndexBuilderTrait, PayloadFieldIndex, PrimaryCondition,
|
||||
ValueIndexer,
|
||||
};
|
||||
use self::memory::{BoolMemory, BooleanItem};
|
||||
use crate::common::operation_error::OperationResult;
|
||||
use crate::common::rocksdb_buffered_delete_wrapper::DatabaseColumnScheduledDeleteWrapper;
|
||||
use crate::common::rocksdb_wrapper::DatabaseColumnWrapper;
|
||||
use crate::index::field_index::map_index::IdIter;
|
||||
use crate::index::field_index::{
|
||||
CardinalityEstimation, FieldIndexBuilderTrait, PayloadBlockCondition, PayloadFieldIndex,
|
||||
PrimaryCondition, ValueIndexer,
|
||||
};
|
||||
use crate::telemetry::PayloadIndexTelemetry;
|
||||
use crate::types::{FieldCondition, Match, MatchValue, PayloadKeyType, ValueVariants};
|
||||
|
||||
@@ -22,11 +22,11 @@ mod memory {
|
||||
use bitvec::vec::BitVec;
|
||||
use common::types::PointOffsetType;
|
||||
|
||||
pub struct BinaryItem {
|
||||
pub struct BooleanItem {
|
||||
value: u8,
|
||||
}
|
||||
|
||||
impl BinaryItem {
|
||||
impl BooleanItem {
|
||||
const HAS_TRUE: u8 = 0b0000_0001;
|
||||
const HAS_FALSE: u8 = 0b0000_0010;
|
||||
|
||||
@@ -62,13 +62,13 @@ mod memory {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u8> for BinaryItem {
|
||||
impl From<u8> for BooleanItem {
|
||||
fn from(value: u8) -> Self {
|
||||
Self { value }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BinaryMemory {
|
||||
pub struct BoolMemory {
|
||||
trues: BitVec,
|
||||
falses: BitVec,
|
||||
trues_count: usize,
|
||||
@@ -76,7 +76,7 @@ mod memory {
|
||||
indexed_count: usize,
|
||||
}
|
||||
|
||||
impl BinaryMemory {
|
||||
impl BoolMemory {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
trues: BitVec::new(),
|
||||
@@ -87,16 +87,16 @@ mod memory {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, id: PointOffsetType) -> BinaryItem {
|
||||
pub fn get(&self, id: PointOffsetType) -> BooleanItem {
|
||||
debug_assert!(self.trues.len() == self.falses.len());
|
||||
|
||||
let has_true = self.trues.get(id as usize).map(|v| *v).unwrap_or(false);
|
||||
let has_false = self.falses.get(id as usize).map(|v| *v).unwrap_or(false);
|
||||
|
||||
BinaryItem::from_bools(has_true, has_false)
|
||||
BooleanItem::from_bools(has_true, has_false)
|
||||
}
|
||||
|
||||
pub fn set_or_insert(&mut self, id: PointOffsetType, item: &BinaryItem) {
|
||||
pub fn set_or_insert(&mut self, id: PointOffsetType, item: &BooleanItem) {
|
||||
if (id as usize) >= self.trues.len() {
|
||||
self.trues.resize(id as usize + 1, false);
|
||||
self.falses.resize(id as usize + 1, false);
|
||||
@@ -166,26 +166,26 @@ mod memory {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BinaryIndex {
|
||||
memory: BinaryMemory,
|
||||
pub struct BoolIndex {
|
||||
memory: BoolMemory,
|
||||
db_wrapper: DatabaseColumnScheduledDeleteWrapper,
|
||||
}
|
||||
|
||||
impl BinaryIndex {
|
||||
pub fn new(db: Arc<RwLock<DB>>, field_name: &str) -> BinaryIndex {
|
||||
impl BoolIndex {
|
||||
pub fn new(db: Arc<RwLock<DB>>, field_name: &str) -> BoolIndex {
|
||||
let store_cf_name = Self::storage_cf_name(field_name);
|
||||
let db_wrapper = DatabaseColumnScheduledDeleteWrapper::new(DatabaseColumnWrapper::new(
|
||||
db,
|
||||
&store_cf_name,
|
||||
));
|
||||
Self {
|
||||
memory: BinaryMemory::new(),
|
||||
memory: BoolMemory::new(),
|
||||
db_wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn builder(db: Arc<RwLock<DB>>, field_name: &str) -> BinaryIndexBuilder {
|
||||
BinaryIndexBuilder(Self::new(db, field_name))
|
||||
pub fn builder(db: Arc<RwLock<DB>>, field_name: &str) -> BoolIndexBuilder {
|
||||
BoolIndexBuilder(Self::new(db, field_name))
|
||||
}
|
||||
|
||||
fn storage_cf_name(field: &str) -> String {
|
||||
@@ -237,10 +237,10 @@ impl BinaryIndex {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BinaryIndexBuilder(BinaryIndex);
|
||||
pub struct BoolIndexBuilder(BoolIndex);
|
||||
|
||||
impl FieldIndexBuilderTrait for BinaryIndexBuilder {
|
||||
type FieldIndexType = BinaryIndex;
|
||||
impl FieldIndexBuilderTrait for BoolIndexBuilder {
|
||||
type FieldIndexType = BoolIndex;
|
||||
|
||||
fn init(&mut self) -> OperationResult<()> {
|
||||
self.0.db_wrapper.recreate_column_family()
|
||||
@@ -255,7 +255,7 @@ impl FieldIndexBuilderTrait for BinaryIndexBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl PayloadFieldIndex for BinaryIndex {
|
||||
impl PayloadFieldIndex for BoolIndex {
|
||||
fn load(&mut self) -> OperationResult<bool> {
|
||||
if !self.db_wrapper.has_column_family()? {
|
||||
return Ok(false);
|
||||
@@ -266,7 +266,7 @@ impl PayloadFieldIndex for BinaryIndex {
|
||||
|
||||
debug_assert_eq!(value.len(), 1);
|
||||
|
||||
let item = BinaryItem::from(value[0]);
|
||||
let item = BooleanItem::from(value[0]);
|
||||
self.memory.set_or_insert(idx, &item);
|
||||
}
|
||||
Ok(true)
|
||||
@@ -326,10 +326,10 @@ impl PayloadFieldIndex for BinaryIndex {
|
||||
&self,
|
||||
threshold: usize,
|
||||
key: PayloadKeyType,
|
||||
) -> Box<dyn Iterator<Item = super::PayloadBlockCondition> + '_> {
|
||||
) -> Box<dyn Iterator<Item = PayloadBlockCondition> + '_> {
|
||||
let make_block = |count, value, key: PayloadKeyType| {
|
||||
if count > threshold {
|
||||
Some(super::PayloadBlockCondition {
|
||||
Some(PayloadBlockCondition {
|
||||
condition: FieldCondition::new_match(
|
||||
key,
|
||||
Match::Value(MatchValue {
|
||||
@@ -359,7 +359,7 @@ impl PayloadFieldIndex for BinaryIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl ValueIndexer for BinaryIndex {
|
||||
impl ValueIndexer for BoolIndex {
|
||||
type ValueType = bool;
|
||||
|
||||
fn add_many(&mut self, id: PointOffsetType, values: Vec<bool>) -> OperationResult<()> {
|
||||
@@ -370,7 +370,7 @@ impl ValueIndexer for BinaryIndex {
|
||||
let has_true = values.iter().any(|v| *v);
|
||||
let has_false = values.iter().any(|v| !*v);
|
||||
|
||||
let item = BinaryItem::from_bools(has_true, has_false);
|
||||
let item = BooleanItem::from_bools(has_true, has_false);
|
||||
|
||||
self.memory.set_or_insert(id, &item);
|
||||
|
||||
@@ -397,7 +397,7 @@ mod tests {
|
||||
use serde_json::json;
|
||||
use tempfile::{Builder, TempDir};
|
||||
|
||||
use super::BinaryIndex;
|
||||
use super::BoolIndex;
|
||||
use crate::common::rocksdb_wrapper::open_db_with_existing_cf;
|
||||
use crate::index::field_index::{FieldIndexBuilderTrait as _, PayloadFieldIndex, ValueIndexer};
|
||||
use crate::json_path::JsonPath;
|
||||
@@ -405,10 +405,10 @@ mod tests {
|
||||
const FIELD_NAME: &str = "bool_field";
|
||||
const DB_NAME: &str = "test_db";
|
||||
|
||||
fn new_binary_index() -> (TempDir, BinaryIndex) {
|
||||
fn new_binary_index() -> (TempDir, BoolIndex) {
|
||||
let tmp_dir = Builder::new().prefix(DB_NAME).tempdir().unwrap();
|
||||
let db = open_db_with_existing_cf(tmp_dir.path()).unwrap();
|
||||
let index = BinaryIndex::builder(db, FIELD_NAME).make_empty().unwrap();
|
||||
let index = BoolIndex::builder(db, FIELD_NAME).make_empty().unwrap();
|
||||
(tmp_dir, index)
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ mod tests {
|
||||
index.flusher()().unwrap();
|
||||
let db = index.db_wrapper.get_database();
|
||||
|
||||
let mut new_index = BinaryIndex::new(db, FIELD_NAME);
|
||||
let mut new_index = BoolIndex::new(db, FIELD_NAME);
|
||||
assert!(new_index.load().unwrap());
|
||||
|
||||
let point_offsets = new_index.filter(&match_bool(false)).unwrap().collect_vec();
|
||||
@@ -1,7 +1,7 @@
|
||||
use common::types::PointOffsetType;
|
||||
use itertools::Itertools;
|
||||
|
||||
use super::binary_index::BinaryIndex;
|
||||
use super::bool_index::simple_bool_index::BoolIndex;
|
||||
use super::map_index::MapIndex;
|
||||
use crate::data_types::facets::{FacetHit, FacetValueRef};
|
||||
use crate::index::struct_filter_context::StructFilterContext;
|
||||
@@ -12,7 +12,7 @@ pub enum FacetIndex<'a> {
|
||||
Keyword(&'a MapIndex<str>),
|
||||
Int(&'a MapIndex<IntPayloadType>),
|
||||
Uuid(&'a MapIndex<UuidIntType>),
|
||||
Bool(&'a BinaryIndex),
|
||||
Bool(&'a BoolIndex),
|
||||
}
|
||||
|
||||
impl<'a> FacetIndex<'a> {
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
use common::types::PointOffsetType;
|
||||
use serde_json::Value;
|
||||
|
||||
use super::binary_index::BinaryIndexBuilder;
|
||||
use super::bool_index::simple_bool_index::BoolIndexBuilder;
|
||||
use super::facet_index::FacetIndex;
|
||||
use super::full_text_index::mmap_text_index::FullTextMmapIndexBuilder;
|
||||
use super::full_text_index::text_index::{FullTextIndex, FullTextIndexBuilder};
|
||||
@@ -16,7 +16,7 @@ use super::numeric_index::{
|
||||
use crate::common::operation_error::OperationResult;
|
||||
use crate::common::Flusher;
|
||||
use crate::data_types::order_by::OrderValue;
|
||||
use crate::index::field_index::binary_index::BinaryIndex;
|
||||
use crate::index::field_index::bool_index::simple_bool_index::BoolIndex;
|
||||
use crate::index::field_index::geo_index::GeoMapIndex;
|
||||
use crate::index::field_index::numeric_index::NumericIndexInner;
|
||||
use crate::index::field_index::{CardinalityEstimation, PayloadBlockCondition};
|
||||
@@ -116,7 +116,7 @@ pub enum FieldIndex {
|
||||
FloatIndex(NumericIndex<FloatPayloadType, FloatPayloadType>),
|
||||
GeoIndex(GeoMapIndex),
|
||||
FullTextIndex(FullTextIndex),
|
||||
BinaryIndex(BinaryIndex),
|
||||
BoolIndex(BoolIndex),
|
||||
UuidIndex(NumericIndex<UuidIntType, UuidPayloadType>),
|
||||
UuidMapIndex(MapIndex<UuidIntType>),
|
||||
}
|
||||
@@ -130,7 +130,7 @@ impl std::fmt::Debug for FieldIndex {
|
||||
FieldIndex::KeywordIndex(_index) => write!(f, "KeywordIndex"),
|
||||
FieldIndex::FloatIndex(_index) => write!(f, "FloatIndex"),
|
||||
FieldIndex::GeoIndex(_index) => write!(f, "GeoIndex"),
|
||||
FieldIndex::BinaryIndex(_index) => write!(f, "BinaryIndex"),
|
||||
FieldIndex::BoolIndex(_index) => write!(f, "BoolIndex"),
|
||||
FieldIndex::FullTextIndex(_index) => write!(f, "FullTextIndex"),
|
||||
FieldIndex::UuidIndex(_index) => write!(f, "UuidIndex"),
|
||||
FieldIndex::UuidMapIndex(_index) => write!(f, "UuidMapIndex"),
|
||||
@@ -158,7 +158,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(_) => None,
|
||||
FieldIndex::FloatIndex(_) => None,
|
||||
FieldIndex::GeoIndex(_) => None,
|
||||
FieldIndex::BinaryIndex(_) => None,
|
||||
FieldIndex::BoolIndex(_) => None,
|
||||
FieldIndex::FullTextIndex(full_text_index) => match &condition.r#match {
|
||||
Some(Match::Text(MatchText { text })) => {
|
||||
let query = full_text_index.parse_query(text);
|
||||
@@ -185,7 +185,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(payload_field_index) => payload_field_index,
|
||||
FieldIndex::FloatIndex(payload_field_index) => payload_field_index.inner(),
|
||||
FieldIndex::GeoIndex(payload_field_index) => payload_field_index,
|
||||
FieldIndex::BinaryIndex(payload_field_index) => payload_field_index,
|
||||
FieldIndex::BoolIndex(payload_field_index) => payload_field_index,
|
||||
FieldIndex::FullTextIndex(payload_field_index) => payload_field_index,
|
||||
FieldIndex::UuidIndex(payload_field_index) => payload_field_index.inner(),
|
||||
FieldIndex::UuidMapIndex(payload_field_index) => payload_field_index,
|
||||
@@ -200,7 +200,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::FloatIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::GeoIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::BinaryIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::BoolIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::FullTextIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::UuidIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
FieldIndex::UuidMapIndex(ref mut payload_field_index) => payload_field_index.load(),
|
||||
@@ -215,7 +215,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => index.clear(),
|
||||
FieldIndex::FloatIndex(index) => index.clear(),
|
||||
FieldIndex::GeoIndex(index) => index.clear(),
|
||||
FieldIndex::BinaryIndex(index) => index.clear(),
|
||||
FieldIndex::BoolIndex(index) => index.clear(),
|
||||
FieldIndex::FullTextIndex(index) => index.clear(),
|
||||
FieldIndex::UuidIndex(index) => index.clear(),
|
||||
FieldIndex::UuidMapIndex(index) => index.clear(),
|
||||
@@ -278,7 +278,7 @@ impl FieldIndex {
|
||||
FieldIndex::GeoIndex(ref mut payload_field_index) => {
|
||||
payload_field_index.add_point(id, payload)
|
||||
}
|
||||
FieldIndex::BinaryIndex(ref mut payload_field_index) => {
|
||||
FieldIndex::BoolIndex(ref mut payload_field_index) => {
|
||||
payload_field_index.add_point(id, payload)
|
||||
}
|
||||
FieldIndex::FullTextIndex(ref mut payload_field_index) => {
|
||||
@@ -301,7 +301,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::FloatIndex(index) => index.mut_inner().remove_point(point_id),
|
||||
FieldIndex::GeoIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::BinaryIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::BoolIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::FullTextIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::UuidIndex(index) => index.remove_point(point_id),
|
||||
FieldIndex::UuidMapIndex(index) => index.remove_point(point_id),
|
||||
@@ -316,7 +316,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::FloatIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::GeoIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::BinaryIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::BoolIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::FullTextIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::UuidIndex(index) => index.get_telemetry_data(),
|
||||
FieldIndex::UuidMapIndex(index) => index.get_telemetry_data(),
|
||||
@@ -331,7 +331,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::FloatIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::GeoIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::BinaryIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::BoolIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::FullTextIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::UuidIndex(index) => index.values_count(point_id),
|
||||
FieldIndex::UuidMapIndex(index) => index.values_count(point_id),
|
||||
@@ -346,7 +346,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::FloatIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::GeoIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::BinaryIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::BoolIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::FullTextIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::UuidIndex(index) => index.values_is_empty(point_id),
|
||||
FieldIndex::UuidMapIndex(index) => index.values_is_empty(point_id),
|
||||
@@ -361,7 +361,7 @@ impl FieldIndex {
|
||||
FieldIndex::IntMapIndex(_)
|
||||
| FieldIndex::KeywordIndex(_)
|
||||
| FieldIndex::GeoIndex(_)
|
||||
| FieldIndex::BinaryIndex(_)
|
||||
| FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::UuidMapIndex(_)
|
||||
| FieldIndex::UuidIndex(_)
|
||||
| FieldIndex::FullTextIndex(_) => None,
|
||||
@@ -373,7 +373,7 @@ impl FieldIndex {
|
||||
FieldIndex::KeywordIndex(index) => Some(FacetIndex::Keyword(index)),
|
||||
FieldIndex::IntMapIndex(index) => Some(FacetIndex::Int(index)),
|
||||
FieldIndex::UuidMapIndex(index) => Some(FacetIndex::Uuid(index)),
|
||||
FieldIndex::BinaryIndex(index) => Some(FacetIndex::Bool(index)),
|
||||
FieldIndex::BoolIndex(index) => Some(FacetIndex::Bool(index)),
|
||||
FieldIndex::UuidIndex(_)
|
||||
| FieldIndex::IntIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
@@ -424,7 +424,7 @@ pub enum FieldIndexBuilder {
|
||||
GeoMmapIndex(GeoMapIndexMmapBuilder),
|
||||
FullTextIndex(FullTextIndexBuilder),
|
||||
FullTextMmapIndex(FullTextMmapIndexBuilder),
|
||||
BinaryIndex(BinaryIndexBuilder),
|
||||
BoolIndex(BoolIndexBuilder),
|
||||
UuidIndex(MapIndexBuilder<UuidIntType>),
|
||||
UuidMmapIndex(MapIndexMmapBuilder<UuidIntType>),
|
||||
}
|
||||
@@ -446,7 +446,7 @@ impl FieldIndexBuilderTrait for FieldIndexBuilder {
|
||||
Self::FloatMmapIndex(index) => index.init(),
|
||||
Self::GeoIndex(index) => index.init(),
|
||||
Self::GeoMmapIndex(index) => index.init(),
|
||||
Self::BinaryIndex(index) => index.init(),
|
||||
Self::BoolIndex(index) => index.init(),
|
||||
Self::FullTextIndex(index) => index.init(),
|
||||
Self::FullTextMmapIndex(builder) => builder.init(),
|
||||
Self::UuidIndex(index) => index.init(),
|
||||
@@ -468,7 +468,7 @@ impl FieldIndexBuilderTrait for FieldIndexBuilder {
|
||||
Self::FloatMmapIndex(index) => index.add_point(id, payload),
|
||||
Self::GeoIndex(index) => index.add_point(id, payload),
|
||||
Self::GeoMmapIndex(index) => index.add_point(id, payload),
|
||||
Self::BinaryIndex(index) => index.add_point(id, payload),
|
||||
Self::BoolIndex(index) => index.add_point(id, payload),
|
||||
Self::FullTextIndex(index) => index.add_point(id, payload),
|
||||
Self::FullTextMmapIndex(builder) => {
|
||||
FieldIndexBuilderTrait::add_point(builder, id, payload)
|
||||
@@ -492,7 +492,7 @@ impl FieldIndexBuilderTrait for FieldIndexBuilder {
|
||||
Self::FloatMmapIndex(index) => FieldIndex::FloatIndex(index.finalize()?),
|
||||
Self::GeoIndex(index) => FieldIndex::GeoIndex(index.finalize()?),
|
||||
Self::GeoMmapIndex(index) => FieldIndex::GeoIndex(index.finalize()?),
|
||||
Self::BinaryIndex(index) => FieldIndex::BinaryIndex(index.finalize()?),
|
||||
Self::BoolIndex(index) => FieldIndex::BoolIndex(index.finalize()?),
|
||||
Self::FullTextIndex(index) => FieldIndex::FullTextIndex(index.finalize()?),
|
||||
Self::FullTextMmapIndex(builder) => FieldIndex::FullTextIndex(builder.finalize()?),
|
||||
Self::UuidIndex(index) => FieldIndex::UuidMapIndex(index.finalize()?),
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
use parking_lot::RwLock;
|
||||
use rocksdb::DB;
|
||||
|
||||
use super::binary_index::BinaryIndex;
|
||||
use super::bool_index::simple_bool_index::BoolIndex;
|
||||
use super::geo_index::{GeoMapIndexBuilder, GeoMapIndexMmapBuilder};
|
||||
use super::histogram::Numericable;
|
||||
use super::map_index::{MapIndex, MapIndexBuilder, MapIndexKey, MapIndexMmapBuilder};
|
||||
@@ -70,7 +70,7 @@ impl<'a> IndexSelector<'a> {
|
||||
)]
|
||||
}
|
||||
PayloadSchemaParams::Bool(_) => {
|
||||
vec![FieldIndex::BinaryIndex(BinaryIndex::new(
|
||||
vec![FieldIndex::BoolIndex(BoolIndex::new(
|
||||
self.as_rocksdb()?.db.clone(),
|
||||
&field.to_string(),
|
||||
))]
|
||||
@@ -133,7 +133,7 @@ impl<'a> IndexSelector<'a> {
|
||||
vec![self.text_builder(field, text_index_params.clone())]
|
||||
}
|
||||
PayloadSchemaParams::Bool(_) => {
|
||||
vec![FieldIndexBuilder::BinaryIndex(BinaryIndex::builder(
|
||||
vec![FieldIndexBuilder::BoolIndex(BoolIndex::builder(
|
||||
self.as_rocksdb()?.db.clone(),
|
||||
&field.to_string(),
|
||||
))]
|
||||
|
||||
@@ -4,6 +4,7 @@ use common::types::PointOffsetType;
|
||||
|
||||
use crate::types::{FieldCondition, IsEmptyCondition, IsNullCondition};
|
||||
|
||||
pub mod bool_index;
|
||||
pub(super) mod facet_index;
|
||||
mod field_index_base;
|
||||
pub mod full_text_index;
|
||||
@@ -17,7 +18,6 @@ mod mmap_point_to_values;
|
||||
pub mod numeric_index;
|
||||
mod stat_tools;
|
||||
|
||||
pub mod binary_index;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod utils;
|
||||
|
||||
@@ -203,7 +203,7 @@ pub fn get_geo_polygon_checkers(
|
||||
FieldIndex::GeoIndex(geo_index) => Some(Box::new(move |point_id: PointOffsetType| {
|
||||
geo_index.check_values_any(point_id, |value| polygon_wrapper.check_point(value))
|
||||
})),
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
| FieldIndex::FloatIndex(_)
|
||||
| FieldIndex::FullTextIndex(_)
|
||||
@@ -223,7 +223,7 @@ pub fn get_geo_radius_checkers(
|
||||
FieldIndex::GeoIndex(geo_index) => Some(Box::new(move |point_id: PointOffsetType| {
|
||||
geo_index.check_values_any(point_id, |value| geo_radius.check_point(value))
|
||||
})),
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
| FieldIndex::FloatIndex(_)
|
||||
| FieldIndex::FullTextIndex(_)
|
||||
@@ -243,7 +243,7 @@ pub fn get_geo_bounding_box_checkers(
|
||||
FieldIndex::GeoIndex(geo_index) => Some(Box::new(move |point_id: PointOffsetType| {
|
||||
geo_index.check_values_any(point_id, |value| geo_bounding_box.check_point(value))
|
||||
})),
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
| FieldIndex::FloatIndex(_)
|
||||
| FieldIndex::FullTextIndex(_)
|
||||
@@ -276,7 +276,7 @@ pub fn get_float_range_checkers(
|
||||
FieldIndex::FloatIndex(num_index) => Some(Box::new(move |point_id: PointOffsetType| {
|
||||
num_index.check_values_any(point_id, |value| range.check_range(*value))
|
||||
})),
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
| FieldIndex::FullTextIndex(_)
|
||||
| FieldIndex::GeoIndex(_)
|
||||
@@ -298,7 +298,7 @@ pub fn get_datetime_range_checkers(
|
||||
num_index.check_values_any(point_id, |value| range.check_range(*value))
|
||||
}))
|
||||
}
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::FloatIndex(_)
|
||||
| FieldIndex::FullTextIndex(_)
|
||||
| FieldIndex::GeoIndex(_)
|
||||
|
||||
@@ -39,7 +39,7 @@ fn get_match_value_checker(
|
||||
index.check_values_any(point_id, |i| *i == value)
|
||||
}))
|
||||
}
|
||||
(ValueVariants::Bool(is_true), FieldIndex::BinaryIndex(index)) => {
|
||||
(ValueVariants::Bool(is_true), FieldIndex::BoolIndex(index)) => {
|
||||
Some(Box::new(move |point_id: PointOffsetType| {
|
||||
if is_true {
|
||||
index.values_has_true(point_id)
|
||||
@@ -57,7 +57,7 @@ fn get_match_value_checker(
|
||||
| (ValueVariants::Bool(_), FieldIndex::KeywordIndex(_))
|
||||
| (ValueVariants::Bool(_), FieldIndex::UuidIndex(_))
|
||||
| (ValueVariants::Bool(_), FieldIndex::UuidMapIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::BinaryIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::BoolIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::DatetimeIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::FloatIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::FullTextIndex(_))
|
||||
@@ -66,7 +66,7 @@ fn get_match_value_checker(
|
||||
| (ValueVariants::Integer(_), FieldIndex::KeywordIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::UuidIndex(_))
|
||||
| (ValueVariants::Integer(_), FieldIndex::UuidMapIndex(_))
|
||||
| (ValueVariants::String(_), FieldIndex::BinaryIndex(_))
|
||||
| (ValueVariants::String(_), FieldIndex::BoolIndex(_))
|
||||
| (ValueVariants::String(_), FieldIndex::DatetimeIndex(_))
|
||||
| (ValueVariants::String(_), FieldIndex::FloatIndex(_))
|
||||
| (ValueVariants::String(_), FieldIndex::FullTextIndex(_))
|
||||
@@ -122,7 +122,7 @@ fn get_match_any_checker(
|
||||
}))
|
||||
}
|
||||
}
|
||||
(AnyVariants::Integers(_), FieldIndex::BinaryIndex(_))
|
||||
(AnyVariants::Integers(_), FieldIndex::BoolIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::DatetimeIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::FloatIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::FullTextIndex(_))
|
||||
@@ -131,7 +131,7 @@ fn get_match_any_checker(
|
||||
| (AnyVariants::Integers(_), FieldIndex::KeywordIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::UuidIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::UuidMapIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::BinaryIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::BoolIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::DatetimeIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::FloatIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::FullTextIndex(_))
|
||||
@@ -190,7 +190,7 @@ fn get_match_except_checker(except: AnyVariants, index: &FieldIndex) -> Option<C
|
||||
| (AnyVariants::Strings(_), FieldIndex::FloatIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::GeoIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::FullTextIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::BinaryIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::BoolIndex(_))
|
||||
| (AnyVariants::Strings(_), FieldIndex::UuidIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::IntIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::DatetimeIndex(_))
|
||||
@@ -198,7 +198,7 @@ fn get_match_except_checker(except: AnyVariants, index: &FieldIndex) -> Option<C
|
||||
| (AnyVariants::Integers(_), FieldIndex::FloatIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::GeoIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::FullTextIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::BinaryIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::BoolIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::UuidIndex(_))
|
||||
| (AnyVariants::Integers(_), FieldIndex::UuidMapIndex(_)) => None,
|
||||
};
|
||||
@@ -221,7 +221,7 @@ fn get_match_text_checker(text: String, index: &FieldIndex) -> Option<ConditionC
|
||||
full_text_index.check_match(&parsed_query, point_id)
|
||||
}))
|
||||
}
|
||||
FieldIndex::BinaryIndex(_)
|
||||
FieldIndex::BoolIndex(_)
|
||||
| FieldIndex::DatetimeIndex(_)
|
||||
| FieldIndex::FloatIndex(_)
|
||||
| FieldIndex::GeoIndex(_)
|
||||
|
||||
@@ -212,7 +212,7 @@ impl SegmentBuilder {
|
||||
}
|
||||
FieldIndex::GeoIndex(_) => {}
|
||||
FieldIndex::FullTextIndex(_) => {}
|
||||
FieldIndex::BinaryIndex(_) => {}
|
||||
FieldIndex::BoolIndex(_) => {}
|
||||
}
|
||||
}
|
||||
ordering
|
||||
|
||||
Reference in New Issue
Block a user