Skip to content

Commit

Permalink
Merge pull request #9565 from sundy-li/expression-index1
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored Jan 11, 2023
2 parents a012c25 + b89fb6e commit cd1c663
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
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

1 comment on commit cd1c663

@vercel
Copy link

@vercel vercel bot commented on cd1c663 Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend.vercel.app
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs

Please sign in to comment.