Skip to content

Commit b6636bf

Browse files
feat: per value support for packed structs
1 parent d581bb9 commit b6636bf

3 files changed

Lines changed: 456 additions & 110 deletions

File tree

rust/lance-encoding/src/compression.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use crate::{
4949
},
5050
general::{GeneralMiniBlockCompressor, GeneralMiniBlockDecompressor},
5151
packed::{
52+
PackedStructFixedPerValueDecompressor, PackedStructFixedPerValueEncoder,
5253
PackedStructFixedWidthMiniBlockDecompressor,
5354
PackedStructFixedWidthMiniBlockEncoder, PackedStructVariablePerValueDecompressor,
5455
PackedStructVariablePerValueEncoder, VariablePackedStructFieldDecoder,
@@ -732,9 +733,9 @@ impl CompressionStrategy for DefaultCompressionStrategy {
732733
field.children.clone(),
733734
)))
734735
} else {
735-
Err(Error::invalid_input(
736-
"Packed struct per-value compression should not be used for fixed-width-only structs",
737-
))
736+
Ok(Box::new(PackedStructFixedPerValueEncoder::new(
737+
field.children.clone(),
738+
)))
738739
}
739740
}
740741
DataBlock::VariableWidth(variable_width) => {
@@ -1008,6 +1009,9 @@ impl DecompressionStrategy for DefaultDecompressionStrategy {
10081009
))),
10091010
Compression::Flat(flat) => Ok(Box::new(ValueDecompressor::from_flat(flat))),
10101011
Compression::FixedSizeList(fsl) => Ok(Box::new(ValueDecompressor::from_fsl(fsl))),
1012+
Compression::PackedStruct(description) => Ok(Box::new(
1013+
PackedStructFixedPerValueDecompressor::new(description)?,
1014+
)),
10111015
_ => todo!("fixed-per-value decompressor for {:?}", description),
10121016
}
10131017
}

rust/lance-encoding/src/encodings/logical/primitive.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5463,14 +5463,6 @@ impl PrimitiveStructuralEncoder {
54635463
variable.bits_per_offset
54645464
))
54655465
}
5466-
DataBlock::Struct(struct_data_block)
5467-
if !struct_data_block.has_variable_width_child() =>
5468-
{
5469-
Some(
5470-
"Full-zip packed struct requires at least one variable-width child"
5471-
.to_string(),
5472-
)
5473-
}
54745466
DataBlock::Dictionary(_) => {
54755467
Some("Full-zip does not encode dictionary data blocks directly".to_string())
54765468
}

0 commit comments

Comments
 (0)