Skip to content

Commit

Permalink
feat: memtable filter push down (#2539)
Browse files Browse the repository at this point in the history
* feat: memtable support filter pushdown to prune primary keys

* fix: switch to next time series when pk not selected

* fix: allow predicate evaluation failure

* fix: some clippy warnings

* fix: panic when no primary key in schema

* feat: cache decoded record batch for primary key

* refactor: use arcswap instead of rwlock

* fix: format toml
  • Loading branch information
v0y4g3r authored Oct 10, 2023
1 parent d4577e7 commit 8bdef9a
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 40 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mito2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test = ["common-test-util"]
anymap = "1.0.0-beta.2"
api.workspace = true
aquamarine.workspace = true
arc-swap = "1.6"
async-channel = "1.9"
async-compat = "0.2"
async-stream.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/mito2/src/flush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl RegionFlushTask {
}

let file_id = FileId::random();
let iter = mem.iter(None, &[]);
let iter = mem.iter(None, None);
let source = Source::Iter(iter);
let mut writer = self
.access_layer
Expand Down
8 changes: 6 additions & 2 deletions src/mito2/src/memtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use std::fmt;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;

use common_query::logical_plan::Expr;
use common_time::Timestamp;
use metrics::{decrement_gauge, increment_gauge};
use store_api::metadata::RegionMetadataRef;
use store_api::storage::ColumnId;
use table::predicate::Predicate;

use crate::error::Result;
use crate::flush::WriteBufferManagerRef;
Expand Down Expand Up @@ -73,7 +73,11 @@ pub trait Memtable: Send + Sync + fmt::Debug {
/// Scans the memtable.
/// `projection` selects columns to read, `None` means reading all columns.
/// `filters` are the predicates to be pushed down to memtable.
fn iter(&self, projection: Option<&[ColumnId]>, filters: &[Expr]) -> BoxedBatchIterator;
fn iter(
&self,
projection: Option<&[ColumnId]>,
predicate: Option<Predicate>,
) -> BoxedBatchIterator;

/// Returns true if the memtable is empty.
fn is_empty(&self) -> bool;
Expand Down
Loading

0 comments on commit 8bdef9a

Please sign in to comment.