@@ -14,6 +14,7 @@ use vortex_runend::compress::runend_encode;
1414use self :: stats:: FloatStats ;
1515use crate :: float:: dictionary:: dictionary_encode;
1616use crate :: integer:: { IntCompressor , IntegerStats } ;
17+ use crate :: patches:: compress_patches;
1718use crate :: {
1819 Compressor , CompressorStats , GenerateStatsOptions , Scheme ,
1920 estimate_compression_ratio_with_sampling, integer,
@@ -184,14 +185,6 @@ impl Scheme for ALPScheme {
184185 return Ok ( 0.0 ) ;
185186 }
186187
187- // If Dict/RLE is feasible, we want to do that before ALP, and then only ALP encode
188- // the values.
189- if stats. average_run_length >= RUN_END_THRESHOLD
190- || stats. distinct_values_count < stats. value_count / 2
191- {
192- return Ok ( 0.0 ) ;
193- }
194-
195188 estimate_compression_ratio_with_sampling (
196189 self ,
197190 stats,
@@ -225,10 +218,9 @@ impl Scheme for ALPScheme {
225218 let compressed_alp_ints =
226219 IntCompressor :: compress ( & alp_ints, is_sample, allowed_cascading - 1 , & int_excludes) ?;
227220
228- Ok (
229- ALPArray :: try_new ( compressed_alp_ints, alp. exponents ( ) , alp. patches ( ) . cloned ( ) ) ?
230- . into_array ( ) ,
231- )
221+ let patches = alp. patches ( ) . map ( compress_patches) . transpose ( ) ?;
222+
223+ Ok ( ALPArray :: try_new ( compressed_alp_ints, alp. exponents ( ) , patches) ?. into_array ( ) )
232224 }
233225}
234226
@@ -273,7 +265,15 @@ impl Scheme for ALPRDScheme {
273265 ptype => vortex_panic ! ( "cannot ALPRD compress ptype {ptype}" ) ,
274266 } ;
275267
276- Ok ( encoder. encode ( stats. source ( ) ) . into_array ( ) )
268+ let mut alp_rd = encoder. encode ( stats. source ( ) ) ;
269+
270+ let patches = alp_rd
271+ . left_parts_patches ( )
272+ . map ( compress_patches)
273+ . transpose ( ) ?;
274+ alp_rd. replace_left_parts_patches ( patches) ;
275+
276+ Ok ( alp_rd. into_array ( ) )
277277 }
278278}
279279
0 commit comments