Skip to content
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: 0 additions & 2 deletions encodings/alp/benches/alp_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ use vortex_alp::decompress_into_array;
use vortex_array::LEGACY_SESSION;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::warm_up_vtables;
use vortex_array::dtype::NativePType;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_buffer::buffer;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/fastlanes/benches/bitpacking_take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ use vortex_array::LEGACY_SESSION;
use vortex_array::RecursiveCanonical;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::warm_up_vtables;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_buffer::buffer;
use vortex_fastlanes::bitpack_compress::bitpack_to_best_bit_width;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/fastlanes/benches/canonicalize_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ use vortex_array::VortexSessionExecute;
use vortex_array::arrays::ChunkedArray;
use vortex_array::builders::ArrayBuilder;
use vortex_array::builders::PrimitiveBuilder;
use vortex_array::compute::warm_up_vtables;
use vortex_array::session::ArraySession;
use vortex_error::VortexExpect;
use vortex_fastlanes::bitpack_compress::test_harness::make_array;
use vortex_session::VortexSession;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/fastlanes/benches/compute_between.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::ToCanonical;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::warm_up_vtables;
use vortex_array::dtype::NativePType;
use vortex_error::VortexExpect;
use vortex_fastlanes::bitpack_compress::bitpack_to_best_bit_width;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
6 changes: 0 additions & 6 deletions encodings/fastlanes/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,6 @@ impl vortex_array::arrays::slice::SliceReduce for vortex_fastlanes::FoR

pub fn vortex_fastlanes::FoR::slice(array: &Self::Array, range: core::ops::range::Range<usize>) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>

impl vortex_array::compute::is_sorted::IsSortedKernel for vortex_fastlanes::FoR

pub fn vortex_fastlanes::FoR::is_sorted(&self, array: &vortex_fastlanes::FoRArray) -> vortex_error::VortexResult<core::option::Option<bool>>

pub fn vortex_fastlanes::FoR::is_strict_sorted(&self, array: &vortex_fastlanes::FoRArray) -> vortex_error::VortexResult<core::option::Option<bool>>

impl vortex_array::scalar_fn::fns::binary::compare::CompareKernel for vortex_fastlanes::FoR

