Skip to content

Commit

Permalink
Vortex Buffer Crate (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored May 6, 2024
1 parent bfe8a3c commit 19ad296
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 28 deletions.
11 changes: 11 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 @@ -6,6 +6,7 @@ members = [
"pyvortex",
"vortex-alp",
"vortex-array",
"vortex-buffer",
"vortex-datetime-parts",
"vortex-dict",
"vortex-error",
Expand Down
1 change: 1 addition & 0 deletions vortex-array/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ num-traits = { workspace = true }
num_enum = { workspace = true }
paste = { workspace = true }
rand = { workspace = true }
vortex-buffer = { path = "../vortex-buffer" }
vortex-dtype = { path = "../vortex-dtype", features = ["serde"] }
vortex-error = { path = "../vortex-error", features = ["flexbuffers"] }
vortex-flatbuffers = { path = "../vortex-flatbuffers" }
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
@@ -1,8 +1,8 @@
use arrow_buffer::BooleanBuffer;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use vortex_buffer::Buffer;

use crate::buffer::Buffer;
use crate::validity::{ArrayValidity, ValidityMetadata};
use crate::validity::{LogicalValidity, Validity};
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/primitive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use arrow_buffer::{ArrowNativeType, ScalarBuffer};
use itertools::Itertools;
use num_traits::AsPrimitive;
use serde::{Deserialize, Serialize};
use vortex_buffer::Buffer;
use vortex_dtype::{match_each_native_ptype, NativePType, PType};
use vortex_error::vortex_bail;

use crate::buffer::Buffer;
use crate::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};
use crate::ArrayFlatten;
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::{Arc, RwLock};

use vortex_buffer::{Buffer, OwnedBuffer};
use vortex_dtype::DType;
use vortex_error::{vortex_err, VortexResult};
use vortex_scalar::Scalar;

use crate::buffer::{Buffer, OwnedBuffer};
use crate::encoding::EncodingRef;
use crate::stats::{Stat, Statistics, StatsSet};
use crate::{Array, ArrayMetadata, IntoArray, OwnedArray, ToArray};
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/implementation.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use vortex_buffer::{Buffer, OwnedBuffer};
use vortex_dtype::DType;
use vortex_error::{vortex_bail, VortexError, VortexResult};

use crate::buffer::{Buffer, OwnedBuffer};
use crate::encoding::{ArrayEncoding, ArrayEncodingRef, EncodingRef};
use crate::encoding::{ArrayEncodingExt, EncodingId};
use crate::stats::{ArrayStatistics, Statistics};
use crate::visitor::ArrayVisitor;
use crate::{
Array, ArrayDType, ArrayData, ArrayMetadata, AsArray, GetArrayMetadata, IntoArray,
IntoArrayData, ToArrayData, ToStatic,
IntoArrayData, ToArrayData,
};
use crate::{ArrayTrait, TryDeserializeArrayMetadata};

Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod accessor;
pub mod array;
pub mod arrow;
pub mod buffer;
pub mod compress;
pub mod compute;
mod context;
Expand Down Expand Up @@ -29,10 +28,10 @@ pub use implementation::*;
pub use metadata::*;
pub use typed::*;
pub use view::*;
use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_error::VortexResult;

use crate::buffer::Buffer;
use crate::compute::ArrayCompute;
use crate::encoding::{ArrayEncodingRef, EncodingRef};
use crate::stats::{ArrayStatistics, ArrayStatisticsCompute};
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::fmt;

use humansize::{format_size, DECIMAL};
use serde::ser::Error;
use vortex_buffer::Buffer;
use vortex_error::{VortexError, VortexResult};

use crate::array::chunked::ChunkedArray;
use crate::buffer::Buffer;
use crate::visitor::ArrayVisitor;
use crate::{Array, ToArrayData};

Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/typed.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::sync::Arc;

use vortex_buffer::OwnedBuffer;
use vortex_dtype::DType;
use vortex_error::{vortex_err, VortexError, VortexResult};

use crate::buffer::OwnedBuffer;
use crate::stats::StatsSet;
use crate::{Array, ArrayData, ArrayDef, AsArray, IntoArray, ToArray, TryDeserializeArrayMetadata};

Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/view.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fmt::{Debug, Formatter};

use itertools::Itertools;
use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_error::{vortex_bail, vortex_err, VortexError, VortexResult};

use crate::buffer::Buffer;
use crate::encoding::{EncodingId, EncodingRef};
use crate::flatbuffers::array as fb;
use crate::stats::{EmptyStatistics, Statistics};
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/visitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use vortex_buffer::Buffer;
use vortex_error::VortexResult;

use crate::buffer::Buffer;
use crate::validity::Validity;
use crate::Array;

Expand Down
18 changes: 18 additions & 0 deletions vortex-buffer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "vortex-buffer"
version.workspace = true
homepage.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true
keywords.workspace = true
include.workspace = true
edition.workspace = true
rust-version.workspace = true

[dependencies]
arrow-buffer = { workspace = true }
vortex-dtype = { path = "../vortex-dtype" }

[lints]
workspace = true
20 changes: 7 additions & 13 deletions vortex-array/src/buffer.rs → vortex-buffer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use arrow_buffer::Buffer as ArrowBuffer;
use vortex_dtype::{match_each_native_ptype, NativePType};

use crate::ToStatic;

#[derive(Debug, Clone)]
pub enum Buffer<'a> {
Owned(ArrowBuffer),
Expand Down Expand Up @@ -45,6 +43,13 @@ impl Buffer<'_> {
}
}
}

