From eca9c20a1386319374a3bed64e3a15a2b1f17644 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 13:17:52 +0000 Subject: [PATCH 1/6] Encoding ID --- bench-vortex/src/lib.rs | 55 ++++++------------- pyvortex/src/array.rs | 2 +- vortex-alp/src/array.rs | 4 +- vortex-array/src/array/bool/mod.rs | 4 +- vortex-array/src/array/chunked/mod.rs | 4 +- vortex-array/src/array/composite/array.rs | 4 +- vortex-array/src/array/composite/compress.rs | 2 +- vortex-array/src/array/constant/mod.rs | 4 +- vortex-array/src/array/mod.rs | 6 +- .../src/array/primitive/compute/patch.rs | 2 +- vortex-array/src/array/primitive/mod.rs | 4 +- vortex-array/src/array/sparse/compress.rs | 2 +- vortex-array/src/array/sparse/mod.rs | 4 +- vortex-array/src/array/struct_/compress.rs | 2 +- vortex-array/src/array/struct_/mod.rs | 4 +- vortex-array/src/array/varbin/compress.rs | 2 +- vortex-array/src/array/varbin/mod.rs | 4 +- vortex-array/src/array/varbinview/mod.rs | 4 +- vortex-array/src/compress.rs | 44 +++++++++++---- vortex-array/src/error.rs | 4 +- vortex-array/src/serde/mod.rs | 4 +- vortex-datetime/src/compress.rs | 2 +- vortex-datetime/src/datetime.rs | 8 ++- vortex-dict/src/compress.rs | 4 +- vortex-dict/src/dict.rs | 4 +- vortex-fastlanes/src/bitpacking/mod.rs | 4 +- vortex-fastlanes/src/for/mod.rs | 4 +- vortex-ree/src/ree.rs | 4 +- vortex-roaring/src/boolean/compress.rs | 2 +- vortex-roaring/src/boolean/mod.rs | 4 +- vortex-roaring/src/integer/compress.rs | 2 +- vortex-roaring/src/integer/mod.rs | 4 +- vortex-zigzag/src/zigzag.rs | 4 +- 33 files changed, 106 insertions(+), 105 deletions(-) diff --git a/bench-vortex/src/lib.rs b/bench-vortex/src/lib.rs index 607a743181..f2f6413fda 100644 --- a/bench-vortex/src/lib.rs +++ b/bench-vortex/src/lib.rs @@ -9,18 +9,10 @@ use log::{info, warn}; use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder; use parquet::arrow::ProjectionMask; -use vortex::array::bool::BoolEncoding; -use vortex::array::chunked::{ChunkedArray, ChunkedEncoding}; -use vortex::array::composite::CompositeEncoding; -use vortex::array::constant::ConstantEncoding; +use vortex::array::chunked::ChunkedArray; use vortex::array::downcast::DowncastArrayBuiltin; -use vortex::array::primitive::PrimitiveEncoding; -use vortex::array::sparse::SparseEncoding; -use vortex::array::struct_::StructEncoding; -use vortex::array::varbin::VarBinEncoding; -use vortex::array::varbinview::VarBinViewEncoding; -use vortex::array::IntoArray; -use vortex::array::{Array, ArrayRef, Encoding}; +use vortex::array::{Array, ArrayRef}; +use vortex::array::{EncodingId, IntoArray}; use vortex::arrow::FromArrowType; use vortex::compress::{CompressConfig, CompressCtx}; use vortex::formatter::display_tree; @@ -32,40 +24,25 @@ use vortex_ree::REEEncoding; use vortex_roaring::RoaringBoolEncoding; use vortex_schema::DType; -pub fn enumerate_arrays() -> Vec<&'static dyn Encoding> { +pub fn enumerate_arrays() -> Vec { vec![ - // TODO(ngates): fix https://github.com/fulcrum-so/vortex/issues/35 - // Builtins - &BoolEncoding, - &ChunkedEncoding, - &CompositeEncoding, - &ConstantEncoding, - &PrimitiveEncoding, - &SparseEncoding, - &StructEncoding, - &VarBinEncoding, - &VarBinViewEncoding, - // Encodings - &ALPEncoding, - &DictEncoding, - &BitPackedEncoding, - &FoREncoding, - &DateTimeEncoding, - // &DeltaEncoding, - // &FFoREncoding, - &REEEncoding, - &RoaringBoolEncoding, - // &RoaringIntEncoding, + ALPEncoding::ID, + DictEncoding::ID, + BitPackedEncoding::ID, + FoREncoding::ID, + DateTimeEncoding::ID, + // DeltaEncoding::ID, + // FFoREncoding::ID, + REEEncoding::ID, + RoaringBoolEncoding::ID, + // RoaringIntEncoding::ID, // Doesn't offer anything more than FoR really - // &ZigZagEncoding, + // ZigZagEncoding::ID, ] } pub fn compress_ctx() -> CompressCtx { - let cfg = CompressConfig::new( - HashSet::from_iter(enumerate_arrays().iter().map(|e| (*e).id())), - HashSet::default(), - ); + let cfg = CompressConfig::new(HashSet::from_iter(enumerate_arrays()), HashSet::default()); info!("Compression config {cfg:?}"); CompressCtx::new(Arc::new(cfg)) } diff --git a/pyvortex/src/array.rs b/pyvortex/src/array.rs index f233018a0f..13902764cd 100644 --- a/pyvortex/src/array.rs +++ b/pyvortex/src/array.rs @@ -111,7 +111,7 @@ impl PyArray { inner.into_any().downcast::().unwrap(), )? .extract(py), - ArrayKind::Other(other) => match *other.encoding().id() { + ArrayKind::Other(other) => match other.encoding().id() { // PyEnc chooses to expose certain encodings as first-class objects. // For the remainder, we should have a generic EncArray implementation that supports basic functions. ALPEncoding::ID => { diff --git a/vortex-alp/src/array.rs b/vortex-alp/src/array.rs index cc234d4340..c3233fb10a 100644 --- a/vortex-alp/src/array.rs +++ b/vortex-alp/src/array.rs @@ -131,8 +131,8 @@ impl ALPEncoding { } impl Encoding for ALPEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-array/src/array/bool/mod.rs b/vortex-array/src/array/bool/mod.rs index 76b5826383..9332a2cc76 100644 --- a/vortex-array/src/array/bool/mod.rs +++ b/vortex-array/src/array/bool/mod.rs @@ -139,8 +139,8 @@ impl BoolEncoding { static ENCODINGS_BOOL: EncodingRef = &BoolEncoding; impl Encoding for BoolEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn serde(&self) -> Option<&dyn EncodingSerde> { diff --git a/vortex-array/src/array/chunked/mod.rs b/vortex-array/src/array/chunked/mod.rs index b6769b3636..810f2d34f4 100644 --- a/vortex-array/src/array/chunked/mod.rs +++ b/vortex-array/src/array/chunked/mod.rs @@ -183,8 +183,8 @@ impl ChunkedEncoding { static ENCODINGS_CHUNKED: EncodingRef = &ChunkedEncoding; impl Encoding for ChunkedEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn serde(&self) -> Option<&dyn EncodingSerde> { diff --git a/vortex-array/src/array/composite/array.rs b/vortex-array/src/array/composite/array.rs index 305b4cdf88..7af8f32dd2 100644 --- a/vortex-array/src/array/composite/array.rs +++ b/vortex-array/src/array/composite/array.rs @@ -140,8 +140,8 @@ impl CompositeEncoding { static ENCODINGS_COMPOSITE: EncodingRef = &CompositeEncoding; impl Encoding for CompositeEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-array/src/array/composite/compress.rs b/vortex-array/src/array/composite/compress.rs index 3755de9f85..544b24bf8b 100644 --- a/vortex-array/src/array/composite/compress.rs +++ b/vortex-array/src/array/composite/compress.rs @@ -14,7 +14,7 @@ impl EncodingCompression for CompositeEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { - (array.encoding().id() == &Self::ID).then_some(self) + (array.encoding().id() == Self::ID).then_some(self) } fn compress( diff --git a/vortex-array/src/array/constant/mod.rs b/vortex-array/src/array/constant/mod.rs index 403dfe6a1d..1a4b8b7f57 100644 --- a/vortex-array/src/array/constant/mod.rs +++ b/vortex-array/src/array/constant/mod.rs @@ -109,8 +109,8 @@ impl ConstantEncoding { static ENCODINGS_CONSTANT: EncodingRef = &ConstantEncoding; impl Encoding for ConstantEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn serde(&self) -> Option<&dyn EncodingSerde> { diff --git a/vortex-array/src/array/mod.rs b/vortex-array/src/array/mod.rs index 3df3535392..cdbd93c880 100644 --- a/vortex-array/src/array/mod.rs +++ b/vortex-array/src/array/mod.rs @@ -247,7 +247,7 @@ pub fn check_validity_buffer(validity: Option<&ArrayRef>, expected_len: usize) - Ok(()) } -#[derive(Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub struct EncodingId(&'static str); impl EncodingId { @@ -268,7 +268,7 @@ impl Display for EncodingId { } pub trait Encoding: Debug + Send + Sync + 'static { - fn id(&self) -> &EncodingId; + fn id(&self) -> EncodingId; /// Whether this encoding provides a compressor. fn compression(&self) -> Option<&dyn EncodingCompression> { @@ -308,7 +308,7 @@ pub enum ArrayKind<'a> { impl<'a> From<&'a dyn Array> for ArrayKind<'a> { fn from(value: &'a dyn Array) -> Self { - match *value.encoding().id() { + match value.encoding().id() { BoolEncoding::ID => ArrayKind::Bool(value.as_bool()), ChunkedEncoding::ID => ArrayKind::Chunked(value.as_chunked()), CompositeEncoding::ID => ArrayKind::Composite(value.as_composite()), diff --git a/vortex-array/src/array/primitive/compute/patch.rs b/vortex-array/src/array/primitive/compute/patch.rs index ad70807ed2..6434a118dc 100644 --- a/vortex-array/src/array/primitive/compute/patch.rs +++ b/vortex-array/src/array/primitive/compute/patch.rs @@ -11,7 +11,7 @@ use crate::{compute, match_each_native_ptype}; impl PatchFn for PrimitiveArray { fn patch(&self, patch: &dyn Array) -> VortexResult { match patch.encoding().id() { - &SparseEncoding::ID => patch_with_sparse(self, patch.as_sparse()), + SparseEncoding::ID => patch_with_sparse(self, patch.as_sparse()), // TODO(ngates): support a default implementation based on iter_arrow? _ => Err(VortexError::MissingKernel( "patch", diff --git a/vortex-array/src/array/primitive/mod.rs b/vortex-array/src/array/primitive/mod.rs index 6be46f49cf..74bae68b6e 100644 --- a/vortex-array/src/array/primitive/mod.rs +++ b/vortex-array/src/array/primitive/mod.rs @@ -229,8 +229,8 @@ impl PrimitiveEncoding { static ENCODINGS_PRIMITIVE: EncodingRef = &PrimitiveEncoding; impl Encoding for PrimitiveEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn serde(&self) -> Option<&dyn EncodingSerde> { diff --git a/vortex-array/src/array/sparse/compress.rs b/vortex-array/src/array/sparse/compress.rs index f6a6bf5733..3e668d27a1 100644 --- a/vortex-array/src/array/sparse/compress.rs +++ b/vortex-array/src/array/sparse/compress.rs @@ -14,7 +14,7 @@ impl EncodingCompression for SparseEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { - (array.encoding().id() == &Self::ID).then_some(self) + (array.encoding().id() == Self::ID).then_some(self) } fn compress( diff --git a/vortex-array/src/array/sparse/mod.rs b/vortex-array/src/array/sparse/mod.rs index 1270ed103b..80b97bb7bb 100644 --- a/vortex-array/src/array/sparse/mod.rs +++ b/vortex-array/src/array/sparse/mod.rs @@ -163,8 +163,8 @@ impl SparseEncoding { static ENCODINGS_SPARSE: EncodingRef = &SparseEncoding; impl Encoding for SparseEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-array/src/array/struct_/compress.rs b/vortex-array/src/array/struct_/compress.rs index c81545835d..200251ad49 100644 --- a/vortex-array/src/array/struct_/compress.rs +++ b/vortex-array/src/array/struct_/compress.rs @@ -11,7 +11,7 @@ impl EncodingCompression for StructEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { - (array.encoding().id() == &Self::ID).then_some(self) + (array.encoding().id() == Self::ID).then_some(self) } fn compress( diff --git a/vortex-array/src/array/struct_/mod.rs b/vortex-array/src/array/struct_/mod.rs index 2cb29f6154..68c863448b 100644 --- a/vortex-array/src/array/struct_/mod.rs +++ b/vortex-array/src/array/struct_/mod.rs @@ -125,8 +125,8 @@ impl StructEncoding { static ENCODINGS_STRUCT: EncodingRef = &StructEncoding; impl Encoding for StructEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-array/src/array/varbin/compress.rs b/vortex-array/src/array/varbin/compress.rs index 36614271a2..53220bf2b9 100644 --- a/vortex-array/src/array/varbin/compress.rs +++ b/vortex-array/src/array/varbin/compress.rs @@ -14,7 +14,7 @@ impl EncodingCompression for VarBinEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { - (array.encoding().id() == &Self::ID).then_some(self) + (array.encoding().id() == Self::ID).then_some(self) } fn compress( diff --git a/vortex-array/src/array/varbin/mod.rs b/vortex-array/src/array/varbin/mod.rs index 71596ae5ed..b9860e94c9 100644 --- a/vortex-array/src/array/varbin/mod.rs +++ b/vortex-array/src/array/varbin/mod.rs @@ -276,8 +276,8 @@ impl VarBinEncoding { static ENCODINGS_VARBIN: EncodingRef = &VarBinEncoding; impl Encoding for VarBinEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-array/src/array/varbinview/mod.rs b/vortex-array/src/array/varbinview/mod.rs index 22cc177fde..081f1d1020 100644 --- a/vortex-array/src/array/varbinview/mod.rs +++ b/vortex-array/src/array/varbinview/mod.rs @@ -266,8 +266,8 @@ impl VarBinViewEncoding { static ENCODINGS_VARBINVIEW: EncodingRef = &VarBinViewEncoding; impl Encoding for VarBinViewEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn serde(&self) -> Option<&dyn EncodingSerde> { diff --git a/vortex-array/src/compress.rs b/vortex-array/src/compress.rs index 10177e7fc8..8df46244d2 100644 --- a/vortex-array/src/compress.rs +++ b/vortex-array/src/compress.rs @@ -1,12 +1,19 @@ use std::collections::HashSet; +use std::convert::Into; use std::fmt::{Debug, Display, Formatter}; use std::sync::Arc; use log::{debug, info, warn}; -use crate::array::chunked::ChunkedArray; +use crate::array::bool::BoolEncoding; +use crate::array::chunked::{ChunkedArray, ChunkedEncoding}; +use crate::array::composite::CompositeEncoding; use crate::array::constant::{ConstantArray, ConstantEncoding}; -use crate::array::struct_::StructArray; +use crate::array::primitive::PrimitiveEncoding; +use crate::array::sparse::SparseEncoding; +use crate::array::struct_::{StructArray, StructEncoding}; +use crate::array::varbin::VarBinEncoding; +use crate::array::varbinview::VarBinViewEncoding; use crate::array::{Array, ArrayKind, ArrayRef, Encoding, EncodingId, ENCODINGS}; use crate::compute; use crate::compute::scalar_at::scalar_at; @@ -47,8 +54,8 @@ pub struct CompressConfig { max_depth: u8, // TODO(ngates): can each encoding define their own configs? pub ree_average_run_threshold: f32, - encodings: HashSet<&'static EncodingId>, - disabled_encodings: HashSet<&'static EncodingId>, + encodings: HashSet, + disabled_encodings: HashSet, } impl Default for CompressConfig { @@ -68,12 +75,27 @@ impl Default for CompressConfig { } impl CompressConfig { + const DEFAULT_ENCODINGS: [EncodingId; 9] = [ + BoolEncoding::ID, + ChunkedEncoding::ID, + CompositeEncoding::ID, + ConstantEncoding::ID, + PrimitiveEncoding::ID, + SparseEncoding::ID, + StructEncoding::ID, + VarBinEncoding::ID, + VarBinViewEncoding::ID, + ]; + pub fn new( - encodings: HashSet<&'static EncodingId>, - mut disabled_encodings: HashSet<&'static EncodingId>, + mut encodings: HashSet, + mut disabled_encodings: HashSet, ) -> Self { + Self::DEFAULT_ENCODINGS.iter().for_each(|e| { + encodings.insert(*e); + }); // Always disable constant encoding, it's handled separately - disabled_encodings.insert(&ConstantEncoding::ID); + disabled_encodings.insert(ConstantEncoding::ID); Self { encodings, disabled_encodings, @@ -91,9 +113,9 @@ impl CompressConfig { ) } - pub fn is_enabled(&self, kind: &EncodingId) -> bool { - (self.encodings.is_empty() || self.encodings.contains(kind)) - && !self.disabled_encodings.contains(kind) + pub fn is_enabled(&self, kind: EncodingId) -> bool { + (self.encodings.is_empty() || self.encodings.contains(&kind)) + && !self.disabled_encodings.contains(&kind) } } @@ -236,7 +258,7 @@ pub fn sampled_compression(array: &dyn Array, ctx: &CompressCtx) -> VortexResult let mut candidates: Vec<&dyn EncodingCompression> = ENCODINGS .iter() .filter(|encoding| ctx.options().is_enabled(encoding.id())) - .filter(|encoding| !ctx.disabled_encodings.contains(encoding.id())) + .filter(|encoding| !ctx.disabled_encodings.contains(&encoding.id())) .filter_map(|encoding| encoding.compression()) .filter(|compression| { if compression diff --git a/vortex-array/src/error.rs b/vortex-array/src/error.rs index b5109b5e81..c7402e7709 100644 --- a/vortex-array/src/error.rs +++ b/vortex-array/src/error.rs @@ -17,10 +17,10 @@ pub enum VortexError { InvalidArgument(ErrString), // Used when a function is not implemented for a given array type. #[error("function {0} not implemented for {1}")] - NotImplemented(&'static str, &'static EncodingId), + NotImplemented(&'static str, EncodingId), // Used when a function is implemented for an array type, but the RHS is not supported. #[error("missing kernel {0} for {1} and {2:?}")] - MissingKernel(&'static str, &'static EncodingId, Vec<&'static EncodingId>), + MissingKernel(&'static str, EncodingId, Vec), #[error("invalid data type: {0}")] InvalidDType(DType), #[error("invalid physical type: {0:?}")] diff --git a/vortex-array/src/serde/mod.rs b/vortex-array/src/serde/mod.rs index 04dd6b6d8e..95e627bb4e 100644 --- a/vortex-array/src/serde/mod.rs +++ b/vortex-array/src/serde/mod.rs @@ -35,7 +35,7 @@ where pub struct ReadCtx<'a> { schema: &'a DType, - encodings: Vec<&'static EncodingId>, + encodings: Vec, r: &'a mut dyn Read, } @@ -167,7 +167,7 @@ impl<'a> ReadCtx<'a> { pub struct WriteCtx<'a> { w: &'a mut dyn Write, - available_encodings: Vec<&'static EncodingId>, + available_encodings: Vec, } impl<'a> WriteCtx<'a> { diff --git a/vortex-datetime/src/compress.rs b/vortex-datetime/src/compress.rs index 93dea2debf..df5c8f5842 100644 --- a/vortex-datetime/src/compress.rs +++ b/vortex-datetime/src/compress.rs @@ -17,7 +17,7 @@ impl EncodingCompression for DateTimeEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { - if array.encoding().id() != &CompositeEncoding::ID { + if array.encoding().id() != CompositeEncoding::ID { return None; } diff --git a/vortex-datetime/src/datetime.rs b/vortex-datetime/src/datetime.rs index 679cd428be..f95fe6214b 100644 --- a/vortex-datetime/src/datetime.rs +++ b/vortex-datetime/src/datetime.rs @@ -136,11 +136,13 @@ impl ArrayDisplay for DateTimeArray { #[derive(Debug)] pub struct DateTimeEncoding; -pub const DATETIME_ENCODING: EncodingId = EncodingId::new("vortex.datetime"); +impl DateTimeEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.datetime"); +} impl Encoding for DateTimeEncoding { - fn id(&self) -> &EncodingId { - &DATETIME_ENCODING + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-dict/src/compress.rs b/vortex-dict/src/compress.rs index 84ce7977b0..09902ea8fa 100644 --- a/vortex-dict/src/compress.rs +++ b/vortex-dict/src/compress.rs @@ -27,8 +27,8 @@ impl EncodingCompression for DictEncoding { _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { // TODO(robert): Add support for VarBinView - if array.encoding().id() != &PrimitiveEncoding::ID - && array.encoding().id() != &VarBinEncoding::ID + if array.encoding().id() != PrimitiveEncoding::ID + && array.encoding().id() != VarBinEncoding::ID { return None; }; diff --git a/vortex-dict/src/dict.rs b/vortex-dict/src/dict.rs index 70337dbae1..55c7035cae 100644 --- a/vortex-dict/src/dict.rs +++ b/vortex-dict/src/dict.rs @@ -96,8 +96,8 @@ impl DictEncoding { } impl Encoding for DictEncoding { - fn id(&self) -> &'static EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-fastlanes/src/bitpacking/mod.rs b/vortex-fastlanes/src/bitpacking/mod.rs index 143601ded6..7b822573a1 100644 --- a/vortex-fastlanes/src/bitpacking/mod.rs +++ b/vortex-fastlanes/src/bitpacking/mod.rs @@ -146,8 +146,8 @@ impl BitPackedEncoding { } impl Encoding for BitPackedEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-fastlanes/src/for/mod.rs b/vortex-fastlanes/src/for/mod.rs index e5f1779920..a7e6c86ef2 100644 --- a/vortex-fastlanes/src/for/mod.rs +++ b/vortex-fastlanes/src/for/mod.rs @@ -119,8 +119,8 @@ impl FoREncoding { } impl Encoding for FoREncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-ree/src/ree.rs b/vortex-ree/src/ree.rs index ce98bae435..6655016a21 100644 --- a/vortex-ree/src/ree.rs +++ b/vortex-ree/src/ree.rs @@ -174,8 +174,8 @@ impl REEEncoding { } impl Encoding for REEEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-roaring/src/boolean/compress.rs b/vortex-roaring/src/boolean/compress.rs index 842b244903..732c269315 100644 --- a/vortex-roaring/src/boolean/compress.rs +++ b/vortex-roaring/src/boolean/compress.rs @@ -17,7 +17,7 @@ impl EncodingCompression for RoaringBoolEncoding { _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { // Only support bool enc arrays - if array.encoding().id() != &BoolEncoding::ID { + if array.encoding().id() != BoolEncoding::ID { return None; } diff --git a/vortex-roaring/src/boolean/mod.rs b/vortex-roaring/src/boolean/mod.rs index 50ba74ca7b..c4cba2f46a 100644 --- a/vortex-roaring/src/boolean/mod.rs +++ b/vortex-roaring/src/boolean/mod.rs @@ -114,8 +114,8 @@ impl RoaringBoolEncoding { } impl Encoding for RoaringBoolEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-roaring/src/integer/compress.rs b/vortex-roaring/src/integer/compress.rs index 42318f16ee..8bb94b7ff2 100644 --- a/vortex-roaring/src/integer/compress.rs +++ b/vortex-roaring/src/integer/compress.rs @@ -22,7 +22,7 @@ impl EncodingCompression for RoaringIntEncoding { _config: &CompressConfig, ) -> Option<&dyn EncodingCompression> { // Only support primitive enc arrays - if array.encoding().id() != &PrimitiveEncoding::ID { + if array.encoding().id() != PrimitiveEncoding::ID { return None; } diff --git a/vortex-roaring/src/integer/mod.rs b/vortex-roaring/src/integer/mod.rs index a4e82ec4a9..5433fd15b0 100644 --- a/vortex-roaring/src/integer/mod.rs +++ b/vortex-roaring/src/integer/mod.rs @@ -116,8 +116,8 @@ impl RoaringIntEncoding { } impl Encoding for RoaringIntEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-zigzag/src/zigzag.rs b/vortex-zigzag/src/zigzag.rs index 9507429b45..dcfe05eec8 100644 --- a/vortex-zigzag/src/zigzag.rs +++ b/vortex-zigzag/src/zigzag.rs @@ -105,8 +105,8 @@ impl ZigZagEncoding { } impl Encoding for ZigZagEncoding { - fn id(&self) -> &EncodingId { - &Self::ID + fn id(&self) -> EncodingId { + Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { From 5b922b0281dd7dbda035a5b8f623cdd54a81c868 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 13:18:04 +0000 Subject: [PATCH 2/6] Encoding ID --- vortex-alp/src/array.rs | 2 +- vortex-ree/src/ree.rs | 2 +- vortex-roaring/src/boolean/mod.rs | 2 +- vortex-roaring/src/integer/mod.rs | 2 +- vortex-zigzag/src/zigzag.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vortex-alp/src/array.rs b/vortex-alp/src/array.rs index c3233fb10a..3e457aa616 100644 --- a/vortex-alp/src/array.rs +++ b/vortex-alp/src/array.rs @@ -51,7 +51,7 @@ impl ALPArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Primitive(p) => Ok(alp_encode(p)?.into_array()), - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } diff --git a/vortex-ree/src/ree.rs b/vortex-ree/src/ree.rs index 6655016a21..267652a5f9 100644 --- a/vortex-ree/src/ree.rs +++ b/vortex-ree/src/ree.rs @@ -82,7 +82,7 @@ impl REEArray { ) .into_array()) } - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } diff --git a/vortex-roaring/src/boolean/mod.rs b/vortex-roaring/src/boolean/mod.rs index c4cba2f46a..19cbb3eb14 100644 --- a/vortex-roaring/src/boolean/mod.rs +++ b/vortex-roaring/src/boolean/mod.rs @@ -43,7 +43,7 @@ impl RoaringBoolArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Bool(p) => Ok(roaring_encode(p)), - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } } diff --git a/vortex-roaring/src/integer/mod.rs b/vortex-roaring/src/integer/mod.rs index 5433fd15b0..297bf2a43e 100644 --- a/vortex-roaring/src/integer/mod.rs +++ b/vortex-roaring/src/integer/mod.rs @@ -55,7 +55,7 @@ impl RoaringIntArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Primitive(p) => Ok(roaring_encode(p)), - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } } diff --git a/vortex-zigzag/src/zigzag.rs b/vortex-zigzag/src/zigzag.rs index dcfe05eec8..68df1d28d5 100644 --- a/vortex-zigzag/src/zigzag.rs +++ b/vortex-zigzag/src/zigzag.rs @@ -40,7 +40,7 @@ impl ZigZagArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Primitive(p) => Ok(zigzag_encode(p)?.into_array()), - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } From 59c554e18d8240fe6679cd7a9ae0422d2638be71 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 13:19:28 +0000 Subject: [PATCH 3/6] Encoding ID --- vortex-alp/src/array.rs | 2 +- vortex-fastlanes/src/for/compress.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/vortex-alp/src/array.rs b/vortex-alp/src/array.rs index 3e457aa616..c3233fb10a 100644 --- a/vortex-alp/src/array.rs +++ b/vortex-alp/src/array.rs @@ -51,7 +51,7 @@ impl ALPArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Primitive(p) => Ok(alp_encode(p)?.into_array()), - _ => Err(VortexError::InvalidEncoding(array.encoding().id())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), } } diff --git a/vortex-fastlanes/src/for/compress.rs b/vortex-fastlanes/src/for/compress.rs index 68222e88b5..b030e443d9 100644 --- a/vortex-fastlanes/src/for/compress.rs +++ b/vortex-fastlanes/src/for/compress.rs @@ -139,7 +139,6 @@ mod test { use std::collections::HashSet; use std::sync::Arc; - use vortex::array::primitive::PrimitiveEncoding; use vortex::array::Encoding; use crate::BitPackedEncoding; @@ -149,11 +148,7 @@ mod test { fn compress_ctx() -> CompressCtx { let cfg = CompressConfig::new( // We need some BitPacking else we will need choose FoR. - HashSet::from([ - PrimitiveEncoding.id(), - FoREncoding.id(), - BitPackedEncoding.id(), - ]), + HashSet::from([FoREncoding.id(), BitPackedEncoding.id()]), HashSet::default(), ); CompressCtx::new(Arc::new(cfg)) From 1071af979b4b702433049c0b214b1ae8781bb0e2 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 13:21:24 +0000 Subject: [PATCH 4/6] Encoding ID --- vortex-array/src/compress.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vortex-array/src/compress.rs b/vortex-array/src/compress.rs index 8df46244d2..b67e645634 100644 --- a/vortex-array/src/compress.rs +++ b/vortex-array/src/compress.rs @@ -75,16 +75,12 @@ impl Default for CompressConfig { } impl CompressConfig { - const DEFAULT_ENCODINGS: [EncodingId; 9] = [ - BoolEncoding::ID, + const DEFAULT_ENCODINGS: [EncodingId; 5] = [ ChunkedEncoding::ID, CompositeEncoding::ID, - ConstantEncoding::ID, - PrimitiveEncoding::ID, SparseEncoding::ID, StructEncoding::ID, VarBinEncoding::ID, - VarBinViewEncoding::ID, ]; pub fn new( From 063370b34afcb3385d24c009ca87d4f7eaf54130 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 13:57:57 +0000 Subject: [PATCH 5/6] Delta fixes --- vortex-alp/src/array.rs | 2 +- vortex-array/src/compress.rs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/vortex-alp/src/array.rs b/vortex-alp/src/array.rs index c3233fb10a..3e457aa616 100644 --- a/vortex-alp/src/array.rs +++ b/vortex-alp/src/array.rs @@ -51,7 +51,7 @@ impl ALPArray { pub fn encode(array: &dyn Array) -> VortexResult { match ArrayKind::from(array) { ArrayKind::Primitive(p) => Ok(alp_encode(p)?.into_array()), - _ => Err(VortexError::InvalidEncoding(array.encoding().id().clone())), + _ => Err(VortexError::InvalidEncoding(array.encoding().id())), } } diff --git a/vortex-array/src/compress.rs b/vortex-array/src/compress.rs index b67e645634..11269c826d 100644 --- a/vortex-array/src/compress.rs +++ b/vortex-array/src/compress.rs @@ -5,15 +5,12 @@ use std::sync::Arc; use log::{debug, info, warn}; -use crate::array::bool::BoolEncoding; use crate::array::chunked::{ChunkedArray, ChunkedEncoding}; use crate::array::composite::CompositeEncoding; use crate::array::constant::{ConstantArray, ConstantEncoding}; -use crate::array::primitive::PrimitiveEncoding; use crate::array::sparse::SparseEncoding; use crate::array::struct_::{StructArray, StructEncoding}; use crate::array::varbin::VarBinEncoding; -use crate::array::varbinview::VarBinViewEncoding; use crate::array::{Array, ArrayKind, ArrayRef, Encoding, EncodingId, ENCODINGS}; use crate::compute; use crate::compute::scalar_at::scalar_at; From 537404455f414b0f6e91735972f674d47f553713 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Fri, 22 Mar 2024 14:02:05 +0000 Subject: [PATCH 6/6] Delta fixes --- vortex-array/src/compress.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/vortex-array/src/compress.rs b/vortex-array/src/compress.rs index 11269c826d..558eaa4d3a 100644 --- a/vortex-array/src/compress.rs +++ b/vortex-array/src/compress.rs @@ -1,5 +1,4 @@ use std::collections::HashSet; -use std::convert::Into; use std::fmt::{Debug, Display, Formatter}; use std::sync::Arc;