Skip to content

Commit

Permalink
lord give me the strength
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Jun 5, 2024
1 parent 2651669 commit 516bf27
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bench-vortex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ include = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }

#[lints]
#workspace = true
[lints]
workspace = true

[dependencies]
arrow-array = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions bench-vortex/benches/random_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn random_access(c: &mut Criterion) {
});

let dataset = BenchmarkDatasets::PBI(Medicare1);
dataset.write_as_parquet();
dataset.write_as_lance();
// NB: our parquet benchmarks read from a single file, and we (currently) write each
// file to an individual lance dataset for comparison parity.
Expand Down
1 change: 1 addition & 0 deletions bench-vortex/src/public_bi_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ impl BenchmarkDataset for BenchmarkDatasets {
self.as_uncompressed();
for f in self.list_files(FileType::Csv) {
info!("Compressing {} to lance", f.to_str().unwrap());
println!("Compressing {} to lance", f.to_str().unwrap());
let output_fname = f
.file_name()
.unwrap()
Expand Down
31 changes: 23 additions & 8 deletions vortex-alp/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use vortex::compute::as_contiguous::AsContiguousFn;
use vortex::compute::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::slice::{slice, SliceFn};
use vortex::compute::take::{take, TakeFn};
use vortex::compute::ArrayCompute;
use vortex::{Array, ArrayDType, impl_default_as_contiguous_fn, IntoArray};
use vortex::compute::as_contiguous::AsContiguousFn;
use vortex::{impl_default_as_contiguous_fn, Array, ArrayDType, IntoArray};
use vortex_error::VortexResult;
use vortex_scalar::Scalar;

Expand Down Expand Up @@ -74,8 +74,9 @@ mod test {
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::as_contiguous::AsContiguousFn;
use vortex::compute::scalar_at::scalar_at;
use vortex::IntoArray;
use vortex::validity::Validity;
use vortex::IntoArray;

use crate::ALPArray;

#[test]
Expand All @@ -85,20 +86,34 @@ mod test {
let encoded = ALPArray::encode(primitives.into_array()).unwrap();
let alp = ALPArray::try_from(&encoded).unwrap();


let flat = alp.as_contiguous(&[encoded]).unwrap();

let a = scalar_at(&flat, 0).unwrap().value().as_pvalue().unwrap().unwrap();
let a = scalar_at(&flat, 0)
.unwrap()
.value()
.as_pvalue()
.unwrap()
.unwrap();
let a: f64 = a.try_into().unwrap();

let b = scalar_at(&flat, 1).unwrap().value().as_pvalue().unwrap().unwrap();
let b = scalar_at(&flat, 1)
.unwrap()
.value()
.as_pvalue()
.unwrap()
.unwrap();
let b: f64 = b.try_into().unwrap();

let c = scalar_at(&flat, 2).unwrap().value().as_pvalue().unwrap().unwrap();
let c = scalar_at(&flat, 2)
.unwrap()
.value()
.as_pvalue()
.unwrap()
.unwrap();
let c: f64 = c.try_into().unwrap();

assert_eq!(a, 1.0);
assert_eq!(b, 2.0);
assert_eq!(c, 3.0);
}
}
}
1 change: 0 additions & 1 deletion vortex-array/src/array/datetime/localdatetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ impl TryFrom<LocalDateTimeArray> for ExtensionArray {
}
}


impl TryFrom<&LocalDateTimeArray> for ExtensionArray {
type Error = VortexError;

Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/struct/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ impl AsContiguousFn for StructArray {
}
}

let fields_len = fields.first()
let fields_len = fields
.first()
.map(|field| field.iter().map(|a| a.len()).sum())
.unwrap_or_default();

Expand Down
5 changes: 4 additions & 1 deletion vortex-array/src/array/struct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ impl StructArray {
}

if fields.iter().any(|a| a.with_dyn(|a| a.len()) != length) {
println!("FIELD LENGTHS: {:?}", fields.iter().map(|field| field.len()).collect::<Vec<_>>());
println!(
"FIELD LENGTHS: {:?}",
fields.iter().map(|field| field.len()).collect::<Vec<_>>()
);
vortex_bail!("Expected all struct fields to have length {}", length);
}

Expand Down
9 changes: 7 additions & 2 deletions vortex-array/src/compute/as_contiguous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use vortex_error::{vortex_bail, vortex_err, VortexResult};

use crate::{Array, ArrayDType};


