@@ -67,7 +67,7 @@ pub const ALL_SCHEMES: &[&dyn Scheme] = &[
6767///
6868/// By default, all schemes in [`ALL_SCHEMES`] are enabled. Feature-gated schemes (Pco, Zstd)
6969/// are not in `ALL_SCHEMES` and must be added explicitly via
70- /// [`with_new_scheme `](BtrBlocksCompressorBuilder::with_new_scheme ) or
70+ /// [`with_scheme `](BtrBlocksCompressorBuilder::with_scheme ) or
7171/// [`with_compact`](BtrBlocksCompressorBuilder::with_compact).
7272///
7373/// # Examples
@@ -79,9 +79,9 @@ pub const ALL_SCHEMES: &[&dyn Scheme] = &[
7979/// // Default compressor with all schemes in ALL_SCHEMES.
8080/// let compressor = BtrBlocksCompressorBuilder::default().build();
8181///
82- /// // Exclude specific schemes.
82+ /// // Remove specific schemes.
8383/// let compressor = BtrBlocksCompressorBuilder::default()
84- /// .exclude ([IntDictScheme.id()])
84+ /// .exclude_schemes ([IntDictScheme.id()])
8585/// .build();
8686/// ```
8787#[ derive( Debug , Clone ) ]
@@ -100,13 +100,13 @@ impl Default for BtrBlocksCompressorBuilder {
100100impl BtrBlocksCompressorBuilder {
101101 /// Adds an external compression scheme not in [`ALL_SCHEMES`].
102102 ///
103- /// This allows encoding crates outside of `vortex-btrblocks` to register their own schemes with
104- /// the compressor.
103+ /// This allows encoding crates outside of `vortex-btrblocks` to register their own schemes
104+ /// with the compressor.
105105 ///
106106 /// # Panics
107107 ///
108108 /// Panics if a scheme with the same [`SchemeId`] is already present.
109- pub fn with_new_scheme ( mut self , scheme : & ' static dyn Scheme ) -> Self {
109+ pub fn with_scheme ( mut self , scheme : & ' static dyn Scheme ) -> Self {
110110 assert ! (
111111 !self . schemes. iter( ) . any( |s| s. id( ) == scheme. id( ) ) ,
112112 "scheme {:?} is already present in the builder" ,
@@ -128,19 +128,42 @@ impl BtrBlocksCompressorBuilder {
128128 /// Panics if any of the compact schemes are already present.
129129 #[ cfg( feature = "zstd" ) ]
130130 pub fn with_compact ( self ) -> Self {
131- // This should be fast since we don't have that many schemes.
132- let builder = self . with_new_scheme ( & string:: ZstdScheme ) ;
131+ let builder = self . with_scheme ( & string:: ZstdScheme ) ;
133132
134133 #[ cfg( feature = "pco" ) ]
135134 let builder = builder
136- . with_new_scheme ( & integer:: PcoScheme )
137- . with_new_scheme ( & float:: PcoScheme ) ;
135+ . with_scheme ( & integer:: PcoScheme )
136+ . with_scheme ( & float:: PcoScheme ) ;
138137
139138 builder
140139 }
141140
142- /// Excludes the specified compression schemes by their [`SchemeId`].
143- pub fn exclude ( mut self , ids : impl IntoIterator < Item = SchemeId > ) -> Self {
141+ /// Excludes schemes without CUDA kernel support and adds Zstd for string compression.
142+ ///
143+ /// With the `unstable_encodings` feature, buffer-level Zstd compression is used which
144+ /// preserves the array buffer layout for zero-conversion GPU decompression. Without it,
145+ /// interleaved Zstd compression is used.
146+ #[ cfg( feature = "zstd" ) ]
147+ pub fn only_cuda_compatible ( self ) -> Self {
148+ let builder = self . exclude_schemes ( [
149+ integer:: SparseScheme . id ( ) ,
150+ rle:: RLE_INTEGER_SCHEME . id ( ) ,
151+ rle:: RLE_FLOAT_SCHEME . id ( ) ,
152+ float:: NullDominatedSparseScheme . id ( ) ,
153+ string:: StringDictScheme . id ( ) ,
154+ string:: FSSTScheme . id ( ) ,
155+ ] ) ;
156+
157+ #[ cfg( feature = "unstable_encodings" ) ]
158+ let builder = builder. with_scheme ( & string:: ZstdBuffersScheme ) ;
159+ #[ cfg( not( feature = "unstable_encodings" ) ) ]
160+ let builder = builder. with_scheme ( & string:: ZstdScheme ) ;
161+
162+ builder
163+ }
164+
165+ /// Removes the specified compression schemes by their [`SchemeId`].
166+ pub fn exclude_schemes ( mut self , ids : impl IntoIterator < Item = SchemeId > ) -> Self {
144167 let ids: HashSet < _ > = ids. into_iter ( ) . collect ( ) ;
145168 self . schemes . retain ( |s| !ids. contains ( & s. id ( ) ) ) ;
146169 self
0 commit comments