Skip to content

Commit cf820d2

Browse files
committed
clean up
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 118191f commit cf820d2

15 files changed

Lines changed: 1078 additions & 659 deletions

File tree

vortex-array/public-api.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22144,6 +22144,14 @@ pub fn vortex_array::ExecutionCtx::new(session: vortex_session::VortexSession) -
2214422144

2214522145
pub fn vortex_array::ExecutionCtx::session(&self) -> &vortex_session::VortexSession
2214622146

22147+
impl core::clone::Clone for vortex_array::ExecutionCtx
22148+
22149+
pub fn vortex_array::ExecutionCtx::clone(&self) -> vortex_array::ExecutionCtx
22150+
22151+
impl core::fmt::Debug for vortex_array::ExecutionCtx
22152+
22153+
pub fn vortex_array::ExecutionCtx::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
22154+
2214722155
impl core::fmt::Display for vortex_array::ExecutionCtx
2214822156

2214922157
pub fn vortex_array::ExecutionCtx::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

vortex-btrblocks/public-api.lock

Lines changed: 299 additions & 525 deletions
Large diffs are not rendered by default.

vortex-btrblocks/src/builder.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@ use crate::schemes::temporal;
2222
/// the final scheme list, so that tie-breaking is deterministic.
2323
pub const ALL_SCHEMES: &[&dyn Scheme] = &[
2424
// Integer schemes.
25-
&integer::UncompressedScheme as &dyn Scheme,
26-
&integer::ConstantScheme,
27-
// NOTE: For must precede BitPacking to avoid unnecessary patches.
25+
&integer::IntUncompressedScheme as &dyn Scheme,
26+
&integer::IntConstantScheme,
27+
// NOTE: FoR must precede BitPacking to avoid unnecessary patches.
2828
&integer::FoRScheme,
2929
&integer::BitPackingScheme,
3030
&integer::ZigZagScheme,
3131
&integer::SparseScheme,
32-
&integer::DictScheme,
32+
&integer::IntDictScheme,
3333
&integer::RunEndScheme,
3434
&integer::SequenceScheme,
3535
&integer::RLE_INTEGER_SCHEME,
3636
#[cfg(feature = "pco")]
3737
&integer::PcoScheme,
3838
// Float schemes.
39-
&float::UncompressedScheme,
40-
&float::ConstantScheme,
39+
&float::FloatUncompressedScheme,
40+
&float::FloatConstantScheme,
4141
&float::ALPScheme,
4242
&float::ALPRDScheme,
43-
&float::DictScheme,
44-
&float::NullDominated,
43+
&float::FloatDictScheme,
44+
&float::NullDominatedSparseScheme,
4545
&float::RLE_FLOAT_SCHEME,
4646
#[cfg(feature = "pco")]
4747
&float::PcoScheme,
@@ -50,11 +50,11 @@ pub const ALL_SCHEMES: &[&dyn Scheme] = &[
5050
// Temporal schemes.
5151
&temporal::TemporalScheme,
5252
// String schemes.
53-
&string::UncompressedScheme,
54-
&string::DictScheme,
53+
&string::StringUncompressedScheme,
54+
&string::StringDictScheme,
5555
&string::FSSTScheme,
56-
&string::ConstantScheme,
57-
&string::NullDominated,
56+
&string::StringConstantScheme,
57+
&string::NullDominatedSparseScheme,
5858
#[cfg(feature = "zstd")]
5959
&string::ZstdScheme,
6060
#[cfg(all(feature = "zstd", feature = "unstable_encodings"))]
@@ -86,20 +86,20 @@ pub fn default_excluded() -> HashSet<SchemeId> {
8686
///
8787
/// ```rust
8888
/// use vortex_btrblocks::{BtrBlocksCompressorBuilder, Scheme, SchemeExt};
89-
/// use vortex_btrblocks::schemes::integer::DictScheme;
89+
/// use vortex_btrblocks::schemes::integer::IntDictScheme;
9090
///
9191
/// // Default compressor - all non-excluded schemes allowed.
9292
/// let compressor = BtrBlocksCompressorBuilder::default().build();
9393
///
9494
/// // Exclude specific schemes.
9595
/// let compressor = BtrBlocksCompressorBuilder::default()
96-
/// .exclude([DictScheme.id()])
96+
/// .exclude([IntDictScheme.id()])
9797
/// .build();
9898
///
9999
/// // Exclude then re-include.
100100
/// let compressor = BtrBlocksCompressorBuilder::default()
101-
/// .exclude([DictScheme.id()])
102-
/// .include([DictScheme.id()])
101+
/// .exclude([IntDictScheme.id()])
102+
/// .include([IntDictScheme.id()])
103103
/// .build();
104104
/// ```
105105
#[derive(Debug, Clone)]

vortex-btrblocks/src/canonical_compressor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ use crate::CascadingCompressor;
2020
///
2121
/// ```rust
2222
/// use vortex_btrblocks::{BtrBlocksCompressor, BtrBlocksCompressorBuilder, Scheme, SchemeExt};
23-
/// use vortex_btrblocks::schemes::integer::DictScheme;
23+
/// use vortex_btrblocks::schemes::integer::IntDictScheme;
2424
///
2525
/// // Default compressor - all schemes allowed.
2626
/// let compressor = BtrBlocksCompressor::default();
2727
///
2828
/// // Exclude specific schemes using the builder.
2929
/// let compressor = BtrBlocksCompressorBuilder::default()
30-
/// .exclude([DictScheme.id()])
30+
/// .exclude([IntDictScheme.id()])
3131
/// .build();
3232
/// ```
3333
#[derive(Clone)]

vortex-btrblocks/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
//!
4242
//! ```rust
4343
//! use vortex_btrblocks::{BtrBlocksCompressor, BtrBlocksCompressorBuilder, Scheme, SchemeExt};
44-
//! use vortex_btrblocks::schemes::integer::DictScheme;
44+
//! use vortex_btrblocks::schemes::integer::IntDictScheme;
4545
//! use vortex_array::DynArray;
4646
//!
4747
//! // Default compressor with all schemes enabled.
4848
//! let compressor = BtrBlocksCompressor::default();
4949
//!
5050
//! // Configure with builder to exclude specific schemes.
5151
//! let compressor = BtrBlocksCompressorBuilder::default()
52-
//! .exclude([DictScheme.id()])
52+
//! .exclude([IntDictScheme.id()])
5353
//! .build();
5454
//! ```
5555
//!

vortex-btrblocks/src/schemes/float.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
// Re-export builtin schemes from vortex-compressor.
4+
//! Float compression schemes.
5+
56
use vortex_alp::ALP;
67
use vortex_alp::ALPArray;
78
use vortex_alp::RDEncoder;
@@ -12,13 +13,8 @@ use vortex_array::IntoArray;
1213
use vortex_array::ToCanonical;
1314
use vortex_array::arrays::PrimitiveArray;
1415
use vortex_array::dtype::PType;
15-
pub use vortex_compressor::builtins::FloatConstantScheme as ConstantScheme;
16-
pub use vortex_compressor::builtins::FloatDictScheme as DictScheme;
17-
pub use vortex_compressor::builtins::FloatUncompressedScheme as UncompressedScheme;
18-
pub use vortex_compressor::builtins::is_float_primitive;
1916
use vortex_compressor::scheme::ChildSelection;
2017
use vortex_compressor::scheme::DescendantExclusion;
21-
pub use vortex_compressor::stats::FloatStats;
2218
use vortex_error::VortexResult;
2319
use vortex_error::vortex_panic;
2420
use vortex_sparse::Sparse;
@@ -45,8 +41,10 @@ pub struct ALPScheme;
4541
pub struct ALPRDScheme;
4642

4743
/// Sparse encoding for null-dominated float arrays.
44+
///
45+
/// This is the same as the integer `SparseScheme`, but we only use this for null-dominated arrays.
4846
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
49-
pub struct NullDominated;
47+
pub struct NullDominatedSparseScheme;
5048

5149
/// Pco (pcodec) compression for floats.
5250
#[cfg(feature = "pco")]
@@ -57,6 +55,13 @@ pub struct PcoScheme;
5755
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5856
pub struct FloatRLEConfig;
5957

58+
// Re-export builtin schemes from vortex-compressor.
59+
pub use vortex_compressor::builtins::FloatConstantScheme;
60+
pub use vortex_compressor::builtins::FloatDictScheme;
61+
pub use vortex_compressor::builtins::FloatUncompressedScheme;
62+
pub use vortex_compressor::builtins::is_float_primitive;
63+
pub use vortex_compressor::stats::FloatStats;
64+
6065
impl rle::RLEConfig for FloatRLEConfig {
6166
type Stats = FloatStats;
6267

@@ -206,7 +211,7 @@ impl Scheme for ALPRDScheme {
206211
}
207212
}
208213

209-
impl Scheme for NullDominated {
214+
impl Scheme for NullDominatedSparseScheme {
210215
fn scheme_name(&self) -> &'static str {
211216
"vortex.float.sparse"
212217
}
@@ -219,6 +224,8 @@ impl Scheme for NullDominated {
219224
1
220225
}
221226

227+
// TODO(connor): There seems to be stuff missing here...
228+
/// The indices of a null-dominated sparse array should not be sparse-encoded again.
222229
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
223230
vec![DescendantExclusion {
224231
excluded: IntSparseScheme.id(),

vortex-btrblocks/src/schemes/integer.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
// Re-export builtin schemes from vortex-compressor.
4+
//! Integer compression schemes.
5+
56
use vortex_array::ArrayRef;
67
use vortex_array::Canonical;
78
use vortex_array::IntoArray;
89
use vortex_array::ToCanonical;
910
use vortex_array::arrays::ConstantArray;
1011
use vortex_array::arrays::PrimitiveArray;
1112
use vortex_array::scalar::Scalar;
12-
pub use vortex_compressor::builtins::IntConstantScheme as ConstantScheme;
13-
pub use vortex_compressor::builtins::IntDictScheme as DictScheme;
14-
pub use vortex_compressor::builtins::IntUncompressedScheme as UncompressedScheme;
15-
pub use vortex_compressor::builtins::is_integer_primitive;
13+
use vortex_compressor::builtins::FloatDictScheme;
14+
use vortex_compressor::builtins::StringDictScheme;
1615
use vortex_compressor::scheme::AncestorExclusion;
1716
use vortex_compressor::scheme::ChildSelection;
1817
use vortex_compressor::scheme::DescendantExclusion;
19-
pub use vortex_compressor::stats::IntegerStats;
2018
use vortex_error::VortexExpect;
2119
use vortex_error::VortexResult;
2220
use vortex_error::vortex_bail;
@@ -74,6 +72,13 @@ pub struct SequenceScheme;
7472
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
7573
pub struct PcoScheme;
7674

75+
// Re-export builtin schemes from vortex-compressor.
76+
pub use vortex_compressor::builtins::IntConstantScheme;
77+
pub use vortex_compressor::builtins::IntDictScheme;
78+
pub use vortex_compressor::builtins::IntUncompressedScheme;
79+
pub use vortex_compressor::builtins::is_integer_primitive;
80+
pub use vortex_compressor::stats::IntegerStats;
81+
7782
/// Threshold for the average run length in an array before we consider run-end encoding.
7883
const RUN_END_THRESHOLD: u32 = 4;
7984

@@ -224,10 +229,13 @@ impl Scheme for ZigZagScheme {
224229
1
225230
}
226231

232+
/// Container-style schemes (Dict, RunEnd, Sparse) restructure data and should only be
233+
/// applied once in a cascade chain. ZigZag's output is a simple value transformation,
234+
/// so further restructuring is wasteful.
227235
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
228236
vec![
229237
DescendantExclusion {
230-
excluded: DictScheme.id(),
238+
excluded: IntDictScheme.id(),
231239
children: ChildSelection::All,
232240
},
233241
DescendantExclusion {
@@ -361,9 +369,11 @@ impl Scheme for SparseScheme {
361369
2
362370
}
363371

372+
/// Sparse values and indices are already low-cardinality by construction, so dictionary
373+
/// encoding doesn't add anything.
364374
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
365375
vec![DescendantExclusion {
366-
excluded: DictScheme.id(),
376+
excluded: IntDictScheme.id(),
367377
children: ChildSelection::All,
368378
}]
369379
}
@@ -488,24 +498,21 @@ impl Scheme for RunEndScheme {
488498
2
489499
}
490500

501+
/// Run-end values and ends are already deduplicated, so dictionary encoding doesn't add
502+
/// anything.
491503
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
492504
vec![DescendantExclusion {
493-
excluded: DictScheme.id(),
505+
excluded: IntDictScheme.id(),
494506
children: ChildSelection::All,
495507
}]
496508
}
497509

510+
// TODO(connor): There seems to be stuff missing here...
498511
fn ancestor_exclusions(&self) -> Vec<AncestorExclusion> {
499-
use vortex_compressor::builtins::FloatDictScheme;
500-
501-
vec![
502-
// Exclude from FloatDict values child (child 0). This replaces the old ALP
503-
// conditional propagation of float RLE exclusion to integer RunEnd.
504-
AncestorExclusion {
505-
ancestor: FloatDictScheme.id(),
506-
children: ChildSelection::One(0),
507-
},
508-
]
512+
vec![AncestorExclusion {
513+
ancestor: FloatDictScheme.id(),
514+
children: ChildSelection::One(0),
515+
}]
509516
}
510517

511518
fn expected_compression_ratio(
@@ -564,22 +571,19 @@ impl Scheme for SequenceScheme {
564571
is_integer_primitive(canonical)
565572
}
566573

574+
/// Sequence encoding on dictionary codes just adds a layer of indirection without compressing
575+
/// the data. Dict codes are compact integers that benefit from BitPacking or FoR, not from
576+
/// sequence detection.
567577
fn ancestor_exclusions(&self) -> Vec<AncestorExclusion> {
568-
use vortex_compressor::builtins::FloatDictScheme;
569-
use vortex_compressor::builtins::StringDictScheme;
570-
571578
vec![
572-
// Exclude from IntDict codes.
573579
AncestorExclusion {
574-
ancestor: DictScheme.id(),
580+
ancestor: IntDictScheme.id(),
575581
children: ChildSelection::All,
576582
},
577-
// Exclude from FloatDict codes (child 1).
578583
AncestorExclusion {
579584
ancestor: FloatDictScheme.id(),
580585
children: ChildSelection::One(1),
581586
},
582-
// Exclude from StringDict codes (child 1).
583587
AncestorExclusion {
584588
ancestor: StringDictScheme.id(),
585589
children: ChildSelection::One(1),

vortex-btrblocks/src/schemes/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33

44
//! Compression scheme implementations.
55
6-
/// Decimal compression schemes.
7-
pub mod decimal;
8-
/// Float compression schemes.
96
pub mod float;
10-
/// Integer compression schemes.
117
pub mod integer;
12-
pub(crate) mod patches;
13-
pub(crate) mod rle;
14-
/// String compression schemes.
158
pub mod string;
16-
/// Temporal compression schemes.
9+
10+
pub mod decimal;
1711
pub mod temporal;
12+
13+
pub(crate) mod patches;
14+
pub(crate) mod rle;

vortex-btrblocks/src/schemes/rle.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::CompressorContext;
2020
use crate::Scheme;
2121
use crate::SchemeExt;
2222
use crate::estimate_compression_ratio_with_sampling;
23-
use crate::schemes::integer::DictScheme as IntDictScheme;
23+
use crate::schemes::integer::IntDictScheme;
2424

2525
/// Threshold for the average run length in an array before we consider run-length encoding.
2626
pub const RUN_LENGTH_THRESHOLD: u32 = 4;
@@ -35,6 +35,8 @@ pub trait RLEStats {
3535
fn source(&self) -> &PrimitiveArray;
3636
}
3737

38+
// TODO(connor): This trait is super confusing, we should probably just remove it and hardcode the
39+
// only 2 implementations (integer and float).
3840
/// Configuration trait for RLE schemes.
3941
///
4042
/// Implement this trait to define the behavior of an RLE scheme for a specific
@@ -92,6 +94,9 @@ impl<C: RLEConfig> Scheme for RLEScheme<C> {
9294
3
9395
}
9496

97+
/// RLE indices (child 1) and offsets (child 2) are monotonically increasing, so dictionary
98+
/// encoding is pointless.
99+
/// Values (child 0) are not excluded since they may benefit from dict encoding.
95100
fn descendant_exclusions(&self) -> Vec<DescendantExclusion> {
96101
vec![DescendantExclusion {
97102
excluded: IntDictScheme.id(),

0 commit comments

Comments
 (0)