pub fn vortex_fastlanes::FoR::compare(lhs: &vortex_fastlanes::FoRArray, rhs: &vortex_array::array::ArrayRef, operator: vortex_array::scalar_fn::fns::operators::CompareOperator, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
Expand Down
79 changes: 48 additions & 31 deletions encodings/fastlanes/src/for/compute/is_sorted.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayRef;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::ToCanonical;
use vortex_array::compute::IsSortedKernel;
use vortex_array::compute::IsSortedKernelAdapter;
use vortex_array::compute::is_sorted;
use vortex_array::compute::is_strict_sorted;
use vortex_array::register_kernel;
use vortex_array::aggregate_fn::AggregateFnRef;
use vortex_array::aggregate_fn::fns::is_sorted::IsSorted;
use vortex_array::aggregate_fn::fns::is_sorted::is_sorted;
use vortex_array::aggregate_fn::fns::is_sorted::is_strict_sorted;
use vortex_array::aggregate_fn::kernels::DynAggregateKernel;
use vortex_array::scalar::Scalar;
use vortex_error::VortexResult;

use crate::FoR;
use crate::FoRArray;

/// FoR can express sortedness directly on its encoded form.
///
Expand Down Expand Up @@ -71,92 +73,107 @@ use crate::FoRArray;
/// Addition is order-preserving, so all the wrapped values preserve their order and they're all
/// represented as unsigned values larger than 127 so they also preserve their order with the
/// unwrapped values.
impl IsSortedKernel for FoR {
fn is_sorted(&self, array: &FoRArray) -> VortexResult<Option<bool>> {
let encoded = array.encoded().to_primitive();
is_sorted(
&encoded
.reinterpret_cast(encoded.ptype().to_unsigned())
.into_array(),
)
}
#[derive(Debug)]
pub(crate) struct FoRIsSortedKernel;

impl DynAggregateKernel for FoRIsSortedKernel {
fn aggregate(
&self,
aggregate_fn: &AggregateFnRef,
batch: &ArrayRef,
ctx: &mut ExecutionCtx,
) -> VortexResult<Option<Scalar>> {
let Some(options) = aggregate_fn.as_opt::<IsSorted>() else {
return Ok(None);
};

let Some(array) = batch.as_opt::<FoR>() else {
return Ok(None);
};

fn is_strict_sorted(&self, array: &FoRArray) -> VortexResult<Option<bool>> {
let encoded = array.encoded().to_primitive();
is_strict_sorted(
&encoded
.reinterpret_cast(encoded.ptype().to_unsigned())
.into_array(),
)
let unsigned_array = encoded
.reinterpret_cast(encoded.ptype().to_unsigned())
.into_array();

let result = if options.strict {
is_strict_sorted(&unsigned_array, ctx)?
} else {
is_sorted(&unsigned_array, ctx)?
};

Ok(Some(IsSorted::make_partial(batch, result, options.strict)?))
}
}

register_kernel!(IsSortedKernelAdapter(FoR).lift());

#[cfg(test)]
mod test {
use vortex_array::IntoArray;
use vortex_array::LEGACY_SESSION;
use vortex_array::VortexSessionExecute;
use vortex_array::aggregate_fn::fns::is_sorted::is_sorted;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::is_sorted;
use vortex_array::validity::Validity;
use vortex_buffer::buffer;

use crate::FoRArray;

#[test]
fn test_sorted() {
let mut ctx = LEGACY_SESSION.create_execution_ctx();

let a = PrimitiveArray::new(buffer![-1, 0, i8::MAX], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
is_sorted(&b.clone().into_array()).unwrap().unwrap(),
is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![i8::MIN, 0, i8::MAX], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
is_sorted(&b.clone().into_array()).unwrap().unwrap(),
is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![i8::MIN, 0, 30, 127], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
is_sorted(&b.clone().into_array()).unwrap().unwrap(),
is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![i8::MIN, -3, -1], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
is_sorted(&b.clone().into_array()).unwrap().unwrap(),
is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![-10, -3, -1], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
is_sorted(&b.clone().into_array()).unwrap().unwrap(),
is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![-10, -11, -1], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
!is_sorted(&b.clone().into_array()).unwrap().unwrap(),
!is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);

let a = PrimitiveArray::new(buffer![-10, i8::MIN, -1], Validity::NonNullable);
let b = FoRArray::encode(a).unwrap();
assert!(
!is_sorted(&b.clone().into_array()).unwrap().unwrap(),
!is_sorted(&b.clone().into_array(), &mut ctx).unwrap(),
"{}",
b.encoded().display_values()
);
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/for/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod cast;
mod compare;
pub(crate) mod is_constant;
mod is_sorted;
pub(crate) mod is_sorted;

use vortex_array::ArrayRef;
use vortex_array::DynArray;
Expand Down
7 changes: 7 additions & 0 deletions encodings/fastlanes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ pub(crate) const FL_CHUNK_SIZE: usize = 1024;

use bitpacking::compute::is_constant::BitPackedIsConstantKernel;
use r#for::compute::is_constant::FoRIsConstantKernel;
use r#for::compute::is_sorted::FoRIsSortedKernel;
use vortex_array::aggregate_fn::AggregateFnVTable;
use vortex_array::aggregate_fn::fns::is_constant::IsConstant;
use vortex_array::aggregate_fn::fns::is_sorted::IsSorted;
use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
use vortex_array::session::ArraySessionExt;
use vortex_session::VortexSession;
Expand All @@ -42,6 +44,11 @@ pub fn initialize(session: &mut VortexSession) {
Some(IsConstant.id()),
&FoRIsConstantKernel,
);
session.aggregate_fns().register_aggregate_kernel(
FoR::ID,
Some(IsSorted.id()),
&FoRIsSortedKernel,
);
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions encodings/fsst/benches/chunked_dict_fsst_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::ChunkedArray;
use vortex_array::builders::builder_with_capacity;
use vortex_array::compute::warm_up_vtables;
use vortex_array::dtype::NativePType;
use vortex_array::session::ArraySession;
use vortex_error::VortexExpect;
use vortex_fsst::test_utils::gen_dict_fsst_test_data;
use vortex_session::VortexSession;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/fsst/benches/fsst_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use vortex_array::arrays::VarBinArray;
use vortex_array::builders::ArrayBuilder;
use vortex_array::builders::VarBinViewBuilder;
use vortex_array::builtins::ArrayBuiltins;
use vortex_array::compute::warm_up_vtables;
use vortex_array::dtype::DType;
use vortex_array::dtype::Nullability;
use vortex_array::scalar::Scalar;
Expand All @@ -30,7 +29,6 @@ use vortex_fsst::fsst_train_compressor;
use vortex_session::VortexSession;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/fsst/benches/fsst_url_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use vortex_array::VortexSessionExecute;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::VarBinArray;
use vortex_array::builtins::ArrayBuiltins;
use vortex_array::compute::warm_up_vtables;
use vortex_array::expr::like;
use vortex_array::expr::lit;
use vortex_array::expr::root;
Expand All @@ -28,7 +27,6 @@ use vortex_fsst::test_utils::generate_url_data;
use vortex_session::VortexSession;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/runend/benches/run_end_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ use vortex_array::RecursiveCanonical;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::VarBinViewArray;
use vortex_array::compute::warm_up_vtables;
use vortex_array::dtype::IntegerPType;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_runend::RunEndArray;
use vortex_runend::compress::runend_encode;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/runend/benches/run_end_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ use std::fmt;
use divan::Bencher;
use vortex_array::arrays::BoolArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::warm_up_vtables;
use vortex_array::validity::Validity;
use vortex_buffer::BitBuffer;
use vortex_buffer::BufferMut;
use vortex_runend::decompress_bool::runend_decode_bools;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
2 changes: 0 additions & 2 deletions encodings/runend/benches/run_end_null_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ use rand::rngs::StdRng;
use vortex_array::DynArray;
use vortex_array::IntoArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::warm_up_vtables;
use vortex_buffer::Buffer;
use vortex_runend::RunEndArray;

fn main() {
warm_up_vtables();
divan::main();
}

Expand Down
6 changes: 0 additions & 6 deletions encodings/runend/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ impl vortex_array::arrays::filter::kernel::FilterKernel for vortex_runend::RunEn

pub fn vortex_runend::RunEnd::filter(array: &vortex_runend::RunEndArray, mask: &vortex_mask::Mask, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>

impl vortex_array::compute::is_sorted::IsSortedKernel for vortex_runend::RunEnd

pub fn vortex_runend::RunEnd::is_sorted(&self, array: &vortex_runend::RunEndArray) -> vortex_error::VortexResult<core::option::Option<bool>>

pub fn vortex_runend::RunEnd::is_strict_sorted(&self, array: &vortex_runend::RunEndArray) -> vortex_error::VortexResult<core::option::Option<bool>>

impl vortex_array::scalar_fn::fns::binary::compare::CompareKernel for vortex_runend::RunEnd

pub fn vortex_runend::RunEnd::compare(lhs: &vortex_runend::RunEndArray, rhs: &vortex_array::array::ArrayRef, operator: vortex_array::scalar_fn::fns::operators::CompareOperator, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::array::ArrayRef>>
Expand Down
Loading
Loading