-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
2,579 additions
and
882 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::sync::Arc; | ||
|
||
use arrow_array::{ArrayRef as ArrowArrayRef, BooleanArray as ArrowBoolArray}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::bool::BoolArray; | ||
use crate::compute::as_arrow::AsArrowArray; | ||
use crate::validity::ArrayValidity; | ||
|
||
impl AsArrowArray for BoolArray<'_> { | ||
fn as_arrow(&self) -> VortexResult<ArrowArrayRef> { | ||
Ok(Arc::new(ArrowBoolArray::new( | ||
self.boolean_buffer().clone(), | ||
self.logical_validity().to_null_buffer()?, | ||
))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use arrow_buffer::BooleanBuffer; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::bool::BoolArray; | ||
use crate::compute::as_contiguous::AsContiguousFn; | ||
use crate::validity::Validity; | ||
use crate::{Array, ArrayTrait, IntoArray}; | ||
|
||
impl AsContiguousFn for BoolArray<'_> { | ||
fn as_contiguous(&self, arrays: &[Array]) -> VortexResult<Array<'static>> { | ||
let validity = if self.dtype().is_nullable() { | ||
Validity::from_iter(arrays.iter().map(|a| a.with_dyn(|a| a.logical_validity()))) | ||
} else { | ||
Validity::NonNullable | ||
}; | ||
|
||
let mut bools = Vec::with_capacity(arrays.iter().map(|a| a.len()).sum()); | ||
for buffer in arrays | ||
.iter() | ||
.map(|a| BoolArray::try_from(a.clone()).unwrap().boolean_buffer()) | ||
{ | ||
bools.extend(buffer.iter()) | ||
} | ||
|
||
Ok(BoolArray::try_new(BooleanBuffer::from(bools), validity)?.into_array()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use vortex_error::VortexResult; | ||
use vortex_schema::Nullability; | ||
|
||
use crate::array::bool::BoolArray; | ||
use crate::compute::fill::FillForwardFn; | ||
use crate::validity::ArrayValidity; | ||
use crate::{Array, ArrayTrait, IntoArray, ToArrayData}; | ||
|
||
impl FillForwardFn for BoolArray<'_> { | ||
fn fill_forward(&self) -> VortexResult<Array<'static>> { | ||
if self.dtype().nullability() == Nullability::NonNullable { | ||
return Ok(self.to_array_data().into_array()); | ||
} | ||
|
||
let validity = self.logical_validity().to_null_buffer()?.unwrap(); | ||
let bools = self.boolean_buffer(); | ||
let mut last_value = false; | ||
let filled = bools | ||
.iter() | ||
.zip(validity.inner().iter()) | ||
.map(|(v, valid)| { | ||
if valid { | ||
last_value = v; | ||
} | ||
last_value | ||
}) | ||
.collect::<Vec<_>>(); | ||
Ok(BoolArray::from(filled).into_array()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use crate::array::bool::BoolArray; | ||
use crate::validity::Validity; | ||
use crate::{compute, IntoArray}; | ||
|
||
#[test] | ||
fn fill_forward() { | ||
let barr = | ||
BoolArray::from_iter(vec![None, Some(false), None, Some(true), None]).into_array(); | ||
let filled_bool = BoolArray::try_from(compute::fill::fill_forward(&barr).unwrap()).unwrap(); | ||
assert_eq!( | ||
filled_bool.boolean_buffer().iter().collect::<Vec<bool>>(), | ||
vec![false, false, false, true, true] | ||
); | ||
assert_eq!(filled_bool.validity(), Validity::NonNullable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::array::bool::BoolArray; | ||
use crate::compute::as_arrow::AsArrowArray; | ||
use crate::compute::as_contiguous::AsContiguousFn; | ||
use crate::compute::fill::FillForwardFn; | ||
use crate::compute::scalar_at::ScalarAtFn; | ||
use crate::compute::take::TakeFn; | ||
use crate::compute::ArrayCompute; | ||
|
||
mod as_arrow; | ||
mod as_contiguous; | ||
mod fill; | ||
mod flatten; | ||
mod scalar_at; | ||
mod take; | ||
|
||
impl ArrayCompute for BoolArray<'_> { | ||
fn as_arrow(&self) -> Option<&dyn AsArrowArray> { | ||
Some(self) | ||
} | ||
|
||
fn as_contiguous(&self) -> Option<&dyn AsContiguousFn> { | ||
Some(self) | ||
} | ||
|
||
fn fill_forward(&self) -> Option<&dyn FillForwardFn> { | ||
Some(self) | ||
} | ||
|
||
fn scalar_at(&self) -> Option<&dyn ScalarAtFn> { | ||
Some(self) | ||
} | ||
|
||
fn take(&self) -> Option<&dyn TakeFn> { | ||
Some(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use vortex::scalar::{BoolScalar, Scalar}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::bool::BoolArray; | ||
use crate::compute::scalar_at::ScalarAtFn; | ||
use crate::validity::ArrayValidity; | ||
use crate::ArrayTrait; | ||
|
||
impl ScalarAtFn for BoolArray<'_> { | ||
fn scalar_at(&self, index: usize) -> VortexResult<Scalar> { | ||
Ok(BoolScalar::try_new( | ||
self.is_valid(index) | ||
.then(|| self.boolean_buffer().value(index)), | ||
self.dtype().nullability(), | ||
) | ||
.unwrap() | ||
.into()) | ||
} | ||
} |
Oops, something went wrong.