Skip to content

Commit

Permalink
use standard compressor infra in fsst
Browse files Browse the repository at this point in the history
  • Loading branch information
danking committed Sep 30, 2024
1 parent ad4ab84 commit 43d7600
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
32 changes: 9 additions & 23 deletions vortex-sampling-compressor/src/compressors/fsst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)),
))
Expand Down
6 changes: 6 additions & 0 deletions vortex-sampling-compressor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 43d7600

Please sign in to comment.