Skip to content
Draft
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions docs/specs/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Every file you write carries the read-forever guarantee. If a file would contain
outside the targeted edition, the write fails immediately; edition violations never surface as
someone else's read error later.

The enabled editions are stored on the writer's Vortex session. Registering an edition makes
its declaration available to the session; enabling it separately allows the writer to emit its
encodings. Enabling another edition from the same family replaces the earlier selection.

Two knobs exist when the default is not what you want:

- **Pin an older edition** when files must stay readable by deployments running older Vortex.
Expand All @@ -45,9 +49,10 @@ Two knobs exist when the default is not what you want:
example spatial encodings) possible later. A writer targets at most one edition per family
and may emit any encoding in their union; each encoding belongs to exactly one family.

You can also opt out of editions entirely to write custom or experimental encodings. Doing so
is an explicit choice that gives up the standardization guarantee — only readers that know your
encodings can read those files.
Lower-level sessions without an enabled-editions store opt out of editions entirely and can write
custom or experimental encodings. A raw `with_allow_encodings` writer policy is another explicit
opt-out. Either choice gives up the standardization guarantee — only readers that know those
encodings can read the files.

## How editions change

Expand Down
7 changes: 1 addition & 6 deletions encodings/parquet-variant/src/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ mod tests {
use vortex_array::Canonical;
use vortex_array::EqMode;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::VarBinViewArray;
Expand Down Expand Up @@ -400,11 +399,7 @@ mod tests {

#[fixture]
fn write_strategy() -> Arc<dyn LayoutStrategy> {
let mut allowed = vortex_file::ALLOWED_ENCODINGS.clone();
allowed.insert(ParquetVariant.id());
vortex_file::WriteStrategyBuilder::default()
.with_allow_encodings(allowed)
.build()
vortex_file::WriteStrategyBuilder::default().build()
}

#[test]
Expand Down
35 changes: 35 additions & 0 deletions vortex-btrblocks/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

//! Builder for configuring `BtrBlocksCompressor` instances.

use vortex_array::ArrayId;
use vortex_utils::aliases::hash_set::HashSet;

use crate::BtrBlocksCompressor;
Expand Down Expand Up @@ -208,6 +209,16 @@ impl BtrBlocksCompressorBuilder {
self
}

/// Retains only schemes whose produced encodings all belong to `allowed`.
///
/// The file writer uses this to restrict compression to the encodings of its configured
/// editions.
pub fn retain_allowed_encodings(mut self, allowed: &HashSet<ArrayId>) -> Self {
self.schemes
.retain(|s| s.produced_encodings().iter().all(|id| allowed.contains(id)));
self
}

/// Builds the configured [`BtrBlocksCompressor`].
pub fn build(self) -> BtrBlocksCompressor {
BtrBlocksCompressor(CascadingCompressor::new(self.schemes))
Expand All @@ -216,6 +227,9 @@ impl BtrBlocksCompressorBuilder {

#[cfg(test)]
mod tests {
use vortex_array::VTable;
use vortex_fastlanes::FoR;

use super::*;

#[test]
Expand All @@ -230,6 +244,27 @@ mod tests {
assert_eq!(builder.schemes.len(), ALL_SCHEMES.len());
}

#[test]
fn retain_allowed_encodings_filters_schemes() {
let allowed: HashSet<ArrayId> = [FoR.id()].into_iter().collect();
let builder = BtrBlocksCompressorBuilder::default().retain_allowed_encodings(&allowed);
assert_eq!(builder.schemes.len(), 1);
assert_eq!(builder.schemes[0].id(), integer::FoRScheme.id());

let none = BtrBlocksCompressorBuilder::default().retain_allowed_encodings(&HashSet::new());
assert!(none.schemes.is_empty());
}

#[test]
fn retaining_all_declared_outputs_keeps_every_scheme() {
let allowed: HashSet<ArrayId> = ALL_SCHEMES
.iter()
.flat_map(|scheme| scheme.produced_encodings())
.collect();
let builder = BtrBlocksCompressorBuilder::default().retain_allowed_encodings(&allowed);
assert_eq!(builder.schemes.len(), ALL_SCHEMES.len());
}

#[test]
fn cuda_compatible_excludes_alprd() {
let builder = BtrBlocksCompressorBuilder::default().only_cuda_compatible();
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/binary/zstd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Zstd compression for binary arrays.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_compressor::scheme::CompressionEstimate;
use vortex_compressor::scheme::DeferredEstimate;
use vortex_error::VortexResult;
Expand All @@ -29,6 +31,10 @@ impl Scheme for ZstdScheme {
canonical.dtype().is_binary()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![vortex_zstd::Zstd.id()]
}

fn expected_compression_ratio(
&self,
_data: &ArrayAndStats,
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/binary/zstd_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Zstd buffer-level binary compression preserving array layout for GPU decompression.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_compressor::scheme::CompressionEstimate;
use vortex_compressor::scheme::DeferredEstimate;
use vortex_error::VortexResult;
Expand All @@ -29,6 +31,10 @@ impl Scheme for ZstdBuffersScheme {
canonical.dtype().is_binary()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![vortex_zstd::ZstdBuffers.id()]
}

fn expected_compression_ratio(
&self,
_data: &ArrayAndStats,
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Decimal compression scheme using byte-part decomposition.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::DecimalArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::decimal::narrowed_decimal;
Expand Down Expand Up @@ -38,6 +40,10 @@ impl Scheme for DecimalScheme {
matches!(canonical, Canonical::Decimal(_))
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![DecimalByteParts.id()]
}

/// Children: primitive=0.
fn num_children(&self) -> usize {
1
Expand Down
10 changes: 10 additions & 0 deletions vortex-btrblocks/src/schemes/float/alp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ use vortex_alp::ALP;
use vortex_alp::ALPArrayExt;
use vortex_alp::ALPArraySlotsExt;
use vortex_alp::alp_encode;
use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::Patched;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
Expand Down Expand Up @@ -40,6 +42,14 @@ impl Scheme for ALPScheme {
canonical.dtype().is_float()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
let mut encodings = vec![ALP.id()];
if use_experimental_patches() {
encodings.push(Patched.id());
}
encodings
}

/// Children: encoded_ints=0.
fn num_children(&self) -> usize {
1
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/float/alprd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
use vortex_alp::ALPRDArrayExt;
use vortex_alp::ALPRDArrayOwnedExt;
use vortex_alp::RDEncoder;
use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
use vortex_array::dtype::PType;
use vortex_compressor::scheme::CompressionEstimate;
Expand Down Expand Up @@ -37,6 +39,10 @@ impl Scheme for ALPRDScheme {
canonical.dtype().is_float()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![vortex_alp::ALPRD.id()]
}

fn expected_compression_ratio(
&self,
data: &ArrayAndStats,
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/float/pco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Pco (pcodec) float compression.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_compressor::scheme::CompressionEstimate;
use vortex_compressor::scheme::DeferredEstimate;
use vortex_error::VortexResult;
Expand All @@ -29,6 +31,10 @@ impl Scheme for PcoScheme {
canonical.dtype().is_float()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![vortex_pco::Pco.id()]
}

fn expected_compression_ratio(
&self,
_data: &ArrayAndStats,
Expand Down
7 changes: 7 additions & 0 deletions vortex-btrblocks/src/schemes/float/rle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@

//! Run-length float encoding.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::VTable;
use vortex_compressor::scheme::AncestorExclusion;
use vortex_compressor::scheme::CompressionEstimate;
use vortex_compressor::scheme::DeferredEstimate;
use vortex_compressor::scheme::DescendantExclusion;
use vortex_compressor::scheme::EstimateVerdict;
use vortex_error::VortexResult;
use vortex_fastlanes::RLE;

use crate::ArrayAndStats;
use crate::CascadingCompressor;
Expand All @@ -35,6 +38,10 @@ impl Scheme for FloatRLEScheme {
canonical.dtype().is_float()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![RLE.id()]
}

/// Children: values=0, indices=1, offsets=2.
fn num_children(&self) -> usize {
3
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/float/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Sparse encoding for null-dominated float arrays.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
use vortex_compressor::scheme::ChildSelection;
Expand Down Expand Up @@ -39,6 +41,10 @@ impl Scheme for NullDominatedSparseScheme {
canonical.dtype().is_float()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![Sparse.id()]
}

/// Children: indices=0.
fn num_children(&self) -> usize {
1
Expand Down
10 changes: 10 additions & 0 deletions vortex-btrblocks/src/schemes/integer/bitpacking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! BitPacking integer encoding.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::Patched;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
Expand Down Expand Up @@ -38,6 +40,14 @@ impl Scheme for BitPackingScheme {
canonical.dtype().is_int()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
let mut encodings = vec![BitPacked.id()];
if use_experimental_patches() {
encodings.push(Patched.id());
}
encodings
}

fn expected_compression_ratio(
&self,
data: &ArrayAndStats,
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/integer/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! FastLanes Delta integer encoding.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::PrimitiveArray;
use vortex_compressor::builtins::BinaryDictScheme;
use vortex_compressor::builtins::FloatDictScheme;
Expand Down Expand Up @@ -78,6 +80,10 @@ impl Scheme for DeltaScheme {
canonical.dtype().is_int()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![Delta.id()]
}

fn num_children(&self) -> usize {
2
}
Expand Down
6 changes: 6 additions & 0 deletions vortex-btrblocks/src/schemes/integer/for_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

//! Frame of Reference integer encoding.

use vortex_array::ArrayId;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::PrimitiveArray;
use vortex_compressor::builtins::BinaryDictScheme;
use vortex_compressor::builtins::FloatDictScheme;
Expand Down Expand Up @@ -41,6 +43,10 @@ impl Scheme for FoRScheme {
canonical.dtype().is_int()
}

fn produced_encodings(&self) -> Vec<ArrayId> {
vec![FoR.id()]
}

/// Dict codes always start at 0, so FoR (which subtracts the min) is a no-op.
fn ancestor_exclusions(&self) -> Vec<AncestorExclusion> {
vec![
Expand Down
Loading
Loading