Skip to content

Commit

Permalink
refactor: use RangeDetacher for Range inference to reduce redundant l…
Browse files Browse the repository at this point in the history
…ogic and avoid more potential bugs (#151)
  • Loading branch information
KKould authored Mar 6, 2024
1 parent c20229f commit bfa8a4b
Show file tree
Hide file tree
Showing 17 changed files with 1,460 additions and 1,657 deletions.
13 changes: 9 additions & 4 deletions src/execution/volcano/dql/index_scan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::errors::DatabaseError;
use crate::execution::volcano::{BoxedExecutor, ReadExecutor};
use crate::expression::simplify::ConstantBinary;
use crate::expression::range_detacher::Range;
use crate::planner::operator::scan::ScanOperator;
use crate::storage::{Iter, Transaction};
use crate::types::index::IndexMetaRef;
Expand All @@ -10,11 +10,16 @@ use futures_async_stream::try_stream;
pub(crate) struct IndexScan {
op: ScanOperator,
index_by: IndexMetaRef,
ranges: Vec<ConstantBinary>,
ranges: Vec<Range>,
}

impl From<(ScanOperator, IndexMetaRef, Vec<ConstantBinary>)> for IndexScan {
fn from((op, index_by, ranges): (ScanOperator, IndexMetaRef, Vec<ConstantBinary>)) -> Self {
impl From<(ScanOperator, IndexMetaRef, Range)> for IndexScan {
fn from((op, index_by, range): (ScanOperator, IndexMetaRef, Range)) -> Self {
let ranges = match range {
Range::SortedRanges(ranges) => ranges,
range => vec![range],
};

IndexScan {
op,
index_by,
Expand Down
4 changes: 2 additions & 2 deletions src/execution/volcano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ pub fn build_read<T: Transaction>(plan: LogicalPlan, transaction: &T) -> BoxedEx
Operator::Scan(op) => {
if let Some(PhysicalOption::IndexScan(IndexInfo {
meta,
ranges: Some(ranges),
range: Some(range),
})) = plan.physical_option
{
IndexScan::from((op, meta, ranges)).execute(transaction)
IndexScan::from((op, meta, range)).execute(transaction)
} else {
SeqScan::from(op).execute(transaction)
}
Expand Down
1 change: 1 addition & 0 deletions src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::types::LogicalType;
pub mod agg;
mod evaluator;
pub mod function;
pub mod range_detacher;
pub mod simplify;
pub mod value_compute;

Expand Down
Loading

0 comments on commit bfa8a4b

Please sign in to comment.