diff --git a/Cargo.lock b/Cargo.lock index f8655eabd77c..b3c0f1627489 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,7 +527,7 @@ dependencies = [ [[package]] name = "arrow2" version = "0.17.4" -source = "git+https://github.com/jorgecarleitao/arrow2?rev=dd80c89#dd80c891850213104c8c0d11b76b56401cb1ce52" +source = "git+https://github.com/jorgecarleitao/arrow2?rev=3c61372#3c61372d7ac76bba149316b1fbad6e981752e502" dependencies = [ "ahash 0.8.3", "arrow-array", diff --git a/Cargo.toml b/Cargo.toml index 8b6b745d987c..0a9039cc699c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -248,7 +248,7 @@ rpath = false [patch.crates-io] # If there are dependencies that need patching, they can be listed below. -arrow2 = { git = "https://github.com/jorgecarleitao/arrow2", rev = "dd80c89" } +arrow2 = { git = "https://github.com/jorgecarleitao/arrow2", rev = "3c61372" } arrow-format = { git = "https://github.com/everpcpc/arrow-format", rev = "588d371" } parquet2 = { git = "https://github.com/jorgecarleitao/parquet2", rev = "b0e6545" } metrics = { git = "https://github.com/datafuse-extras/metrics.git", rev = "fc2ecd1" } diff --git a/src/query/expression/src/evaluator.rs b/src/query/expression/src/evaluator.rs index 265922bf829a..60f4e27dc2fd 100644 --- a/src/query/expression/src/evaluator.rs +++ b/src/query/expression/src/evaluator.rs @@ -40,7 +40,6 @@ use crate::types::BooleanType; use crate::types::DataType; use crate::types::NullableType; use crate::udf_client::UDFFlightClient; -use crate::utils::arrow::constant_bitmap; use crate::utils::variant_transform::contains_variant; use crate::utils::variant_transform::transform_variant; use crate::values::Column; @@ -420,7 +419,7 @@ impl<'a> Evaluator<'a> { .into_column() .unwrap(); Ok(Value::Column(Column::Nullable(Box::new(NullableColumn { - validity: constant_bitmap(true, column.len()).into(), + validity: Bitmap::new_constant(true, column.len()), column, })))) } @@ -442,11 +441,8 @@ impl<'a> Evaluator<'a> { }, (DataType::Array(inner_src_ty), DataType::Array(inner_dest_ty)) => match value { Value::Scalar(Scalar::Array(array)) => { - let validity = validity.map(|validity| { - let mut inner_validity = MutableBitmap::with_capacity(array.len()); - inner_validity.extend_constant(array.len(), validity.get_bit(0)); - inner_validity.into() - }); + let validity = validity + .map(|validity| Bitmap::new_constant(validity.get_bit(0), array.len())); let new_array = self .run_cast( @@ -505,11 +501,8 @@ impl<'a> Evaluator<'a> { }, (DataType::Map(inner_src_ty), DataType::Map(inner_dest_ty)) => match value { Value::Scalar(Scalar::Map(array)) => { - let validity = validity.map(|validity| { - let mut inner_validity = MutableBitmap::with_capacity(array.len()); - inner_validity.extend_constant(array.len(), validity.get_bit(0)); - inner_validity.into() - }); + let validity = validity + .map(|validity| Bitmap::new_constant(validity.get_bit(0), array.len())); let new_array = self .run_cast( @@ -524,11 +517,8 @@ impl<'a> Evaluator<'a> { Ok(Value::Scalar(Scalar::Map(new_array))) } Value::Column(Column::Map(col)) => { - let validity = validity.map(|validity| { - let mut inner_validity = MutableBitmap::with_capacity(col.len()); - inner_validity.extend_constant(col.len(), validity.get_bit(0)); - inner_validity.into() - }); + let validity = validity + .map(|validity| Bitmap::new_constant(validity.get_bit(0), col.len())); let new_col = self .run_cast( @@ -654,7 +644,7 @@ impl<'a> Evaluator<'a> { Value::Scalar(_) => Ok(value), Value::Column(column) => { Ok(Value::Column(Column::Nullable(Box::new(NullableColumn { - validity: constant_bitmap(true, column.len()).into(), + validity: Bitmap::new_constant(true, column.len()), column, })))) } @@ -692,7 +682,7 @@ impl<'a> Evaluator<'a> { offsets: col.offsets, })); Ok(Value::Column(Column::Nullable(Box::new(NullableColumn { - validity: constant_bitmap(true, new_col.len()).into(), + validity: Bitmap::new_constant(true, new_col.len()), column: new_col, })))) } @@ -730,7 +720,7 @@ impl<'a> Evaluator<'a> { offsets: col.offsets, })); Ok(Value::Column(Column::Nullable(Box::new(NullableColumn { - validity: constant_bitmap(true, new_col.len()).into(), + validity: Bitmap::new_constant(true, new_col.len()), column: new_col, })))) } @@ -848,7 +838,7 @@ impl<'a> Evaluator<'a> { }); // Evaluate the condition first and then partially evaluate the result branches. - let mut validity = validity.unwrap_or_else(|| constant_bitmap(true, num_rows).into()); + let mut validity = validity.unwrap_or_else(|| Bitmap::new_constant(true, num_rows)); let mut conds = Vec::new(); let mut flags = Vec::new(); let mut results = Vec::new(); @@ -857,12 +847,12 @@ impl<'a> Evaluator<'a> { match cond.try_downcast::>().unwrap() { Value::Scalar(None | Some(false)) => { results.push(Value::Scalar(Scalar::default_value(&generics[0]))); - flags.push(constant_bitmap(false, len.unwrap_or(1)).into()); + flags.push(Bitmap::new_constant(false, len.unwrap_or(1))); } Value::Scalar(Some(true)) => { results.push(self.partial_run(&args[cond_idx + 1], Some(validity.clone()))?); - validity = constant_bitmap(false, num_rows).into(); - flags.push(constant_bitmap(true, len.unwrap_or(1)).into()); + validity = Bitmap::new_constant(false, num_rows); + flags.push(Bitmap::new_constant(true, len.unwrap_or(1))); break; } Value::Column(cond) => { diff --git a/src/query/expression/src/function.rs b/src/query/expression/src/function.rs index e5b8ec3daca0..5b614705c99f 100755 --- a/src/query/expression/src/function.rs +++ b/src/query/expression/src/function.rs @@ -36,7 +36,6 @@ use crate::type_check::try_unify_signature; use crate::types::nullable::NullableColumn; use crate::types::nullable::NullableDomain; use crate::types::*; -use crate::utils::arrow::constant_bitmap; use crate::values::Value; use crate::values::ValueRef; use crate::Column; @@ -258,7 +257,7 @@ impl Function { Value::Column(column) => { Value::Column(Column::Nullable(Box::new(NullableColumn { column, - validity: constant_bitmap(true, num_rows).into(), + validity: Bitmap::new_constant(true, num_rows), }))) } } @@ -550,7 +549,7 @@ impl<'a> EvalContext<'a> { valids.set(row, false); } None => { - let mut valids = constant_bitmap(true, self.num_rows.max(1)); + let mut valids = Bitmap::new_constant(true, self.num_rows.max(1)).make_mut(); valids.set(row, false); self.errors = Some((valids, error_msg.into())); } @@ -628,7 +627,7 @@ where F: Fn(&[ValueRef], &mut EvalContext) -> Value { } } let results = f(&nonull_args, ctx); - let bitmap = bitmap.unwrap_or_else(|| constant_bitmap(true, len)); + let bitmap = bitmap.unwrap_or_else(|| Bitmap::new_constant(true, len).make_mut()); if let Some((error_bitmap, _)) = ctx.errors.as_mut() { // If the original value is NULL, we can ignore the error. let rhs: Bitmap = bitmap.clone().not().into(); @@ -690,7 +689,7 @@ pub fn error_to_null( Value::Scalar(scalar) => Value::Scalar(Some(scalar)), Value::Column(column) => Value::Column(NullableColumn { column, - validity: constant_bitmap(true, ctx.num_rows).into(), + validity: Bitmap::new_constant(true, ctx.num_rows), }), } } diff --git a/src/query/expression/src/utils/arrow.rs b/src/query/expression/src/utils/arrow.rs index a06b949da51f..3187c7b92574 100644 --- a/src/query/expression/src/utils/arrow.rs +++ b/src/query/expression/src/utils/arrow.rs @@ -53,12 +53,6 @@ pub fn append_bitmap(bitmap: &mut MutableBitmap, other: &Bitmap) { bitmap.extend_from_bitmap(other) } -pub fn constant_bitmap(value: bool, len: usize) -> MutableBitmap { - let mut builder = MutableBitmap::new(); - builder.extend_constant(len, value); - builder -} - pub fn buffer_into_mut(mut buffer: Buffer) -> Vec { unsafe { buffer diff --git a/src/query/expression/src/values.rs b/src/query/expression/src/values.rs index c6adacf46555..226a31924256 100755 --- a/src/query/expression/src/values.rs +++ b/src/query/expression/src/values.rs @@ -75,7 +75,6 @@ use crate::types::*; use crate::utils::arrow::append_bitmap; use crate::utils::arrow::bitmap_into_mut; use crate::utils::arrow::buffer_into_mut; -use crate::utils::arrow::constant_bitmap; use crate::utils::arrow::deserialize_column; use crate::utils::arrow::serialize_column; use crate::utils::FromData; @@ -1626,11 +1625,10 @@ impl Column { }; if is_nullable { - let validity = arrow_col.validity().cloned().unwrap_or_else(|| { - let mut validity = MutableBitmap::with_capacity(arrow_col.len()); - validity.extend_constant(arrow_col.len(), true); - validity.into() - }); + let validity = arrow_col + .validity() + .cloned() + .unwrap_or_else(|| Bitmap::new_constant(true, arrow_col.len())); Column::Nullable(Box::new(NullableColumn { column, validity })) } else { column @@ -1774,11 +1772,7 @@ impl Column { })) } _ => { - let validity = validity.unwrap_or_else(|| { - let mut validity = MutableBitmap::with_capacity(self.len()); - validity.extend_constant(self.len(), true); - validity.into() - }); + let validity = validity.unwrap_or_else(|| Bitmap::new_constant(true, self.len())); Column::Nullable(Box::new(NullableColumn { column: self.clone(), validity, @@ -1935,7 +1929,7 @@ impl ColumnBuilder { } return ColumnBuilder::Nullable(Box::new(NullableColumnBuilder { builder, - validity: constant_bitmap(true, n), + validity: Bitmap::new_constant(true, n).make_mut(), })); } } @@ -1950,7 +1944,7 @@ impl ColumnBuilder { } ColumnBuilder::Nullable(Box::new(NullableColumnBuilder { builder, - validity: constant_bitmap(false, n), + validity: Bitmap::new_constant(false, n).make_mut(), })) } _ => unreachable!(), @@ -1961,7 +1955,7 @@ impl ColumnBuilder { ScalarRef::Decimal(dec) => { ColumnBuilder::Decimal(DecimalColumnBuilder::repeat(*dec, n)) } - ScalarRef::Boolean(b) => ColumnBuilder::Boolean(constant_bitmap(*b, n)), + ScalarRef::Boolean(b) => ColumnBuilder::Boolean(Bitmap::new_constant(*b, n).make_mut()), ScalarRef::String(s) => ColumnBuilder::String(StringColumnBuilder::repeat(s, n)), ScalarRef::Timestamp(d) => ColumnBuilder::Timestamp(vec![*d; n]), ScalarRef::Date(d) => ColumnBuilder::Date(vec![*d; n]), diff --git a/src/query/formats/tests/it/output_format_utils.rs b/src/query/formats/tests/it/output_format_utils.rs index e5fe86b9d06f..be0d6b773a3d 100644 --- a/src/query/formats/tests/it/output_format_utils.rs +++ b/src/query/formats/tests/it/output_format_utils.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_arrow::arrow::bitmap::MutableBitmap; +use common_arrow::arrow::bitmap::Bitmap; use common_expression::types::nullable::NullableColumn; use common_expression::types::number::Float64Type; use common_expression::types::number::Int32Type; @@ -72,12 +72,11 @@ pub fn get_simple_block(is_nullable: bool) -> (TableSchemaRef, DataBlock) { .into_iter() .enumerate() .map(|(idx, (data_type, c))| { - let mut validity = MutableBitmap::new(); - validity.extend_constant(c.len(), true); + let validity = Bitmap::new_constant(true, c.len()); ( Column::Nullable(Box::new(NullableColumn { column: c, - validity: validity.into(), + validity, })), TableField::new(&format!("c{}", idx + 1), data_type.wrap_nullable()), ) diff --git a/src/query/functions/src/scalars/arithmetic.rs b/src/query/functions/src/scalars/arithmetic.rs index 6238364b4881..072b6df411cd 100644 --- a/src/query/functions/src/scalars/arithmetic.rs +++ b/src/query/functions/src/scalars/arithmetic.rs @@ -19,6 +19,7 @@ use std::ops::BitOr; use std::ops::BitXor; use std::sync::Arc; +use common_arrow::arrow::bitmap::Bitmap; use common_expression::types::decimal::Decimal; use common_expression::types::decimal::DecimalColumn; use common_expression::types::decimal::DecimalDomain; @@ -44,7 +45,6 @@ use common_expression::types::ALL_NUMERICS_TYPES; use common_expression::types::ALL_UNSIGNED_INTEGER_TYPES; use common_expression::utils::arithmetics_type::ResultTypeOfBinary; use common_expression::utils::arithmetics_type::ResultTypeOfUnary; -use common_expression::utils::arrow::constant_bitmap; use common_expression::values::Value; use common_expression::values::ValueRef; use common_expression::vectorize_1_arg; @@ -885,7 +885,7 @@ pub fn register_number_to_string(registry: &mut FunctionRegistry) { let result = builder.build(); Value::Column(NullableColumn { column: result, - validity: constant_bitmap(true, from.len()).into(), + validity: Bitmap::new_constant(true, from.len()), }) } }, diff --git a/src/query/functions/src/scalars/datetime.rs b/src/query/functions/src/scalars/datetime.rs index c822f4c11063..c832f597ed2a 100644 --- a/src/query/functions/src/scalars/datetime.rs +++ b/src/query/functions/src/scalars/datetime.rs @@ -18,6 +18,7 @@ use chrono::prelude::*; use chrono::Datelike; use chrono::Utc; use chrono_tz::Tz; +use common_arrow::arrow::bitmap::Bitmap; use common_arrow::arrow::temporal_conversions::EPOCH_DAYS_FROM_CE; use common_expression::error_to_null; use common_expression::types::date::check_date; @@ -45,7 +46,6 @@ use common_expression::types::NullableType; use common_expression::types::NumberType; use common_expression::types::StringType; use common_expression::types::TimestampType; -use common_expression::utils::arrow::constant_bitmap; use common_expression::utils::date_helper::*; use common_expression::vectorize_1_arg; use common_expression::vectorize_2_arg; @@ -531,7 +531,7 @@ fn register_to_number(registry: &mut FunctionRegistry) { |val, _| match val { ValueRef::Scalar(scalar) => Value::Scalar(Some(scalar as i64)), ValueRef::Column(col) => Value::Column(NullableColumn { - validity: constant_bitmap(true, col.len()).into(), + validity: Bitmap::new_constant(true, col.len()), column: col.iter().map(|val| *val as i64).collect(), }), }, @@ -548,7 +548,7 @@ fn register_to_number(registry: &mut FunctionRegistry) { |val, _| match val { ValueRef::Scalar(scalar) => Value::Scalar(Some(scalar)), ValueRef::Column(col) => Value::Column(NullableColumn { - validity: constant_bitmap(true, col.len()).into(), + validity: Bitmap::new_constant(true, col.len()), column: col, }), }, diff --git a/src/query/functions/src/scalars/variant.rs b/src/query/functions/src/scalars/variant.rs index 1f6bd1adfb1c..ad7b8ee6c5ef 100644 --- a/src/query/functions/src/scalars/variant.rs +++ b/src/query/functions/src/scalars/variant.rs @@ -17,6 +17,7 @@ use std::sync::Arc; use bstr::ByteSlice; use chrono::Datelike; +use common_arrow::arrow::bitmap::Bitmap; use common_arrow::arrow::temporal_conversions::EPOCH_DAYS_FROM_CE; use common_expression::types::date::string_to_date; use common_expression::types::nullable::NullableColumn; @@ -38,7 +39,6 @@ use common_expression::types::StringType; use common_expression::types::TimestampType; use common_expression::types::VariantType; use common_expression::types::ALL_NUMERICS_TYPES; -use common_expression::utils::arrow::constant_bitmap; use common_expression::vectorize_1_arg; use common_expression::vectorize_with_builder_1_arg; use common_expression::vectorize_with_builder_2_arg; @@ -649,7 +649,7 @@ pub fn register(registry: &mut FunctionRegistry) { ValueRef::Column(col) => { let new_col = cast_scalars_to_variants(col.iter(), ctx.func_ctx.tz); Value::Column(NullableColumn { - validity: constant_bitmap(true, new_col.len()).into(), + validity: Bitmap::new_constant(true, new_col.len()), column: new_col, }) } diff --git a/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs b/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs index 7a44d1cfcdd3..a8e49f7758c9 100644 --- a/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs +++ b/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs @@ -15,7 +15,6 @@ use common_arrow::arrow::bitmap::Bitmap; use common_arrow::arrow::bitmap::MutableBitmap; use common_exception::Result; -use common_expression::arrow::constant_bitmap; use common_expression::arrow::or_validities; use common_expression::types::nullable::NullableColumn; use common_expression::types::AnyType; @@ -132,7 +131,7 @@ impl HashJoinProbeState { match filter_vector { Column::Nullable(_) => Ok(filter_vector), other => Ok(Column::Nullable(Box::new(NullableColumn { - validity: constant_bitmap(true, other.len()).into(), + validity: Bitmap::new_constant(true, other.len()), column: other, }))), } @@ -156,9 +155,7 @@ impl HashJoinState { Column::Nullable(c) => { let bitmap = &c.validity; if bitmap.unset_bits() == 0 { - let mut m = MutableBitmap::with_capacity(num_rows); - m.extend_constant(num_rows, true); - valids = Some(m.into()); + valids = Some(Bitmap::new_constant(true, num_rows)); break; } else { valids = or_validities(valids, Some(bitmap.clone())); @@ -166,9 +163,7 @@ impl HashJoinState { } Column::Null { .. } => {} _c => { - let mut m = MutableBitmap::with_capacity(num_rows); - m.extend_constant(num_rows, true); - valids = Some(m.into()); + valids = Some(Bitmap::new_constant(true, num_rows)); break; } } diff --git a/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs b/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs index c74f537cb90f..276662f17712 100644 --- a/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs +++ b/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_build_state.rs @@ -20,7 +20,6 @@ use std::sync::atomic::Ordering; use std::sync::Arc; use common_arrow::arrow::bitmap::Bitmap; -use common_arrow::arrow::bitmap::MutableBitmap; use common_base::base::tokio::sync::Barrier; use common_catalog::table_context::TableContext; use common_exception::ErrorCode; @@ -168,9 +167,7 @@ impl HashJoinBuildState { self.hash_join_state.hash_join_desc.join_type, JoinType::Left | JoinType::LeftSingle | JoinType::Full ) { - let mut validity = MutableBitmap::new(); - validity.extend_constant(data_block.num_rows(), true); - let validity: Bitmap = validity.into(); + let validity = Bitmap::new_constant(true, data_block.num_rows()); let nullable_columns = data_block .columns() .iter() diff --git a/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_probe_state.rs b/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_probe_state.rs index 973fe50b3372..22a2e227a4c6 100644 --- a/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_probe_state.rs +++ b/src/query/service/src/pipelines/processors/transforms/hash_join/hash_join_probe_state.rs @@ -18,6 +18,7 @@ use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Arc; +use common_arrow::arrow::bitmap::Bitmap; use common_arrow::arrow::bitmap::MutableBitmap; use common_base::base::tokio::sync::Barrier; use common_catalog::table_context::TableContext; @@ -216,9 +217,7 @@ impl HashJoinProbeState { for (col, _) in probe_keys.iter() { let (is_all_null, tmp_valids) = col.validity(); if is_all_null { - let mut m = MutableBitmap::with_capacity(input.num_rows()); - m.extend_constant(input.num_rows(), false); - valids = Some(m.into()); + valids = Some(Bitmap::new_constant(false, input.num_rows())); break; } else { valids = and_validities(valids, tmp_valids.cloned()); diff --git a/src/query/service/src/pipelines/processors/transforms/hash_join/probe_state.rs b/src/query/service/src/pipelines/processors/transforms/hash_join/probe_state.rs index 9d0d53907172..655d18e4d844 100644 --- a/src/query/service/src/pipelines/processors/transforms/hash_join/probe_state.rs +++ b/src/query/service/src/pipelines/processors/transforms/hash_join/probe_state.rs @@ -13,7 +13,6 @@ // limitations under the License. use common_arrow::arrow::bitmap::Bitmap; -use common_arrow::arrow::bitmap::MutableBitmap; use common_expression::FunctionContext; use common_hashtable::RowPtr; @@ -52,9 +51,7 @@ impl ProbeState { has_string_column: bool, func_ctx: FunctionContext, ) -> Self { - let mut true_validity = MutableBitmap::new(); - true_validity.extend_constant(max_block_size, true); - let true_validity: Bitmap = true_validity.into(); + let true_validity = Bitmap::new_constant(true, max_block_size); let (row_state, row_state_indexes, probe_unmatched_indexes) = match &join_type { JoinType::Left | JoinType::LeftSingle | JoinType::Full => { if with_conjunct { diff --git a/src/query/service/src/pipelines/processors/transforms/range_join/ie_join_state.rs b/src/query/service/src/pipelines/processors/transforms/range_join/ie_join_state.rs index 61ea84e06ccf..9c18e76253bc 100644 --- a/src/query/service/src/pipelines/processors/transforms/range_join/ie_join_state.rs +++ b/src/query/service/src/pipelines/processors/transforms/range_join/ie_join_state.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_arrow::arrow::bitmap::Bitmap; use common_arrow::arrow::bitmap::MutableBitmap; use common_catalog::table_context::TableContext; use common_exception::Result; @@ -265,8 +266,7 @@ impl RangeJoinState { } } // Initialize bit_array - let mut bit_array = MutableBitmap::with_capacity(p_array.len()); - bit_array.extend_constant(p_array.len(), false); + let bit_array = Bitmap::new_constant(false, p_array.len()).make_mut(); let l2 = &merged_blocks.columns()[1].value.convert_to_full_column( self.conditions[0] diff --git a/src/query/service/tests/it/servers/http/json_block.rs b/src/query/service/tests/it/servers/http/json_block.rs index 5e4d8fd3e6b9..f76b21090cdd 100644 --- a/src/query/service/tests/it/servers/http/json_block.rs +++ b/src/query/service/tests/it/servers/http/json_block.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_arrow::arrow::bitmap::MutableBitmap; +use common_arrow::arrow::bitmap::Bitmap; use common_exception::Result; use common_expression::types::nullable::NullableColumn; use common_expression::types::number::Float64Type; @@ -69,12 +69,9 @@ fn test_data_block(is_nullable: bool) -> Result<()> { columns = columns .iter() .map(|c| { - let mut validity = MutableBitmap::new(); - validity.extend_constant(c.len(), true); - Column::Nullable(Box::new(NullableColumn { column: c.clone(), - validity: validity.into(), + validity: Bitmap::new_constant(true, c.len()), })) }) .collect(); diff --git a/src/query/storages/parquet/src/parquet_rs/parquet_reader/topk.rs b/src/query/storages/parquet/src/parquet_rs/parquet_reader/topk.rs index dea456696249..dd65d061df88 100644 --- a/src/query/storages/parquet/src/parquet_rs/parquet_reader/topk.rs +++ b/src/query/storages/parquet/src/parquet_rs/parquet_reader/topk.rs @@ -15,7 +15,6 @@ use std::sync::Arc; use common_arrow::arrow::bitmap::Bitmap; -use common_arrow::arrow::bitmap::MutableBitmap; use common_catalog::plan::TopK; use common_exception::Result; use common_expression::Column; @@ -63,8 +62,8 @@ impl ParquetTopK { pub fn evaluate_column(&self, column: &Column, sorter: &mut TopKSorter) -> Bitmap { let num_rows = column.len(); - let mut bitmap = MutableBitmap::with_capacity(num_rows); - bitmap.extend_constant(num_rows, true); + let bitmap = Bitmap::new_constant(true, num_rows); + let mut bitmap = bitmap.make_mut(); sorter.push_column(column, &mut bitmap); bitmap.into() }