Skip to content

Commit

Permalink
trying to rm box_chunk_to_arc_chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
dantengsky committed Feb 23, 2022
1 parent 2456f73 commit 71e3fef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion common/datablocks/src/data_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ impl DataBlock {
Ok(Self { columns, schema })
}

pub fn from_chunk(schema: &DataSchemaRef, chuck: &Chunk<ArrayRef>) -> Result<DataBlock> {
pub fn from_chunk<A>(schema: &DataSchemaRef, chuck: &Chunk<A>) -> Result<DataBlock>
where A: AsRef<dyn Array> {
let columns = chuck
.columns()
.iter()
Expand Down
39 changes: 24 additions & 15 deletions common/datavalues/src/columns/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::any::Any;
use std::sync::Arc;

use common_arrow::arrow::array::Array;
use common_arrow::arrow::array::ArrayRef;
use common_arrow::arrow::bitmap::Bitmap;
use common_arrow::arrow::bitmap::MutableBitmap;
Expand Down Expand Up @@ -151,21 +152,29 @@ pub trait IntoColumn {
fn into_nullable_column(self) -> ColumnRef;
}

impl IntoColumn for &ArrayRef {
fn into_column(self) -> ColumnRef {
IntoColumn::into_column(self.clone())
}

fn into_nullable_column(self) -> ColumnRef {
IntoColumn::into_nullable_column(self.clone())
}
}

//impl IntoColumn for &ArrayRef {
// impl IntoColumn for &ArrayRef {
// fn into_column(self) -> ColumnRef {
// IntoColumn::into_column(self.clone())
// }
//
// fn into_nullable_column(self) -> ColumnRef {
// IntoColumn::into_nullable_column(self.clone())
// }
//}

//pub struct Chunk<A: AsRef<dyn Array>> {
// arrays: Vec<A>,
//}
//pub type ArrayRef = Arc<dyn Array>;
//impl<A: AsRef<dyn Array>> IntoColumn for A {
impl IntoColumn for ArrayRef {
//impl IntoColumn for ArrayRef {
impl<A> IntoColumn for A
where A: AsRef<dyn Array>
{
fn into_column(self) -> ColumnRef {
use TypeID::*;
let data_type: DataTypePtr = from_arrow_type(self.data_type());
let data_type: DataTypePtr = from_arrow_type(self.as_ref().data_type());
match data_type.data_type_id() {
// arrow type has no nullable type
Nullable => unimplemented!(),
Expand All @@ -191,9 +200,9 @@ impl IntoColumn for ArrayRef {
}

fn into_nullable_column(self) -> ColumnRef {
let size = self.len();
let validity = self.validity().cloned();
let column = self.into_column();
let size = self.as_ref().len();
let validity = self.as_ref().validity().cloned();
let column = self.as_ref().into_column();
Arc::new(NullableColumn::new(
column,
validity.unwrap_or_else(|| {
Expand Down
2 changes: 0 additions & 2 deletions common/streams/src/stream_limit_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use common_arrow::arrow;
use common_arrow::arrow::array::BooleanArray;
use common_arrow::arrow::bitmap::MutableBitmap;
use common_arrow::arrow::datatypes::DataType as ArrowType;
use common_datablocks::box_chunk_to_arc_chunk;
use common_datablocks::DataBlock;
use common_datablocks::HashMethod;
use common_datablocks::HashMethodSerializer;
Expand Down Expand Up @@ -75,7 +74,6 @@ impl LimitByStream {
let array = BooleanArray::from_data(ArrowType::Boolean, filter.into(), None);
let chunk = block.clone().try_into()?;
let chunk = arrow::compute::filter::filter_chunk(&chunk, &array)?;
let chunk = box_chunk_to_arc_chunk(chunk);
Some(DataBlock::from_chunk(block.schema(), &chunk)).transpose()
}
}
Expand Down

0 comments on commit 71e3fef

Please sign in to comment.