Skip to content

Commit

Permalink
Revert "chore(query): add more asserts (#16536)"
Browse files Browse the repository at this point in the history
This reverts commit c6bd10b.
  • Loading branch information
zhang2014 committed Oct 8, 2024
1 parent 039d06b commit e7ce5fe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/query/catalog/src/plan/stream_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ impl StreamColumnMeta {
}

pub fn build_origin_block_row_num(num_rows: usize) -> BlockEntry {
let row_ids = (0..num_rows as u64).collect();
let mut row_ids = Vec::with_capacity(num_rows);
for i in 0..num_rows {
row_ids.push(i as u64);
}
let column = Value::Column(UInt64Type::from_data(row_ids));

BlockEntry::new(
Expand Down
14 changes: 2 additions & 12 deletions src/query/expression/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl DataBlock {
num_rows: usize,
meta: Option<BlockMetaInfoPtr>,
) -> Self {
#[cfg(debug_assertions)]
Self::check_columns_valid(&columns, num_rows).unwrap();

Self {
Expand All @@ -129,7 +130,6 @@ impl DataBlock {
fn check_columns_valid(columns: &[BlockEntry], num_rows: usize) -> Result<()> {
for entry in columns.iter() {
if let Value::Column(c) = &entry.value {
#[cfg(debug_assertions)]
c.check_valid()?;
if c.len() != num_rows {
return Err(ErrorCode::Internal(format!(
Expand Down Expand Up @@ -264,12 +264,6 @@ impl DataBlock {
}

pub fn slice(&self, range: Range<usize>) -> Self {
assert!(
range.end <= self.num_rows(),
"range {:?} out of len {}",
range,
self.num_rows()
);
let columns = self
.columns()
.iter()
Expand All @@ -285,11 +279,7 @@ impl DataBlock {
.collect();
Self {
columns,
num_rows: if range.is_empty() {
0
} else {
range.end - range.start
},
num_rows: range.end - range.start,
meta: self.meta.clone(),
}
}
Expand Down
13 changes: 1 addition & 12 deletions src/query/expression/src/kernels/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ struct FilterVisitor<'a> {
filter: &'a Bitmap,
result: Option<Value<AnyType>>,
num_rows: usize,
original_rows: usize,
}

impl<'a> FilterVisitor<'a> {
Expand All @@ -122,7 +121,6 @@ impl<'a> FilterVisitor<'a> {
filter,
result: None,
num_rows,
original_rows: filter.len(),
}
}
}
Expand All @@ -132,8 +130,6 @@ impl<'a> ValueVisitor for FilterVisitor<'a> {
match value {
Value::Scalar(c) => self.visit_scalar(c),
Value::Column(c) => {
assert!(c.len() == self.original_rows);

if c.len() == self.num_rows || c.len() == 0 {
self.result = Some(Value::Column(c));
} else if self.num_rows == 0 {
Expand Down Expand Up @@ -259,14 +255,7 @@ impl<'a> ValueVisitor for FilterVisitor<'a> {
Ok(())
}

fn visit_boolean(&mut self, mut bitmap: Bitmap) -> Result<()> {
// faster path for all bits set
if bitmap.unset_bits() == 0 {
bitmap.slice(0, self.num_rows);
self.result = Some(Value::Column(BooleanType::upcast_column(bitmap)));
return Ok(());
}

fn visit_boolean(&mut self, bitmap: Bitmap) -> Result<()> {
let capacity = self.num_rows.saturating_add(7) / 8;
let mut builder: Vec<u8> = Vec::with_capacity(capacity);
let mut builder_ptr = builder.as_mut_ptr();
Expand Down
2 changes: 0 additions & 2 deletions src/query/expression/src/kernels/sort_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ impl ValueVisitor for SortCompare {
// faster path for numeric
fn visit_number<T: Number>(&mut self, column: Buffer<T>) -> Result<()> {
let values = column.as_slice();
assert!(values.len() == self.rows);
self.generic_sort(values, |c, idx| c[idx as usize], |a: T, b: T| a.cmp(&b));
Ok(())
}
Expand All @@ -277,7 +276,6 @@ impl ValueVisitor for SortCompare {
}

fn visit_typed_column<T: ValueType>(&mut self, col: T::Column) -> Result<()> {
assert!(T::column_len(&col) == self.rows);
self.generic_sort(
&col,
|c, idx| -> T::ScalarRef<'_> { unsafe { T::index_column_unchecked(c, idx as _) } },
Expand Down

0 comments on commit e7ce5fe

Please sign in to comment.