Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dk/recursively compress fsst array #915

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion encodings/fsst/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ impl FSSTArray {
impl AcceptArrayVisitor for FSSTArray {
fn accept(&self, visitor: &mut dyn vortex::visitor::ArrayVisitor) -> VortexResult<()> {
visitor.visit_child("symbols", &self.symbols())?;
visitor.visit_child("codes", &self.codes())
visitor.visit_child("symbol_lengths", &self.symbol_lengths())?;
visitor.visit_child("codes", &self.codes())?;
visitor.visit_child("uncompressed_lengths", &self.uncompressed_lengths())
}
}

Expand Down
23 changes: 20 additions & 3 deletions vortex-sampling-compressor/src/compressors/fsst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt::Debug;
use std::sync::Arc;

use fsst::Compressor;
use vortex::array::{VarBin, VarBinView};
use vortex::array::{VarBin, VarBinArray, VarBinView};
use vortex::encoding::EncodingRef;
use vortex::{ArrayDType, ArrayDef, IntoArray};
use vortex_dtype::DType;
Expand Down Expand Up @@ -91,18 +91,35 @@ 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_compressed = codes_compressor.auxiliary("offsets").compress(
&codes_varbin.offsets(),
like.as_ref().and_then(|l| l.child(1)),
)?;

let codes = VarBinArray::try_new(
codes_offsets_compressed.array,
codes_varbin.bytes(),
codes_varbin_dtype,
codes_varbin.validity(),
)?
.into_array();

Ok(CompressedArray::new(
FSSTArray::try_new(
fsst_array.dtype().clone(),
fsst_array.symbols(),
fsst_array.symbol_lengths(),
fsst_array.codes(),
codes,
uncompressed_lengths.array,
)?
.into_array(),
Some(CompressionTree::new_with_metadata(
self,
vec![uncompressed_lengths.path],
vec![uncompressed_lengths.path, codes_offsets_compressed.path],
compressor,
)),
))
Expand Down
Loading