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

Vortex Error #133

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"vortex-array",
"vortex-datetime",
"vortex-dict",
"vortex-error",
"vortex-fastlanes",
"vortex-ree",
"vortex-roaring",
Expand Down
1 change: 1 addition & 0 deletions pyvortex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ arrow = { workspace = true }
vortex-array = { path = "../vortex-array" }
vortex-alp = { path = "../vortex-alp" }
vortex-dict = { path = "../vortex-dict" }
vortex-error = { path = "../vortex-error" }
vortex-fastlanes = { path = "../vortex-fastlanes" }
vortex-ree = { path = "../vortex-ree" }
vortex-roaring = { path = "../vortex-roaring" }
Expand Down
1 change: 1 addition & 0 deletions pyvortex/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::dtype::PyDType;
use crate::error::PyVortexError;
use crate::vortex_arrow;
use std::sync::Arc;

#[pyclass(name = "Array", module = "vortex", sequence, subclass)]
pub struct PyArray {
inner: ArrayRef,
Expand Down
2 changes: 1 addition & 1 deletion pyvortex/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pyo3::exceptions::PyValueError;
use pyo3::PyErr;

use vortex::error::VortexError;
use vortex_error::VortexError;

pub struct PyVortexError(VortexError);

Expand Down
1 change: 1 addition & 0 deletions vortex-alp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ workspace = true

[dependencies]
vortex-array = { path = "../vortex-array" }
vortex-error = { path = "../vortex-error" }
vortex-schema = { path = "../vortex-schema" }
linkme = { workspace = true }
itertools = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions vortex-alp/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::sync::{Arc, RwLock};
use crate::alp::Exponents;
use vortex::array::{Array, ArrayKind, ArrayRef, Encoding, EncodingId, EncodingRef};
use vortex::compress::EncodingCompression;
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::impl_array;
use vortex::serde::{ArraySerde, EncodingSerde};
use vortex::stats::{Stats, StatsSet};
use vortex_error::{VortexError, VortexResult};
use vortex_schema::{DType, IntWidth, Signedness};

use crate::compress::alp_encode;
Expand Down Expand Up @@ -51,7 +51,7 @@ impl ALPArray {
pub fn encode(array: &dyn Array) -> VortexResult<ArrayRef> {
match ArrayKind::from(array) {
ArrayKind::Primitive(p) => Ok(alp_encode(p)?.into_array()),
_ => Err(VortexError::InvalidEncoding(array.encoding().id())),
_ => Err("ALP can only encoding primitive arrays".into()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/encode/encoding/

also might be nice to propagate information about what encoding was passed in?

}
}

Expand Down
8 changes: 4 additions & 4 deletions vortex-alp/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use vortex::array::{Array, ArrayRef};
use vortex::compress::{CompressConfig, CompressCtx, EncodingCompression};
use vortex::compute::flatten::flatten_primitive;
use vortex::compute::patch::patch;
use vortex::error::{VortexError, VortexResult};
use vortex::ptype::{NativePType, PType};
use vortex_error::VortexResult;

use crate::alp::ALPFloat;
use crate::array::{ALPArray, ALPEncoding};
Expand All @@ -19,13 +19,13 @@ use crate::Exponents;
macro_rules! match_each_alp_float_ptype {
($self:expr, | $_:tt $enc:ident | $($body:tt)*) => ({
macro_rules! __with__ {( $_ $enc:ident ) => ( $($body)* )}
use vortex::error::VortexError;
use vortex::ptype::PType;
use vortex_error::VortexError;
let ptype = $self;
match ptype {
PType::F32 => Ok(__with__! { f32 }),
PType::F64 => Ok(__with__! { f64 }),
_ => Err(VortexError::InvalidPType(ptype))
_ => Err(VortexError::InvalidArgument("ALP can only encode f32 and f64".into())),
}
})
}
Expand Down Expand Up @@ -108,7 +108,7 @@ pub(crate) fn alp_encode(parray: &PrimitiveArray) -> VortexResult<ALPArray> {
let (exponents, encoded, patches) = match parray.ptype() {
PType::F32 => encode_to_array(parray.typed_data::<f32>(), None),
PType::F64 => encode_to_array(parray.typed_data::<f64>(), None),
_ => return Err(VortexError::InvalidPType(parray.ptype())),
_ => return Err("ALP can only encode f32 and f64".into()),
};
Ok(ALPArray::new(encoded, exponents, patches))
}
Expand Down
2 changes: 1 addition & 1 deletion vortex-alp/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use vortex::array::Array;
use vortex::compute::flatten::{FlattenFn, FlattenedArray};
use vortex::compute::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::ArrayCompute;
use vortex::error::VortexResult;
use vortex_error::VortexResult;
use vortex::scalar::Scalar;

use crate::compress::decompress;
Expand Down
4 changes: 2 additions & 2 deletions vortex-alp/src/serde.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::alp::Exponents;
use vortex::array::{Array, ArrayRef};
use vortex::error::{VortexError, VortexResult};
use vortex_error::{VortexError, VortexResult};
use vortex::serde::{ArraySerde, EncodingSerde, ReadCtx, WriteCtx};
use vortex_schema::{DType, FloatWidth, Signedness};

Expand Down Expand Up @@ -53,7 +53,7 @@ mod test {
use vortex::array::downcast::DowncastArrayBuiltin;
use vortex::array::primitive::PrimitiveArray;
use vortex::array::{Array, ArrayRef};
use vortex::error::VortexResult;
use vortex_error::VortexResult;
use vortex::serde::{ReadCtx, WriteCtx};

use crate::compress::alp_encode;
Expand Down
2 changes: 1 addition & 1 deletion vortex-alp/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use vortex::error::VortexResult;
use vortex_error::VortexResult;

use crate::ALPArray;
use vortex::stats::{Stat, StatsCompute, StatsSet};
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ num_enum = { workspace = true }
paste = { workspace = true }
rand = { workspace = true }
thiserror = { workspace = true }
vortex-schema = { path = "../vortex-schema" }
vortex-alloc = { path = "../vortex-alloc" }
vortex-error = { path = "../vortex-error" }
vortex-schema = { path = "../vortex-schema" }
6 changes: 4 additions & 2 deletions vortex-array/src/array/bool/compute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::sync::Arc;

use arrow_buffer::buffer::BooleanBuffer;
use itertools::Itertools;
use std::sync::Arc;

use vortex_error::VortexResult;

use crate::array::bool::BoolArray;
use crate::array::downcast::DowncastArrayBuiltin;
Expand All @@ -10,7 +13,6 @@ use crate::compute::fill::FillForwardFn;
use crate::compute::flatten::{flatten_bool, FlattenFn, FlattenedArray};
use crate::compute::scalar_at::ScalarAtFn;
use crate::compute::ArrayCompute;
use crate::error::VortexResult;
use crate::scalar::{BoolScalar, Scalar};

impl ArrayCompute for BoolArray {
Expand Down
11 changes: 7 additions & 4 deletions vortex-array/src/array/bool/flatten.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::sync::Arc;

use arrow_array::{ArrayRef as ArrowArrayRef, BooleanArray as ArrowBoolArray};
use arrow_buffer::NullBuffer;

use vortex_error::VortexResult;

use crate::array::bool::BoolArray;
use crate::compute::as_arrow::AsArrowArray;
use crate::compute::flatten::flatten_bool;
use crate::error::VortexResult;
use arrow_array::{ArrayRef as ArrowArrayRef, BooleanArray as ArrowBoolArray};
use arrow_buffer::NullBuffer;
use std::sync::Arc;

impl AsArrowArray for BoolArray {
fn as_arrow(&self) -> VortexResult<ArrowArrayRef> {
Expand Down
6 changes: 3 additions & 3 deletions vortex-array/src/array/bool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::sync::{Arc, RwLock};
use arrow_buffer::buffer::BooleanBuffer;
use linkme::distributed_slice;

use crate::array::IntoArray;
use crate::impl_array;
use vortex_error::VortexResult;
use vortex_schema::{DType, Nullability};

use crate::array::IntoArray;
use crate::compute::scalar_at::scalar_at;
use crate::error::VortexResult;
use crate::formatter::{ArrayDisplay, ArrayFormatter};
use crate::impl_array;
use crate::serde::{ArraySerde, EncodingSerde};
use crate::stats::{Stat, Stats, StatsSet};

Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/bool/serde.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use arrow_buffer::buffer::BooleanBuffer;

use vortex_error::VortexResult;

use crate::array::bool::{BoolArray, BoolEncoding};
use crate::array::{Array, ArrayRef};
use crate::error::VortexResult;
use crate::serde::{ArraySerde, EncodingSerde, ReadCtx, WriteCtx};

impl ArraySerde for BoolArray {
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/bool/stats.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::collections::HashMap;

use vortex_error::VortexResult;

use crate::array::bool::BoolArray;
use crate::array::Array;
use crate::error::VortexResult;
use crate::stats::{Stat, StatsCompute, StatsSet};

impl StatsCompute for BoolArray {
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/chunked/compute.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use itertools::Itertools;

use vortex_error::VortexResult;

use crate::array::chunked::ChunkedArray;
use crate::array::downcast::DowncastArrayBuiltin;
use crate::array::ArrayRef;
use crate::compute::as_contiguous::{as_contiguous, AsContiguousFn};
use crate::compute::flatten::{FlattenFn, FlattenedArray};
use crate::compute::scalar_at::{scalar_at, ScalarAtFn};
use crate::compute::ArrayCompute;
use crate::error::VortexResult;
use crate::scalar::Scalar;

impl ArrayCompute for ChunkedArray {
Expand Down
5 changes: 3 additions & 2 deletions vortex-array/src/array/chunked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use std::sync::{Arc, RwLock};

use itertools::Itertools;
use linkme::distributed_slice;

use vortex_error::{VortexError, VortexResult};
use vortex_schema::DType;

use crate::array::{
check_slice_bounds, Array, ArrayRef, Encoding, EncodingId, EncodingRef, ENCODINGS,
};
use crate::error::{VortexError, VortexResult};
use crate::formatter::{ArrayDisplay, ArrayFormatter};
use crate::impl_array;
use crate::serde::{ArraySerde, EncodingSerde};
Expand Down Expand Up @@ -194,11 +195,11 @@ impl Encoding for ChunkedEncoding {

#[cfg(test)]
mod test {
use crate::array::{Array, ArrayRef};
use vortex_schema::{DType, IntWidth, Nullability, Signedness};

use crate::array::chunked::ChunkedArray;
use crate::array::IntoArray;
use crate::array::{Array, ArrayRef};
use crate::compute::flatten::{flatten, flatten_primitive, FlattenedArray};
use crate::ptype::NativePType;

Expand Down
6 changes: 4 additions & 2 deletions vortex-array/src/array/chunked/serde.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use vortex_error::VortexResult;

use crate::array::chunked::{ChunkedArray, ChunkedEncoding};
use crate::array::{Array, ArrayRef};
use crate::error::VortexResult;
use crate::serde::{ArraySerde, EncodingSerde, ReadCtx, WriteCtx};

impl ArraySerde for ChunkedArray {
Expand All @@ -27,12 +28,13 @@ impl EncodingSerde for ChunkedEncoding {

#[cfg(test)]
mod test {
use vortex_schema::{DType, IntWidth, Nullability, Signedness};

use crate::array::chunked::ChunkedArray;
use crate::array::downcast::DowncastArrayBuiltin;
use crate::array::primitive::PrimitiveArray;
use crate::array::Array;
use crate::serde::test::roundtrip_array;
use vortex_schema::{DType, IntWidth, Nullability, Signedness};

#[test]
fn roundtrip() {
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/chunked/stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use vortex_error::VortexResult;

use crate::array::chunked::ChunkedArray;
use crate::error::VortexResult;
use crate::stats::{Stat, StatsCompute, StatsSet};

impl StatsCompute for ChunkedArray {
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/composite/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use std::fmt::{Debug, Display};
use std::sync::{Arc, RwLock};

use linkme::distributed_slice;

use vortex_error::VortexResult;
use vortex_schema::{CompositeID, DType};

use crate::array::composite::{find_extension, CompositeExtensionRef, TypedCompositeArray};
use crate::array::{Array, ArrayRef, Encoding, EncodingId, EncodingRef, ENCODINGS};
use crate::compress::EncodingCompression;
use crate::compute::ArrayCompute;
use crate::error::VortexResult;
use crate::formatter::{ArrayDisplay, ArrayFormatter};
use crate::impl_array;
use crate::serde::{ArraySerde, BytesSerde, EncodingSerde};
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/composite/compress.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use vortex_error::VortexResult;

use crate::array::composite::{CompositeArray, CompositeEncoding};
use crate::array::downcast::DowncastArrayBuiltin;
use crate::array::{Array, ArrayRef};
use crate::compress::{CompressConfig, CompressCtx, EncodingCompression};
use crate::error::VortexResult;

impl EncodingCompression for CompositeEncoding {
fn cost(&self) -> u8 {
Expand Down
Loading
Loading