Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Feb 27, 2024
1 parent f79bd78 commit 9464dbb
Show file tree
Hide file tree
Showing 52 changed files with 187 additions and 176 deletions.
4 changes: 2 additions & 2 deletions bench-vortex/benches/compress_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use vortex::array::varbin::VarBinArray;
use vortex::array::{Array, ArrayRef};
use vortex::compress::CompressCtx;
use vortex::dtype::DType;
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};

use vortex_bench::enumerate_arrays;

Expand Down Expand Up @@ -57,7 +57,7 @@ fn enc_compress(c: &mut Criterion) {
let chunks = reader
.map(|batch_result| batch_result.map_err(VortexError::from))
.map(|batch| batch.map(|b| b.into()))
.collect::<EncResult<Vec<ArrayRef>>>()
.collect::<VortexResult<Vec<ArrayRef>>>()
.unwrap();
let chunked = ChunkedArray::new(chunks, dtype);
println!(
Expand Down
4 changes: 2 additions & 2 deletions bench-vortex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod test {
use vortex::array::{Array, ArrayRef};
use vortex::compress::CompressCtx;
use vortex::dtype::DType;
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};

pub fn download_taxi_data() -> &'static Path {
let download_path = Path::new("../../pyspiral/bench/.data/https-d37ci6vzurychx-cloudfront-net-trip-data-yellow-tripdata-2023-11.parquet");
Expand Down Expand Up @@ -81,7 +81,7 @@ mod test {
let chunks = reader
.map(|batch_result| batch_result.map_err(VortexError::from))
.map(|batch| batch.map(|b| b.into()))
.collect::<EncResult<Vec<ArrayRef>>>()
.collect::<VortexResult<Vec<ArrayRef>>>()
.unwrap();
let chunked = ChunkedArray::new(chunks, dtype);
println!(
Expand Down
6 changes: 4 additions & 2 deletions pyvortex/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ use vortex_alp::{ALPArray, ALP_ENCODING};
use vortex_dict::{DictArray, DICT_ENCODING};
use vortex_ffor::{FFORArray, FFOR_ENCODING};
use vortex_ree::{REEArray, REE_ENCODING};
use vortex_roaring::{RoaringBoolArray, RoaringIntArray, ROARING_BOOL_ENCODING, ROARING_INT_ENCODING};
use vortex_roaring::{
RoaringBoolArray, RoaringIntArray, ROARING_BOOL_ENCODING, ROARING_INT_ENCODING,
};
use vortex_zigzag::{ZigZagArray, ZIGZAG_ENCODING};

use crate::dtype::PyDType;
use crate::vortex_arrow;
use crate::error::PyVortexError;
use crate::vortex_arrow;

#[pyclass(name = "Array", module = "vortex", sequence, subclass)]
pub struct PyArray {
Expand Down
2 changes: 1 addition & 1 deletion pyvortex/src/dtype.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use arrow::datatypes::DataType;
use arrow::pyarrow::FromPyArrow;
use vortex::arrow::convert::TryIntoDType;
use pyo3::types::PyType;
use pyo3::{pyclass, pymethods, Py, PyAny, PyResult, Python};
use vortex::arrow::convert::TryIntoDType;

use vortex::dtype::DType;

Expand Down
2 changes: 1 addition & 1 deletion pyvortex/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use vortex::arrow::convert::TryIntoDType;
use vortex::dtype::DType;

use crate::array::PyArray;
use crate::vortex_arrow::map_arrow_err;
use crate::error::PyVortexError;
use crate::vortex_arrow::map_arrow_err;

/// The main entry point for creating enc arrays from other Python objects.
///
Expand Down
2 changes: 1 addition & 1 deletion pyvortex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use crate::compress::PyCompressConfig;
mod array;
mod compress;
mod dtype;
mod vortex_arrow;
mod encode;
mod error;
mod serde;
mod vortex_arrow;

/// A Python module implemented in Rust.
#[pymodule]
Expand Down
10 changes: 5 additions & 5 deletions vortex-alp/src/alp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use codecz::alp::ALPExponents;
use vortex::array::{Array, ArrayKind, ArrayRef, ArrowIterator, Encoding, EncodingId, EncodingRef};
use vortex::compress::EncodingCompression;
use vortex::dtype::{DType, FloatWidth, IntWidth, Signedness};
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::scalar::{NullableScalar, Scalar};
use vortex::serde::{ArraySerde, EncodingSerde};
Expand All @@ -32,7 +32,7 @@ impl ALPArray {
encoded: ArrayRef,
exponents: ALPExponents,
patches: Option<ArrayRef>,
) -> EncResult<Self> {
) -> VortexResult<Self> {
let dtype = match encoded.dtype() {
d @ DType::Int(width, Signedness::Signed, nullability) => match width {
IntWidth::_32 => DType::Float(32.into(), *nullability),
Expand All @@ -50,7 +50,7 @@ impl ALPArray {
})
}

pub fn encode(array: &dyn Array) -> EncResult<ArrayRef> {
pub fn encode(array: &dyn Array) -> VortexResult<ArrayRef> {
match ArrayKind::from(array) {
ArrayKind::Primitive(p) => Ok(alp_encode(p).boxed()),
_ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())),
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Array for ALPArray {
Stats::new(&self.stats, self)
}

fn scalar_at(&self, index: usize) -> EncResult<Box<dyn Scalar>> {
fn scalar_at(&self, index: usize) -> VortexResult<Box<dyn Scalar>> {
if let Some(patch) = self
.patches()
.and_then(|p| p.scalar_at(index).ok())
Expand Down Expand Up @@ -141,7 +141,7 @@ impl Array for ALPArray {
todo!()
}

fn slice(&self, start: usize, stop: usize) -> EncResult<ArrayRef> {
fn slice(&self, start: usize, stop: usize) -> VortexResult<ArrayRef> {
Ok(Self::try_new(
self.encoded().slice(start, stop)?,
self.exponents(),
Expand Down
2 changes: 1 addition & 1 deletion vortex-alp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use alp::*;
use vortex::array::{EncodingRef, ENCODINGS};
use linkme::distributed_slice;
use vortex::array::{EncodingRef, ENCODINGS};

mod alp;
mod compress;
Expand Down
8 changes: 4 additions & 4 deletions vortex-dict/src/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vortex::array::{
};
use vortex::compress::EncodingCompression;
use vortex::dtype::{DType, Signedness};
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::scalar::Scalar;
use vortex::serde::{ArraySerde, EncodingSerde};
Expand All @@ -24,7 +24,7 @@ impl DictArray {
Self::try_new(codes, dict).unwrap()
}

pub fn try_new(codes: ArrayRef, dict: ArrayRef) -> EncResult<Self> {
pub fn try_new(codes: ArrayRef, dict: ArrayRef) -> VortexResult<Self> {
if !matches!(codes.dtype(), DType::Int(_, Signedness::Unsigned, _)) {
return Err(VortexError::InvalidDType(codes.dtype().clone()));
}
Expand Down Expand Up @@ -75,7 +75,7 @@ impl Array for DictArray {
Stats::new(&self.stats, self)
}

fn scalar_at(&self, index: usize) -> EncResult<Box<dyn Scalar>> {
fn scalar_at(&self, index: usize) -> VortexResult<Box<dyn Scalar>> {
check_index_bounds(self, index)?;
let dict_index: usize = self.codes().scalar_at(index)?.try_into()?;
self.dict().scalar_at(dict_index)
Expand All @@ -86,7 +86,7 @@ impl Array for DictArray {
}

// TODO(robert): Add function to trim the dictionary
fn slice(&self, start: usize, stop: usize) -> EncResult<ArrayRef> {
fn slice(&self, start: usize, stop: usize) -> VortexResult<ArrayRef> {
check_slice_bounds(self, start, stop)?;
Ok(Self::new(self.codes().slice(start, stop)?, self.dict.clone()).boxed())
}
Expand Down
2 changes: 1 addition & 1 deletion vortex-dict/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use vortex::array::{EncodingRef, ENCODINGS};
use linkme::distributed_slice;
use vortex::array::{EncodingRef, ENCODINGS};

pub use compress::*;
pub use dict::*;
Expand Down
10 changes: 5 additions & 5 deletions vortex-ffor/src/ffor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vortex::array::{
};
use vortex::compress::EncodingCompression;
use vortex::dtype::DType;
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::match_each_integer_ptype;
use vortex::scalar::{NullableScalar, Scalar};
Expand Down Expand Up @@ -47,7 +47,7 @@ impl FFORArray {
min_val: Box<dyn Scalar>,
num_bits: u8,
len: usize,
) -> EncResult<Self> {
) -> VortexResult<Self> {
let validity = validity.filter(|v| !v.is_empty());
check_validity_buffer(validity.as_ref())?;

Expand All @@ -70,7 +70,7 @@ impl FFORArray {
})
}

pub fn encode(array: &dyn Array) -> EncResult<ArrayRef> {
pub fn encode(array: &dyn Array) -> VortexResult<ArrayRef> {
match ArrayKind::from(array) {
ArrayKind::Primitive(p) => Ok(ffor_encode(p).boxed()),
_ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())),
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Array for FFORArray {
Stats::new(&self.stats, self)
}

fn scalar_at(&self, index: usize) -> EncResult<Box<dyn Scalar>> {
fn scalar_at(&self, index: usize) -> VortexResult<Box<dyn Scalar>> {
if !self.is_valid(index) {
return Ok(NullableScalar::none(self.dtype().clone()).boxed());
}
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Array for FFORArray {
todo!()
}

fn slice(&self, _start: usize, _stop: usize) -> EncResult<ArrayRef> {
fn slice(&self, _start: usize, _stop: usize) -> VortexResult<ArrayRef> {
unimplemented!("FFoRArray::slice")
}

Expand Down
2 changes: 1 addition & 1 deletion vortex-ffor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use vortex::array::{EncodingRef, ENCODINGS};
pub use ffor::*;
use linkme::distributed_slice;
use vortex::array::{EncodingRef, ENCODINGS};

mod compress;
mod downcast;
Expand Down
2 changes: 1 addition & 1 deletion vortex-ree/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use vortex::array::{EncodingRef, ENCODINGS};
use linkme::distributed_slice;
use vortex::array::{EncodingRef, ENCODINGS};

pub use ree::*;

Expand Down
14 changes: 7 additions & 7 deletions vortex-ree/src/ree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use vortex::compress::EncodingCompression;
use vortex::compute;
use vortex::compute::search_sorted::SearchSortedSide;
use vortex::dtype::{DType, Nullability, Signedness};
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::ptype::NativePType;
use vortex::scalar::Scalar;
Expand Down Expand Up @@ -52,7 +52,7 @@ impl REEArray {
values: ArrayRef,
validity: Option<ArrayRef>,
length: usize,
) -> EncResult<Self> {
) -> VortexResult<Self> {
check_validity_buffer(validity.as_ref())?;

if !matches!(
Expand Down Expand Up @@ -82,15 +82,15 @@ impl REEArray {
})
}

pub fn find_physical_index(&self, index: usize) -> EncResult<usize> {
pub fn find_physical_index(&self, index: usize) -> VortexResult<usize> {
compute::search_sorted::search_sorted_usize(
self.ends(),
index + self.offset,
SearchSortedSide::Right,
)
}

pub fn encode(array: &dyn Array) -> EncResult<ArrayRef> {
pub fn encode(array: &dyn Array) -> VortexResult<ArrayRef> {
match ArrayKind::from(array) {
ArrayKind::Primitive(p) => {
let (ends, values) = ree_encode(p);
Expand Down Expand Up @@ -155,7 +155,7 @@ impl Array for REEArray {
Stats::new(&self.stats, self)
}

fn scalar_at(&self, index: usize) -> EncResult<Box<dyn Scalar>> {
fn scalar_at(&self, index: usize) -> VortexResult<Box<dyn Scalar>> {
check_index_bounds(self, index)?;
self.values.scalar_at(self.find_physical_index(index)?)
}
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Array for REEArray {
})
}

fn slice(&self, start: usize, stop: usize) -> EncResult<ArrayRef> {
fn slice(&self, start: usize, stop: usize) -> VortexResult<ArrayRef> {
check_slice_bounds(self, start, stop)?;
let slice_begin = self.find_physical_index(start)?;
let slice_end = self.find_physical_index(stop)?;
Expand Down Expand Up @@ -314,8 +314,8 @@ fn run_ends_logical_length<T: AsRef<dyn Array>>(ends: &T) -> usize {
mod test {
use arrow::array::cast::AsArray;
use arrow::array::types::Int32Type;
use vortex::array::Array;
use itertools::Itertools;
use vortex::array::Array;

use crate::REEArray;
use vortex::dtype::{DType, IntWidth, Nullability, Signedness};
Expand Down
14 changes: 7 additions & 7 deletions vortex-roaring/src/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vortex::array::{
use vortex::compress::EncodingCompression;
use vortex::dtype::DType;
use vortex::dtype::Nullability::NonNullable;
use vortex::error::{VortexError, EncResult};
use vortex::error::{VortexError, VortexResult};
use vortex::formatter::{ArrayDisplay, ArrayFormatter};
use vortex::scalar::Scalar;
use vortex::serde::{ArraySerde, EncodingSerde};
Expand Down Expand Up @@ -41,7 +41,7 @@ impl RoaringBoolArray {
&self.bitmap
}

pub fn encode(array: &dyn Array) -> EncResult<Self> {
pub fn encode(array: &dyn Array) -> VortexResult<Self> {
match ArrayKind::from(array) {
ArrayKind::Bool(p) => Ok(roaring_encode(p)),
_ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())),
Expand Down Expand Up @@ -84,7 +84,7 @@ impl Array for RoaringBoolArray {
Stats::new(&self.stats, self)
}

fn scalar_at(&self, index: usize) -> EncResult<Box<dyn Scalar>> {
fn scalar_at(&self, index: usize) -> VortexResult<Box<dyn Scalar>> {
check_index_bounds(self, index)?;

if self.bitmap.contains(index as u32) {
Expand All @@ -98,7 +98,7 @@ impl Array for RoaringBoolArray {
todo!()
}

fn slice(&self, start: usize, stop: usize) -> EncResult<ArrayRef> {
fn slice(&self, start: usize, stop: usize) -> VortexResult<ArrayRef> {
check_slice_bounds(self, start, stop)?;

let slice_bitmap = Bitmap::from_range(start as u32..stop as u32);
Expand Down Expand Up @@ -163,13 +163,13 @@ impl Encoding for RoaringBoolEncoding {
mod test {
use vortex::array::bool::BoolArray;
use vortex::array::Array;
use vortex::error::EncResult;
use vortex::error::VortexResult;
use vortex::scalar::Scalar;

use crate::RoaringBoolArray;

#[test]
pub fn iter() -> EncResult<()> {
pub fn iter() -> VortexResult<()> {
let bool: &dyn Array = &BoolArray::from(vec![true, false, true, true]);
let array = RoaringBoolArray::encode(bool)?;

Expand All @@ -180,7 +180,7 @@ mod test {
}

#[test]
pub fn scalar_at() -> EncResult<()> {
pub fn scalar_at() -> VortexResult<()> {
let bool: &dyn Array = &BoolArray::from(vec![true, false, true, true]);
let array = RoaringBoolArray::encode(bool)?;

Expand Down
8 changes: 4 additions & 4 deletions vortex-roaring/src/boolean/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ impl StatsCompute for RoaringBoolArray {
mod test {
use vortex::array::bool::BoolArray;
use vortex::array::Array;
use vortex::error::EncResult;
use vortex::error::VortexResult;
use vortex::stats::Stat::*;

use crate::RoaringBoolArray;

#[test]
pub fn stats_all_true() -> EncResult<()> {
pub fn stats_all_true() -> VortexResult<()> {
let bool: &dyn Array = &BoolArray::from(vec![true, true]);
let array = RoaringBoolArray::encode(bool)?;

Expand All @@ -65,7 +65,7 @@ mod test {
}

#[test]
pub fn stats_all_false() -> EncResult<()> {
pub fn stats_all_false() -> VortexResult<()> {
let bool: &dyn Array = &BoolArray::from(vec![false, false]);
let array = RoaringBoolArray::encode(bool)?;

Expand All @@ -87,7 +87,7 @@ mod test {
}

#[test]
pub fn stats_mixed() -> EncResult<()> {
pub fn stats_mixed() -> VortexResult<()> {
let bool: &dyn Array = &BoolArray::from(vec![false, true, true]);
let array = RoaringBoolArray::encode(bool)?;

Expand Down
Loading

0 comments on commit 9464dbb

Please sign in to comment.