Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(fuse): optimize the expr in range filter #9565

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/query/expression/src/utils/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn combine_validities(lhs: Option<&Bitmap>, rhs: Option<&Bitmap>) -> Option<
}
}

pub fn combine_validities_2(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<Bitmap> {
pub fn and_validities(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<Bitmap> {
match (lhs, rhs) {
(Some(lhs), None) => Some(lhs),
(None, Some(rhs)) => Some(rhs),
Expand All @@ -122,7 +122,7 @@ pub fn combine_validities_2(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<
}
}

pub fn combine_validities_3(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<Bitmap> {
pub fn or_validities(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<Bitmap> {
match (lhs, rhs) {
(Some(lhs), None) => Some(lhs),
(None, Some(rhs)) => Some(rhs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use common_arrow::arrow::bitmap::MutableBitmap;
use common_catalog::table_context::TableContext;
use common_exception::ErrorCode;
use common_exception::Result;
use common_expression::arrow::combine_validities_3;
use common_expression::arrow::constant_bitmap;
use common_expression::arrow::or_validities;
use common_expression::types::nullable::NullableColumn;
use common_expression::types::AnyType;
use common_expression::types::DataType;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl JoinHashTable {
valids = Some(m.into());
break;
} else {
valids = combine_validities_3(valids, Some(bitmap.clone()));
valids = or_validities(valids, Some(bitmap.clone()));
}
}
Column::Null { .. } => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use common_arrow::arrow::bitmap::MutableBitmap;
use common_base::base::tokio::sync::Notify;
use common_exception::ErrorCode;
use common_exception::Result;
use common_expression::arrow::combine_validities_2;
use common_expression::arrow::and_validities;
use common_expression::DataBlock;
use common_expression::DataSchemaRef;
use common_expression::Evaluator;
Expand Down Expand Up @@ -274,7 +274,7 @@ impl JoinHashTable {
valids = Some(m.into());
break;
} else {
valids = combine_validities_2(valids, tmp_valids.cloned());
valids = and_validities(valids, tmp_valids.cloned());
}
}
probe_state.valids = valids;
Expand Down
26 changes: 13 additions & 13 deletions src/query/storages/common/index/src/range_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,7 @@ impl RangeFilter {
})
.unwrap();

Ok(Self {
schema,
expr: conjunction,
func_ctx: ctx.try_get_function_context()?,
})
}

pub fn try_eval_const(&self) -> Result<bool> {
let input_domains = self
.expr
let input_domains = conjunction
.column_refs()
.into_iter()
.map(|(name, ty)| {
Expand All @@ -76,11 +67,20 @@ impl RangeFilter {
})
.collect::<Result<_>>()?;

let folder = ConstantFolder::new(input_domains, self.func_ctx, &BUILTIN_FUNCTIONS);
let (new_expr, _) = folder.fold(&self.expr);
let func_ctx = ctx.try_get_function_context()?;
let folder = ConstantFolder::new(input_domains, func_ctx, &BUILTIN_FUNCTIONS);
let (new_expr, _) = folder.fold(&conjunction);

Ok(Self {
schema,
expr: new_expr,
func_ctx,
})
}

pub fn try_eval_const(&self) -> Result<bool> {
// Only return false, which means to skip this block, when the expression is folded to a constant false.
Ok(!matches!(new_expr, Expr::Constant {
Ok(!matches!(self.expr, Expr::Constant {
scalar: Scalar::Boolean(false),
..
}))
Expand Down
7 changes: 0 additions & 7 deletions src/query/storages/common/table-meta/src/meta/v2/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ pub struct BlockMeta {

#[serde(default)]
pub bloom_filter_index_size: u64,

/// Compression algo used to compress the columns of blocks
///
/// If not specified, the legacy algo `Lz4` will be used.
/// `Lz4` is merely for backward compatibility, it will NO longer be
/// used in the write path.
#[serde(default = "Compression::legacy")]
pub compression: Compression,
}

Expand Down