Skip to content

Commit 85f85ca

Browse files
committed
usedelta
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 2b8237f commit 85f85ca

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

  • vortex-btrblocks/src/compressor

vortex-btrblocks/src/compressor/rle.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ use std::marker::PhantomData;
88
use vortex_array::ArrayRef;
99
use vortex_array::Canonical;
1010
use vortex_array::IntoArray;
11+
use vortex_array::LEGACY_SESSION;
1112
use vortex_array::ToCanonical;
13+
use vortex_array::VortexSessionExecute;
1214
use vortex_array::arrays::PrimitiveArray;
1315
use vortex_error::VortexResult;
16+
use vortex_fastlanes::DeltaArray;
1417
use vortex_fastlanes::RLEArray;
18+
use vortex_fastlanes::delta_compress;
1519

1620
use crate::BtrBlocksCompressor;
1721
use crate::CanonicalCompressor;
@@ -131,6 +135,16 @@ impl<C: RLEConfig> Scheme for RLEScheme<C> {
131135
&new_excludes,
132136
)?;
133137

138+
// Delta in an unstable encoding, once we deem it stable we can switch over to this always.
139+
#[cfg(feature = "unstable_encodings")]
140+
let compressed_indices = try_compress_delta(
141+
&rle_array.indices().to_primitive().narrow()?,
142+
compressor,
143+
ctx.descend(),
144+
Excludes::from(&[IntCode::Dict]),
145+
)?;
146+
147+
#[cfg(not(feature = "unstable_encodings"))]
134148
let compressed_indices = compressor.compress_canonical(
135149
Canonical::Primitive(rle_array.indices().to_primitive().narrow()?),
136150
ctx.descend(),
@@ -157,3 +171,22 @@ impl<C: RLEConfig> Scheme for RLEScheme<C> {
157171
}
158172
}
159173
}
174+
175+
#[cfg(feature = "unstable_encodings")]
176+
fn try_compress_delta(
177+
primitive_array: &PrimitiveArray,
178+
compressor: &BtrBlocksCompressor,
179+
ctx: CompressorContext,
180+
excludes: Excludes,
181+
) -> VortexResult<ArrayRef> {
182+
let (bases, deltas) =
183+
delta_compress(primitive_array, &mut LEGACY_SESSION.create_execution_ctx())?;
184+
185+
let compressed_bases =
186+
compressor.compress_canonical(Canonical::Primitive(bases), ctx, excludes)?;
187+
let compressed_deltas =
188+
compressor.compress_canonical(Canonical::Primitive(deltas), ctx, excludes)?;
189+
190+
DeltaArray::try_from_delta_compress_parts(compressed_bases, compressed_deltas)
191+
.map(DeltaArray::into_array)
192+
}

0 commit comments

Comments
 (0)