/// Trait for typed array variants which support the process of unfurling to somewhere else.
pub trait AsContiguousFn {
fn as_contiguous(&self, arrays: &[Array]) -> VortexResult<Array>;
Expand Down Expand Up @@ -46,7 +45,13 @@ pub fn as_contiguous(arrays: &[Array]) -> VortexResult<Array> {
vortex_bail!(ComputeError: "No arrays to concatenate");
}
if !arrays.iter().map(|chunk| chunk.encoding().id()).all_equal() {
println!("ENCODINGS: {:?}", arrays.iter().map(|chunk| chunk.encoding().id()).collect_vec());
println!(
"ENCODINGS: {:?}",
arrays
.iter()
.map(|chunk| chunk.encoding().id())
.collect_vec()
);
vortex_bail!(ComputeError: "Chunks have differing encodings");
}
if !arrays.iter().map(|chunk| chunk.dtype()).all_equal() {
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/flatten.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use vortex_error::VortexResult;

use crate::{Array, IntoArray};
use crate::array::bool::BoolArray;
use crate::array::extension::ExtensionArray;
use crate::array::primitive::PrimitiveArray;
use crate::array::r#struct::StructArray;
use crate::array::varbin::VarBinArray;
use crate::array::varbinview::VarBinViewArray;
use crate::encoding::ArrayEncoding;
use crate::{Array, IntoArray};

/// The set of encodings that can be converted to Arrow with zero-copy.
pub enum Flattened {
Expand Down
5 changes: 4 additions & 1 deletion vortex-datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use vortex::validity::{ArrayValidity, LogicalValidity};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, ArrayDType, ArrayFlatten, ToArrayData};
use vortex_error::vortex_bail;

use crate::compute::decode_to_localdatetime;

impl_encoding!("vortex.datetimeparts", DateTimeParts);
Expand Down Expand Up @@ -82,7 +83,9 @@ impl DateTimePartsArray {

impl ArrayFlatten for DateTimePartsArray {
fn flatten(self) -> VortexResult<Flattened> {
Ok(Flattened::Extension(decode_to_localdatetime(&self.into_array())?.try_into()?))
Ok(Flattened::Extension(
decode_to_localdatetime(&self.into_array())?.try_into()?,
))
}
}

Expand Down
24 changes: 19 additions & 5 deletions vortex-datetime-parts/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,24 @@ pub fn decode_to_localdatetime(array: &Array) -> VortexResult<LocalDateTimeArray
TimeUnit::S => 1,
};

let days_buf = array.days().flatten()?.into_array().as_primitive().scalar_buffer::<i64>();
let seconds_buf = array.seconds().flatten()?.into_array().as_primitive().scalar_buffer::<i64>();
let subsecond_buf = array.subsecond().flatten()?.into_array().as_primitive().scalar_buffer::<i64>();
let days_buf = array
.days()
.flatten()?
.into_array()
.as_primitive()
.scalar_buffer::<i64>();
let seconds_buf = array
.seconds()
.flatten()?
.into_array()
.as_primitive()
.scalar_buffer::<i64>();
let subsecond_buf = array
.subsecond()
.flatten()?
.into_array()
.as_primitive()
.scalar_buffer::<i64>();

// TODO(aduffy): replace with vectorized implementation?
let values = days_buf
Expand All @@ -137,7 +152,7 @@ pub fn decode_to_localdatetime(array: &Array) -> VortexResult<LocalDateTimeArray

LocalDateTimeArray::try_new(
time_unit,
PrimitiveArray::from_vec(values, array.logical_validity().into_validity()).into_array()
PrimitiveArray::from_vec(values, array.logical_validity().into_validity()).into_array(),
)
}

Expand All @@ -158,7 +173,6 @@ impl AsContiguousFn for DateTimePartsArray {
vortex_bail!(ComputeError: "mismatched dtypes in call to as_contiguous");
}


let mut chunks = Vec::with_capacity(arrays.iter().map(|array| array.len()).sum());

for array in arrays {
Expand Down
4 changes: 2 additions & 2 deletions vortex-dict/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use vortex::compute::as_contiguous::AsContiguousFn;
use vortex::compute::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::slice::{slice, SliceFn};
use vortex::compute::take::{take, TakeFn};
use vortex::compute::ArrayCompute;
use vortex::{Array, impl_default_as_contiguous_fn, IntoArray};
use vortex::compute::as_contiguous::AsContiguousFn;
use vortex::{impl_default_as_contiguous_fn, Array, IntoArray};
use vortex_error::VortexResult;
use vortex_scalar::Scalar;

Expand Down
2 changes: 1 addition & 1 deletion vortex-fastlanes/src/for/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use vortex::compute::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::slice::{slice, SliceFn};
use vortex::compute::take::{take, TakeFn};
use vortex::compute::ArrayCompute;
use vortex::{Array, impl_default_as_contiguous_fn, IntoArray};
use vortex::{impl_default_as_contiguous_fn, Array, IntoArray};
use vortex_dtype::match_each_integer_ptype;
use vortex_error::{vortex_bail, VortexResult};
use vortex_scalar::{PrimitiveScalar, Scalar, ScalarValue};
Expand Down

0 comments on commit 516bf27

Please sign in to comment.