@@ -67,8 +67,8 @@ 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
71- /// [`with_compact `](BtrBlocksCompressorBuilder::with_compact ).
70+ /// [`add_scheme `](BtrBlocksCompressorBuilder::add_scheme ) or
71+ /// [`add_compact `](BtrBlocksCompressorBuilder::add_compact ).
7272///
7373/// # Examples
7474///
@@ -79,10 +79,10 @@ 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.
83- /// let compressor = BtrBlocksCompressorBuilder::default()
84- /// .exclude ([IntDictScheme.id()])
85- /// .build();
82+ /// // Remove specific schemes.
83+ /// let mut builder = BtrBlocksCompressorBuilder::default();
84+ /// builder.remove ([IntDictScheme.id()]);
85+ /// let compressor = builder .build();
8686/// ```
8787#[ derive( Debug , Clone ) ]
8888pub struct BtrBlocksCompressorBuilder {
@@ -100,19 +100,18 @@ 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 add_scheme ( & mut self , scheme : & ' static dyn Scheme ) -> & mut Self {
110110 assert ! (
111111 !self . schemes. iter( ) . any( |s| s. id( ) == scheme. id( ) ) ,
112112 "scheme {:?} is already present in the builder" ,
113113 scheme. id( ) ,
114114 ) ;
115-
116115 self . schemes . push ( scheme) ;
117116 self
118117 }
@@ -127,20 +126,40 @@ impl BtrBlocksCompressorBuilder {
127126 ///
128127 /// Panics if any of the compact schemes are already present.
129128 #[ cfg( feature = "zstd" ) ]
130- 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 ) ;
133-
129+ pub fn add_compact ( & mut self ) -> & mut Self {
130+ self . add_scheme ( & string:: ZstdScheme ) ;
134131 #[ cfg( feature = "pco" ) ]
135- let builder = builder
136- . with_new_scheme ( & integer:: PcoScheme )
137- . with_new_scheme ( & float:: PcoScheme ) ;
132+ {
133+ self . add_scheme ( & integer:: PcoScheme ) ;
134+ self . add_scheme ( & float:: PcoScheme ) ;
135+ }
136+ self
137+ }
138138
139- builder
139+ /// Excludes schemes without CUDA kernel support and adds Zstd for string compression.
140+ ///
141+ /// With the `unstable_encodings` feature, buffer-level Zstd compression is used which
142+ /// preserves the array buffer layout for zero-conversion GPU decompression. Without it,
143+ /// interleaved Zstd compression is used.
144+ #[ cfg( feature = "zstd" ) ]
145+ pub fn add_cuda_compatible ( & mut self ) -> & mut Self {
146+ self . remove ( [
147+ integer:: SparseScheme . id ( ) ,
148+ rle:: RLE_INTEGER_SCHEME . id ( ) ,
149+ rle:: RLE_FLOAT_SCHEME . id ( ) ,
150+ float:: NullDominatedSparseScheme . id ( ) ,
151+ string:: StringDictScheme . id ( ) ,
152+ string:: FSSTScheme . id ( ) ,
153+ ] ) ;
154+ #[ cfg( feature = "unstable_encodings" ) ]
155+ self . add_scheme ( & string:: ZstdBuffersScheme ) ;
156+ #[ cfg( not( feature = "unstable_encodings" ) ) ]
157+ self . add_scheme ( & string:: ZstdScheme ) ;
158+ self
140159 }
141160
142- /// Excludes the specified compression schemes by their [`SchemeId`].
143- pub fn exclude ( mut self , ids : impl IntoIterator < Item = SchemeId > ) -> Self {
161+ /// Removes the specified compression schemes by their [`SchemeId`].
162+ pub fn remove ( & mut self , ids : impl IntoIterator < Item = SchemeId > ) -> & mut Self {
144163 let ids: HashSet < _ > = ids. into_iter ( ) . collect ( ) ;
145164 self . schemes . retain ( |s| !ids. contains ( & s. id ( ) ) ) ;
146165 self
0 commit comments