diff --git a/core/src/dbs/iterator.rs b/core/src/dbs/iterator.rs
index ca1d3896..f4862574 100644
--- a/core/src/dbs/iterator.rs
+++ b/core/src/dbs/iterator.rs
@@ -19,19 +19,18 @@ use crate::sql::thing::Thing;
use crate::sql::value::Value;
use async_recursion::async_recursion;
use std::mem;
-use std::sync::Arc;
#[derive(Clone)]
pub(crate) enum Iterable {
Value(Value),
- Table(Arc
),
+ Table(Table),
Thing(Thing),
Range(Range),
Edges(Edges),
Defer(Thing),
Mergeable(Thing, Value),
Relatable(Thing, Thing, Thing),
- Index(Arc, IteratorRef),
+ Index(Table, IteratorRef),
}
pub(crate) struct Processed {
@@ -118,7 +117,7 @@ impl Iterator {
}
_ => {
// Ingest the table for scanning
- self.ingest(Iterable::Table(Arc::new(v)))
+ self.ingest(Iterable::Table(v))
}
},
// There is no data clause so create a record id
@@ -129,7 +128,7 @@ impl Iterator {
}
_ => {
// Ingest the table for scanning
- self.ingest(Iterable::Table(Arc::new(v)))
+ self.ingest(Iterable::Table(v))
}
},
},
diff --git a/core/src/dbs/processor.rs b/core/src/dbs/processor.rs
index 6d8dea7a..b97da805 100644
--- a/core/src/dbs/processor.rs
+++ b/core/src/dbs/processor.rs
@@ -127,10 +127,10 @@ impl<'a> Processor<'a> {
// Avoiding search in the hashmap of the query planner for each doc
let mut ctx = Context::new(ctx);
ctx.set_query_executor(exe.clone());
- return self.process_table(&ctx, opt, txn, stm, v.as_ref()).await;
+ return self.process_table(&ctx, opt, txn, stm, &v).await;
}
}
- self.process_table(ctx, opt, txn, stm, v.as_ref()).await?
+ self.process_table(ctx, opt, txn, stm, &v).await?
}
Iterable::Range(v) => self.process_range(ctx, opt, txn, stm, v).await?,
Iterable::Edges(e) => self.process_edge(ctx, opt, txn, stm, e).await?,
@@ -141,10 +141,10 @@ impl<'a> Processor<'a> {
// Avoiding search in the hashmap of the query planner for each doc
let mut ctx = Context::new(ctx);
ctx.set_query_executor(exe.clone());
- return self.process_index(&ctx, opt, txn, stm, t.as_ref(), ir).await;
+ return self.process_index(&ctx, opt, txn, stm, &t, ir).await;
}
}
- self.process_index(ctx, opt, txn, stm, t.as_ref(), ir).await?
+ self.process_index(ctx, opt, txn, stm, &t, ir).await?
}
Iterable::Mergeable(v, o) => {
self.process_mergeable(ctx, opt, txn, stm, v, o).await?
@@ -563,7 +563,8 @@ impl<'a> Processor<'a> {
txn.lock().await.check_ns_db_tb(opt.ns(), opt.db(), &table.0, opt.strict).await?;
if let Some(exe) = ctx.get_query_executor() {
if let Some(mut iterator) = exe.new_iterator(opt, ir).await? {
- let mut things = iterator.next_batch(txn, PROCESSOR_BATCH_SIZE).await?;
+ let mut things = Vec::new();
+ iterator.next_batch(txn, PROCESSOR_BATCH_SIZE, &mut things).await?;
while !things.is_empty() {
// Check if the context is finished
if ctx.is_done() {
@@ -601,7 +602,8 @@ impl<'a> Processor<'a> {
}
// Collect the next batch of ids
- things = iterator.next_batch(txn, PROCESSOR_BATCH_SIZE).await?;
+ things = Vec::new();
+ iterator.next_batch(txn, PROCESSOR_BATCH_SIZE, &mut things).await?;
}
// Everything ok
return Ok(());
diff --git a/core/src/fnc/operate.rs b/core/src/fnc/operate.rs
index c8efece4..21f40467 100644
--- a/core/src/fnc/operate.rs
+++ b/core/src/fnc/operate.rs
@@ -212,15 +212,19 @@ fn get_executor_option<'a>(
pub(crate) async fn matches(
ctx: &Context<'_>,
+ opt: &Options,
txn: &Transaction,
doc: Option<&CursorDoc<'_>>,
exp: &Expression,
+ l: Value,
+ r: Value,
) -> Result {
- match get_executor_option(ctx, doc, exp) {
- ExecutorOption::PreMatch => Ok(Value::Bool(true)),
- ExecutorOption::None => Ok(Value::Bool(false)),
- ExecutorOption::Execute(exe, thg) => exe.matches(txn, thg, exp).await,
- }
+ let res = match get_executor_option(ctx, doc, exp) {
+ ExecutorOption::PreMatch => true,
+ ExecutorOption::None => false,
+ ExecutorOption::Execute(exe, thg) => exe.matches(ctx, opt, txn, thg, exp, l, r).await?,
+ };
+ Ok(res.into())
}
pub(crate) async fn knn(
diff --git a/core/src/idx/ft/analyzer/filter.rs b/core/src/idx/ft/analyzer/filter.rs
index 36566f43..af1adc9a 100644
--- a/core/src/idx/ft/analyzer/filter.rs
+++ b/core/src/idx/ft/analyzer/filter.rs
@@ -11,7 +11,6 @@ pub(super) enum FilteringStage {
Indexing,
Querying,
}
-
pub(super) enum Filter {
Stemmer(Stemmer),
Ascii,
diff --git a/core/src/idx/ft/analyzer/mod.rs b/core/src/idx/ft/analyzer/mod.rs
index 10c2f70f..60f7ec66 100644
--- a/core/src/idx/ft/analyzer/mod.rs
+++ b/core/src/idx/ft/analyzer/mod.rs
@@ -6,7 +6,7 @@ use crate::idx::ft::analyzer::tokenizer::{Tokenizer, Tokens};
use crate::idx::ft::doclength::DocLength;
use crate::idx::ft::offsets::{Offset, OffsetRecords};
use crate::idx::ft::postings::TermFrequency;
-use crate::idx::ft::terms::{TermId, Terms};
+use crate::idx::ft::terms::{TermId, TermLen, Terms};
use crate::sql::statements::DefineAnalyzerStatement;
use crate::sql::tokenizer::Tokenizer as SqlTokenizer;
use crate::sql::Value;
@@ -34,31 +34,96 @@ impl From for Analyzer {
}
}
}
+
+pub(in crate::idx) type TermsList = Vec