Skip to content

Commit

Permalink
Delta lookback (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwlon authored Nov 9, 2024
1 parent 91766ae commit 29a9fcf
Show file tree
Hide file tree
Showing 55 changed files with 2,391 additions and 1,134 deletions.
6 changes: 3 additions & 3 deletions docs/benchmark_results/mbp_m3_max.csv
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
input,codec,compress_dt,decompress_dt,compressed_size
air_quality,blosc:cname=zstd:level=3,0.104805835,0.028497249,8429280
air_quality,parquet:compression=zstd1,0.2296,0.02594,11156819
air_quality,pco,0.10299417,0.021796916,4283105
air_quality,pco,0.11510511,0.022027887,4283153
air_quality,spdp,0.09585233,0.10599508,22560633
air_quality,tpfor,0.029559456,0.002875309,19114630
r_place,blosc:cname=zstd:level=3,11.372147,3.3396413,976973046
r_place,parquet:compression=zstd1,15.389868,1.9258637,961718183
r_place,pco,10.476611,1.5533803,661664577
r_place,pco,11.368066,1.5747843,661665164
r_place,spdp,11.464923,12.225844,3306514546
r_place,tpfor,2.5569496,0.5739353,2023272462
taxi,blosc:cname=zstd:level=3,6.3025703,1.8824589,841110760
taxi,parquet:compression=zstd1,5.600355,0.9174722,464867099
taxi,pco,5.3043575,0.8830483,333004373
taxi,pco,5.6141233,0.8759089,333004631
taxi,spdp,4.5603795,5.0574136,1636214754
taxi,tpfor,1.0123023,0.24857067,1452549995
41 changes: 33 additions & 8 deletions dtype_dispatch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![doc = include_str!("../README.md")]
#![allow(unreachable_patterns)]

/// Produces two macros: an enum definer and an enum matcher.
///
Expand All @@ -15,17 +16,38 @@ macro_rules! build_dtype_macros {
) => {
$(#[$definer_attrs])*
macro_rules! $definer {
(#[$enum_attrs: meta] $vis: vis $name: ident) => {
#[$enum_attrs]
#[non_exhaustive]
$vis enum $name {
$($variant,)+
}

impl $name {
#[inline]
pub fn new<T: $constraint>() -> Option<Self> {
let type_id = std::any::TypeId::of::<T>();
$(
if type_id == std::any::TypeId::of::<$t>() {
return Some($name::$variant);
}
)+
None
}
}
};
(#[$enum_attrs: meta] #[repr($desc_t: ty)] $vis: vis $name: ident = $desc_val: ident) => {
#[$enum_attrs]
#[repr($desc_t)]
#[non_exhaustive]
$vis enum $name {
$($variant = <$t>::$desc_val,)+
}

impl $name {
#[inline]
pub fn new<S: $constraint>() -> Option<Self> {
let type_id = std::any::TypeId::of::<S>();
pub fn new<T: $constraint>() -> Option<Self> {
let type_id = std::any::TypeId::of::<T>();
$(
if type_id == std::any::TypeId::of::<$t>() {
return Some($name::$variant);
Expand All @@ -50,6 +72,7 @@ macro_rules! build_dtype_macros {
}

#[$enum_attrs]
#[non_exhaustive]
$vis enum $name {
$($variant($container<$t>),)+
}
Expand Down Expand Up @@ -106,26 +129,26 @@ macro_rules! build_dtype_macros {
None
}

pub fn downcast<S: $constraint>(self) -> Option<$container<S>> {
pub fn downcast<T: $constraint>(self) -> Option<$container<T>> {
match self {
$(
Self::$variant(inner) => inner.downcast::<S>(),
Self::$variant(inner) => inner.downcast::<T>(),
)+
}
}

pub fn downcast_ref<S: $constraint>(&self) -> Option<&$container<S>> {
pub fn downcast_ref<T: $constraint>(&self) -> Option<&$container<T>> {
match self {
$(
Self::$variant(inner) => inner.downcast_ref::<S>(),
Self::$variant(inner) => inner.downcast_ref::<T>(),
)+
}
}

pub fn downcast_mut<S: $constraint>(&mut self) -> Option<&mut $container<S>> {
pub fn downcast_mut<T: $constraint>(&mut self) -> Option<&mut $container<T>> {
match self {
$(
Self::$variant(inner) => inner.downcast_mut::<S>(),
Self::$variant(inner) => inner.downcast_mut::<T>(),
)+
}
}
Expand All @@ -141,6 +164,7 @@ macro_rules! build_dtype_macros {
type $generic = $t;
$block
})+
_ => unreachable!()
}
};
($value: expr, $enum_: ident<$generic: ident>($inner: ident) => $block: block) => {
Expand All @@ -149,6 +173,7 @@ macro_rules! build_dtype_macros {
type $generic = $t;
$block
})+
_ => unreachable!()
}
};
}
Expand Down
34 changes: 17 additions & 17 deletions images/real_world_compression_ratio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 29a9fcf

Please sign in to comment.