From c97b28405f1c709b15727ef107d16e976924bf70 Mon Sep 17 00:00:00 2001 From: Andrew Duffy Date: Tue, 1 Oct 2024 10:39:46 -0400 Subject: [PATCH] move ALP into separate module in same crate --- encodings/alp/src/{ => alp}/array.rs | 3 +-- encodings/alp/src/{ => alp}/compress.rs | 3 +-- encodings/alp/src/{ => alp}/compute.rs | 0 encodings/alp/src/{alp.rs => alp/mod.rs} | 16 +++++++++++++++- encodings/alp/src/lib.rs | 5 ----- 5 files changed, 17 insertions(+), 10 deletions(-) rename encodings/alp/src/{ => alp}/array.rs (99%) rename encodings/alp/src/{ => alp}/compress.rs (99%) rename encodings/alp/src/{ => alp}/compute.rs (100%) rename encodings/alp/src/{alp.rs => alp/mod.rs} (97%) diff --git a/encodings/alp/src/array.rs b/encodings/alp/src/alp/array.rs similarity index 99% rename from encodings/alp/src/array.rs rename to encodings/alp/src/alp/array.rs index d14fc41407..4717431557 100644 --- a/encodings/alp/src/array.rs +++ b/encodings/alp/src/alp/array.rs @@ -15,8 +15,7 @@ use vortex::{ use vortex_dtype::{DType, PType}; use vortex_error::{vortex_bail, vortex_panic, VortexExpect as _, VortexResult}; -use crate::alp::Exponents; -use crate::compress::{alp_encode, decompress}; +use crate::alp::{alp_encode, decompress, Exponents}; use crate::ALPFloat; impl_encoding!("vortex.alp", ids::ALP, ALP); diff --git a/encodings/alp/src/compress.rs b/encodings/alp/src/alp/compress.rs similarity index 99% rename from encodings/alp/src/compress.rs rename to encodings/alp/src/alp/compress.rs index 6c4dfeba7a..0d8604b11e 100644 --- a/encodings/alp/src/compress.rs +++ b/encodings/alp/src/alp/compress.rs @@ -5,8 +5,7 @@ use vortex_dtype::{NativePType, PType}; use vortex_error::{vortex_bail, VortexExpect as _, VortexResult}; use vortex_scalar::Scalar; -use crate::alp::ALPFloat; -use crate::array::ALPArray; +use crate::alp::{ALPArray, ALPFloat}; use crate::Exponents; #[macro_export] diff --git a/encodings/alp/src/compute.rs b/encodings/alp/src/alp/compute.rs similarity index 100% rename from encodings/alp/src/compute.rs rename to encodings/alp/src/alp/compute.rs diff --git a/encodings/alp/src/alp.rs b/encodings/alp/src/alp/mod.rs similarity index 97% rename from encodings/alp/src/alp.rs rename to encodings/alp/src/alp/mod.rs index 710b8b25b3..7297fc0497 100644 --- a/encodings/alp/src/alp.rs +++ b/encodings/alp/src/alp/mod.rs @@ -5,6 +5,13 @@ use itertools::Itertools; use num_traits::{CheckedSub, Float, PrimInt, ToPrimitive}; use serde::{Deserialize, Serialize}; +mod array; +mod compress; +mod compute; + +pub use array::*; +pub use compress::*; + const SAMPLE_SIZE: usize = 32; #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -19,7 +26,14 @@ impl Display for Exponents { } } -pub trait ALPFloat: Float + Display + 'static { +mod private { + pub trait Sealed {} + + impl Sealed for f32 {} + impl Sealed for f64 {} +} + +pub trait ALPFloat: private::Sealed + Float + Display + 'static { type ALPInt: PrimInt + Display + ToPrimitive; const FRACTIONAL_BITS: u8; diff --git a/encodings/alp/src/lib.rs b/encodings/alp/src/lib.rs index 9ee0ca6dd4..302a3b5b86 100644 --- a/encodings/alp/src/lib.rs +++ b/encodings/alp/src/lib.rs @@ -2,11 +2,6 @@ pub use alp::*; pub use alp_rd::*; -pub use array::*; -pub use compress::*; mod alp; mod alp_rd; -mod array; -mod compress; -mod compute;