From 43d76007594c8e138c782fcb3d4c8487e13eeb2e Mon Sep 17 00:00:00 2001 From: Daniel King Date: Mon, 30 Sep 2024 13:14:47 -0400 Subject: [PATCH] use standard compressor infra in fsst --- .../src/compressors/fsst.rs | 32 ++++++------------- vortex-sampling-compressor/src/lib.rs | 6 ++++ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/vortex-sampling-compressor/src/compressors/fsst.rs b/vortex-sampling-compressor/src/compressors/fsst.rs index 844ee828e0..619f34383b 100644 --- a/vortex-sampling-compressor/src/compressors/fsst.rs +++ b/vortex-sampling-compressor/src/compressors/fsst.rs @@ -93,26 +93,17 @@ impl EncodingCompressor for FSSTCompressor { like.as_ref().and_then(|l| l.child(0)), )?; - let codes_compressor = ctx.auxiliary("codes"); let codes_varbin = VarBinArray::try_from(fsst_array.codes())?; let codes_varbin_dtype = codes_varbin.dtype().clone(); - let codes_offsets_for = FoRCompressor.compress( - &codes_varbin.offsets(), - like.as_ref().and_then(|l| l.child(1).cloned()), - ctx.auxiliary("offsets_for"), - )?; - - let codes_offsets_delta = DeltaCompressor.compress( - &codes_offsets_for.array, - like.as_ref().and_then(|l| l.child(2).cloned()), - ctx.auxiliary("offsets_for_delta"), - )?; - - let codes_offsets_compressed = codes_compressor.auxiliary("delta_offsets").compress( - &codes_offsets_delta.array, - like.as_ref().and_then(|l| l.child(3)), - )?; + let codes_offsets_compressed = ctx + .named("codes_varbin_offsets") + .excluding(self) + .including(&DeltaCompressor) + .compress( + &codes_varbin.offsets(), + like.as_ref().and_then(|l| l.child(1)), + )?; let codes = VarBinArray::try_new( codes_offsets_compressed.array, @@ -133,12 +124,7 @@ impl EncodingCompressor for FSSTCompressor { .into_array(), Some(CompressionTree::new_with_metadata( self, - vec![ - uncompressed_lengths.path, - codes_offsets_for.path, - codes_offsets_delta.path, - codes_offsets_compressed.path, - ], + vec![uncompressed_lengths.path, codes_offsets_compressed.path], compressor, )), )) diff --git a/vortex-sampling-compressor/src/lib.rs b/vortex-sampling-compressor/src/lib.rs index 50edc93115..f6a7790eb7 100644 --- a/vortex-sampling-compressor/src/lib.rs +++ b/vortex-sampling-compressor/src/lib.rs @@ -165,6 +165,12 @@ impl<'a> SamplingCompressor<'a> { cloned } + pub fn including(&self, compressor: CompressorRef<'a>) -> Self { + let mut cloned = self.clone(); + cloned.compressors.insert(compressor); + cloned + } + #[allow(clippy::same_name_method)] pub fn compress( &self,