pub fn to_static(&self) -> OwnedBuffer {
match self {
Buffer::Owned(d) => Buffer::Owned(d.clone()),
Buffer::View(_) => Buffer::Owned(self.into()),
}
}
}

impl<'a> Buffer<'a> {
Expand All @@ -61,17 +66,6 @@ impl<'a> Buffer<'a> {
}
}

impl ToStatic for Buffer<'_> {
type Static = Buffer<'static>;

fn to_static(&self) -> Self::Static {
match self {
Buffer::Owned(d) => Buffer::Owned(d.clone()),
Buffer::View(_) => Buffer::Owned(self.into()),
}
}
}

impl From<ArrowBuffer> for OwnedBuffer {
fn from(value: ArrowBuffer) -> Self {
Buffer::Owned(value)
Expand Down
3 changes: 2 additions & 1 deletion vortex-ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ itertools = { workspace = true }
log = { workspace = true }
nougat = "0.2.4"
vortex-array = { path = "../vortex-array" }
vortex-buffer = { path = "../vortex-buffer" }
vortex-error = { path = "../vortex-error" }
vortex-flatbuffers = { path = "../vortex-flatbuffers" }
vortex-dtype = { path = "../vortex-dtype" }
Expand All @@ -32,8 +33,8 @@ walkdir = { workspace = true }
criterion = { workspace = true }
rand = { workspace = true }
simplelog = { workspace = true }
vortex-fastlanes = { path = "../vortex-fastlanes" }
vortex-alp = { path = "../vortex-alp" }
vortex-fastlanes = { path = "../vortex-fastlanes" }
arrow = { workspace = true }
arrow-array = { workspace = true }
arrow-ipc = { workspace = true, features = ["lz4"] }
Expand Down
2 changes: 1 addition & 1 deletion vortex-ipc/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use flatbuffers::{root, root_unchecked};
use log::error;
use nougat::gat;
use vortex::array::chunked::ChunkedArray;
use vortex::buffer::Buffer;
use vortex::compute::scalar_subtract::subtract_scalar;
use vortex::compute::search_sorted::{search_sorted, SearchSortedSide};
use vortex::compute::slice::slice;
Expand All @@ -17,6 +16,7 @@ use vortex::stats::{ArrayStatistics, Stat};
use vortex::{
Array, ArrayDType, ArrayView, Context, IntoArray, OwnedArray, ToArray, ToStatic, ViewContext,
};
use vortex_buffer::Buffer;
use vortex_dtype::{match_each_integer_ptype, DType};
use vortex_error::{vortex_bail, vortex_err, VortexError, VortexResult};
use vortex_flatbuffers::ReadFlatBuffer;
Expand Down
1 change: 1 addition & 0 deletions vortex-roaring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = { workspace = true }
[dependencies]
arrow-buffer = { workspace = true }
vortex-array = { path = "../vortex-array" }
vortex-buffer = { path = "../vortex-buffer" }
vortex-error = { path = "../vortex-error" }
vortex-dtype = { path = "../vortex-dtype" }
vortex-scalar = { path = "../vortex-scalar" }
Expand Down
2 changes: 1 addition & 1 deletion vortex-roaring/src/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use compress::roaring_encode;
use croaring::{Bitmap, Portable};
use serde::{Deserialize, Serialize};
use vortex::array::bool::{Bool, BoolArray};
use vortex::buffer::Buffer;
use vortex::stats::ArrayStatisticsCompute;
use vortex::validity::{ArrayValidity, LogicalValidity, Validity};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, ArrayDType, ArrayFlatten, OwnedArray};
use vortex_buffer::Buffer;
use vortex_dtype::Nullability;
use vortex_dtype::Nullability::NonNullable;
use vortex_error::{vortex_bail, vortex_err};
Expand Down
2 changes: 1 addition & 1 deletion vortex-roaring/src/integer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use compress::roaring_encode;
use croaring::{Bitmap, Portable};
use serde::{Deserialize, Serialize};
use vortex::array::primitive::{Primitive, PrimitiveArray};
use vortex::buffer::Buffer;
use vortex::stats::ArrayStatisticsCompute;
use vortex::validity::{ArrayValidity, LogicalValidity};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, ArrayFlatten, OwnedArray};
use vortex_buffer::Buffer;
use vortex_dtype::Nullability::NonNullable;
use vortex_dtype::PType;
use vortex_error::{vortex_bail, vortex_err};
Expand Down

0 comments on commit 19ad296

Please sign in to comment.