Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make unary functions nicer to use #493

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion encodings/alp/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::{Array, IntoArray};
use vortex_error::VortexResult;
Expand Down
5 changes: 2 additions & 3 deletions encodings/byte-bool/src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::sync::Arc;

use arrow_buffer::BooleanBuffer;
use num_traits::AsPrimitive;
use vortex::compute::unary::fill_forward::FillForwardFn;
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::unary::{FillForwardFn, ScalarAtFn};
use vortex::compute::{ArrayCompute, CompareFn, SliceFn, TakeFn};
use vortex::encoding::ArrayEncodingRef;
use vortex::stats::StatsSet;
Expand Down Expand Up @@ -182,7 +181,7 @@ impl FillForwardFn for ByteBoolArray {

#[cfg(test)]
mod tests {
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::compute::{compare, slice};
use vortex::AsArray as _;

Expand Down
2 changes: 1 addition & 1 deletion encodings/datetime-parts/src/compress.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use vortex::array::datetime::{TemporalArray, TimeUnit};
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::cast::try_cast;
use vortex::compute::unary::try_cast;
use vortex::{Array, IntoArray, IntoArrayVariant};
use vortex_dtype::PType;
use vortex_error::{vortex_bail, VortexResult};
Expand Down
2 changes: 1 addition & 1 deletion encodings/datetime-parts/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use vortex::array::datetime::temporal::TemporalMetadata;
use vortex::array::datetime::{TemporalArray, TimeUnit};
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::validity::ArrayValidity;
use vortex::{Array, ArrayDType, IntoArray, IntoArrayVariant};
Expand Down
2 changes: 1 addition & 1 deletion encodings/dict/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ mod test {
use vortex::accessor::ArrayAccessor;
use vortex::array::primitive::PrimitiveArray;
use vortex::array::varbin::VarBinArray;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::ToArray;
use vortex_dtype::Nullability::Nullable;
use vortex_dtype::{DType, PType};
Expand Down
2 changes: 1 addition & 1 deletion encodings/dict/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::{Array, IntoArray};
use vortex_error::VortexResult;
Expand Down
2 changes: 1 addition & 1 deletion encodings/dict/src/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use vortex::accessor::ArrayAccessor;
use vortex::array::bool::BoolArray;
use vortex::compute::take;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::stats::StatsSet;
use vortex::validity::{ArrayValidity, LogicalValidity};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/bitpacking/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{ArrayCompute, SearchSortedFn, SliceFn, TakeFn};
use vortex::ArrayDType;
use vortex_error::{vortex_err, VortexResult};
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/bitpacking/compute/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl SliceFn for BitPackedArray {
mod test {
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::slice;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::IntoArray;

use crate::BitPackedArray;
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/bitpacking/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod test {
use vortex::array::primitive::{Primitive, PrimitiveArray};
use vortex::array::sparse::SparseArray;
use vortex::compute::take;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::{ArrayDef, IntoArray, IntoArrayVariant};

use crate::BitPackedArray;
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/delta/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use arrayref::{array_mut_ref, array_ref};
use fastlanes::{Delta, Transpose};
use num_traits::{WrappingAdd, WrappingSub};
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::fill_forward::fill_forward;
use vortex::compute::unary::fill_forward;
use vortex::validity::Validity;
use vortex::IntoArrayVariant;
use vortex_dtype::{match_each_unsigned_integer_ptype, NativePType, Nullability};
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/for/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn decompress_primitive<T: NativePType + WrappingAdd + PrimInt>(

#[cfg(test)]
mod test {
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::unary::ScalarAtFn;
use vortex::IntoArrayVariant;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions encodings/fastlanes/src/for/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{
search_sorted, slice, take, ArrayCompute, SearchResult, SearchSortedFn, SearchSortedSide,
SliceFn, TakeFn,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl SearchSortedFn for FoRArray {
#[cfg(test)]
mod test {
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::compute::{search_sorted, SearchResult, SearchSortedSide};
use vortex::IntoArray;

Expand Down
2 changes: 1 addition & 1 deletion encodings/roaring/src/boolean/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use croaring::Bitmap;
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::unary::ScalarAtFn;
use vortex::compute::{ArrayCompute, SliceFn};
use vortex::{Array, IntoArray};
use vortex_error::VortexResult;
Expand Down
2 changes: 1 addition & 1 deletion encodings/roaring/src/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl IntoCanonical for RoaringBoolArray {
#[cfg(test)]
mod test {
use vortex::array::bool::BoolArray;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::IntoArray;
use vortex_error::VortexResult;
use vortex_scalar::Scalar;
Expand Down
2 changes: 1 addition & 1 deletion encodings/roaring/src/integer/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::unary::ScalarAtFn;
use vortex::compute::ArrayCompute;
use vortex_dtype::PType;
use vortex_error::VortexResult;
Expand Down
2 changes: 1 addition & 1 deletion encodings/roaring/src/integer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl ArrayStatisticsCompute for RoaringIntArray {}
#[cfg(test)]
mod test {
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::IntoArray;
use vortex_error::VortexResult;

Expand Down
4 changes: 2 additions & 2 deletions encodings/runend-bool/src/array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::compute::{search_sorted, SearchSortedSide};
use vortex::stats::{ArrayStatistics, ArrayStatisticsCompute, StatsSet};
use vortex::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
Expand Down Expand Up @@ -144,7 +144,7 @@ impl ArrayStatisticsCompute for RunEndBoolArray {}
#[cfg(test)]
mod test {
use vortex::array::bool::BoolArray;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::compute::{slice, take};
use vortex::validity::Validity;
use vortex::{Array, ArrayDType, IntoArray, IntoCanonical, ToArray};
Expand Down
2 changes: 1 addition & 1 deletion encodings/runend-bool/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use vortex::array::bool::BoolArray;
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::unary::ScalarAtFn;
use vortex::compute::{slice, ArrayCompute, SliceFn, TakeFn};
use vortex::{Array, IntoArray, IntoArrayVariant, ToArray};
use vortex_dtype::match_each_integer_ptype;
Expand Down
2 changes: 1 addition & 1 deletion encodings/runend/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::{Array, IntoArray, IntoArrayVariant};
use vortex_dtype::match_each_integer_ptype;
Expand Down
4 changes: 2 additions & 2 deletions encodings/runend/src/runend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Debug;

use serde::{Deserialize, Serialize};
use vortex::array::primitive::{Primitive, PrimitiveArray};
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::compute::{search_sorted, SearchSortedSide};
use vortex::stats::{ArrayStatistics, ArrayStatisticsCompute, StatsSet};
use vortex::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
Expand Down Expand Up @@ -154,7 +154,7 @@ impl ArrayStatisticsCompute for RunEndArray {}
#[cfg(test)]
mod test {
use vortex::compute::slice;
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::unary::scalar_at;
use vortex::validity::Validity;
use vortex::{ArrayDType, IntoArray, IntoArrayVariant};
use vortex_dtype::{DType, Nullability, PType};
Expand Down
2 changes: 1 addition & 1 deletion encodings/zigzag/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::unary::{scalar_at, ScalarAtFn};
use vortex::compute::{slice, ArrayCompute, SliceFn};
use vortex::{Array, IntoArray};
use vortex_dtype::PType;
Expand Down
7 changes: 2 additions & 5 deletions vortex-array/benches/scalar_subtract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ fn scalar_subtract(c: &mut Criterion) {

group.bench_function("vortex", |b| {
b.iter(|| {
let array = vortex::compute::unary::scalar_subtract::subtract_scalar(
&chunked,
&to_subtract.into(),
)
.unwrap();
let array =
vortex::compute::unary::subtract_scalar(&chunked, &to_subtract.into()).unwrap();

let chunked = ChunkedArray::try_from(array).unwrap();
black_box(chunked);
Expand Down
5 changes: 2 additions & 3 deletions vortex-array/src/array/bool/compute/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use vortex_dtype::Nullability;
use vortex_error::VortexResult;

use crate::array::bool::BoolArray;
use crate::compute::unary::fill_forward::FillForwardFn;
use crate::compute::unary::FillForwardFn;
use crate::validity::ArrayValidity;
use crate::{Array, ArrayDType, IntoArray, ToArrayData};

Expand Down Expand Up @@ -40,8 +40,7 @@ mod test {
let barr =
BoolArray::from_iter(vec![None, Some(false), None, Some(true), None]).into_array();
let filled_bool =
BoolArray::try_from(compute::unary::fill_forward::fill_forward(&barr).unwrap())
.unwrap();
BoolArray::try_from(compute::unary::fill_forward(&barr).unwrap()).unwrap();
assert_eq!(
filled_bool.boolean_buffer().iter().collect::<Vec<bool>>(),
vec![false, false, false, true, true]
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/bool/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::array::bool::BoolArray;
use crate::compute::unary::fill_forward::FillForwardFn;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::unary::{FillForwardFn, ScalarAtFn};
use crate::compute::{ArrayCompute, CompareFn, SliceFn, TakeFn};

mod compare;
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/bool/compute/scalar_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::array::bool::BoolArray;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::unary::ScalarAtFn;
use crate::validity::ArrayValidity;
use crate::ArrayDType;

Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/bool/compute/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod tests {

use super::*;
use crate::compute::slice;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_at;
use crate::validity::ArrayValidity;
use crate::AsArray;

Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/bool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl AcceptArrayVisitor for BoolArray {
#[cfg(test)]
mod tests {
use crate::array::bool::BoolArray;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_at;
use crate::IntoArray;

#[test]
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/chunked/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::array::chunked::ChunkedArray;
use crate::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use crate::compute::unary::scalar_subtract::SubtractScalarFn;
use crate::compute::unary::{scalar_at, ScalarAtFn, SubtractScalarFn};
use crate::compute::{ArrayCompute, SliceFn, TakeFn};

mod slice;
Expand Down
4 changes: 1 addition & 3 deletions vortex-array/src/array/chunked/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use vortex_scalar::Scalar;

use crate::array::chunked::ChunkedArray;
use crate::array::primitive::PrimitiveArray;
use crate::compute::unary::cast::try_cast;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_subtract::subtract_scalar;
use crate::compute::unary::{scalar_at, subtract_scalar, try_cast};
use crate::compute::{search_sorted, slice, take, SearchSortedSide, TakeFn};
use crate::stats::ArrayStatistics;
use crate::{Array, ArrayDType, IntoArray, ToArray};
Expand Down
5 changes: 2 additions & 3 deletions vortex-array/src/array/chunked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use vortex_error::{vortex_bail, VortexResult};
use vortex_scalar::Scalar;

use crate::array::primitive::PrimitiveArray;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_subtract::{subtract_scalar, SubtractScalarFn};
use crate::compute::unary::{scalar_at, subtract_scalar, SubtractScalarFn};
use crate::compute::{search_sorted, SearchResult, SearchSortedSide};
use crate::iter::{ArrayIterator, ArrayIteratorAdapter};
use crate::stats::StatsSet;
Expand Down Expand Up @@ -167,7 +166,7 @@ mod test {

use crate::array::chunked::ChunkedArray;
use crate::compute::slice;
use crate::compute::unary::scalar_subtract::subtract_scalar;
use crate::compute::unary::subtract_scalar;
use crate::{Array, IntoArray, IntoArrayVariant, ToArray};

fn chunked_array() -> ChunkedArray {
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/constant/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::array::constant::ConstantArray;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::unary::ScalarAtFn;
use crate::compute::{
ArrayCompute, SearchResult, SearchSortedFn, SearchSortedSide, SliceFn, TakeFn,
};
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/extension/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::array::extension::ExtensionArray;
use crate::compute::unary::cast::CastFn;
use crate::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use crate::compute::unary::{scalar_at, CastFn, ScalarAtFn};
use crate::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use crate::{Array, IntoArray};

Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/array/null/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::array::null::NullArray;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::unary::ScalarAtFn;
use crate::compute::{ArrayCompute, SliceFn, TakeFn};
use crate::{Array, IntoArray, IntoArrayVariant};

Expand Down Expand Up @@ -56,7 +56,7 @@ mod test {
use vortex_dtype::DType;

use crate::array::null::NullArray;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_at;
use crate::compute::{slice, take};
use crate::validity::{ArrayValidity, LogicalValidity};
use crate::IntoArray;
Expand Down
8 changes: 4 additions & 4 deletions vortex-array/src/array/primitive/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use vortex_dtype::{match_each_native_ptype, DType, NativePType, PType};
use vortex_error::{vortex_err, VortexResult};

use crate::array::primitive::PrimitiveArray;
use crate::compute::unary::cast::CastFn;
use crate::compute::unary::CastFn;
use crate::validity::Validity;
use crate::{Array, ArrayDType, IntoArray};

Expand Down Expand Up @@ -55,7 +55,7 @@ mod test {
#[test]
fn cast_u32_u8() {
let arr = vec![0u32, 10, 200].into_array();
let p = compute::unary::cast::try_cast(&arr, PType::U8.into())
let p = compute::unary::try_cast(&arr, PType::U8.into())
.unwrap()
.as_primitive();
assert_eq!(p.maybe_null_slice::<u8>(), vec![0u8, 10, 200]);
Expand All @@ -64,7 +64,7 @@ mod test {
#[test]
fn cast_u32_f32() {
let arr = vec![0u32, 10, 200].into_array();
let u8arr = compute::unary::cast::try_cast(&arr, PType::F32.into())
let u8arr = compute::unary::try_cast(&arr, PType::F32.into())
.unwrap()
.as_primitive();
assert_eq!(u8arr.maybe_null_slice::<f32>(), vec![0.0f32, 10., 200.]);
Expand All @@ -73,7 +73,7 @@ mod test {
#[test]
fn cast_i32_u32() {
let arr = vec![-1i32].into_array();
let error = compute::unary::cast::try_cast(&arr, PType::U32.into())
let error = compute::unary::try_cast(&arr, PType::U32.into())
.err()
.unwrap();
let VortexError::ComputeError(s, _) = error else {
Expand Down
Loading
Loading