-
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.
Array2: swap trait for struct with lifetime (#215)
Now we have an Array<'a> enum, we can swap out the array trait and things get a little simpler.
- Loading branch information
Showing
12 changed files
with
266 additions
and
349 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
use vortex::scalar::Scalar; | ||
use vortex::scalar::{BoolScalar, Scalar}; | ||
use vortex_error::VortexResult; | ||
|
||
use crate::array::bool::BoolArray; | ||
use crate::compute::{ArrayCompute, ScalarAtFn}; | ||
use crate::validity::ArrayValidity; | ||
use crate::ArrayTrait; | ||
|
||
impl ArrayCompute for &dyn BoolArray { | ||
impl ArrayCompute for BoolArray<'_> { | ||
fn scalar_at(&self) -> Option<&dyn ScalarAtFn> { | ||
Some(self) | ||
} | ||
} | ||
|
||
impl ScalarAtFn for &dyn BoolArray { | ||
fn scalar_at(&self, _index: usize) -> VortexResult<Scalar> { | ||
todo!() | ||
impl ScalarAtFn for BoolArray<'_> { | ||
fn scalar_at(&self, index: usize) -> VortexResult<Scalar> { | ||
if self.is_valid(index) { | ||
let value = self.boolean_buffer().value(index); | ||
Ok(Scalar::Bool( | ||
BoolScalar::try_new(Some(value), self.dtype().nullability()).unwrap(), | ||
)) | ||
} else { | ||
Ok(Scalar::null(self.dtype())) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.