@@ -14,6 +14,7 @@ use vortex_runend::compress::runend_encode;
14
14
use self :: stats:: FloatStats ;
15
15
use crate :: float:: dictionary:: dictionary_encode;
16
16
use crate :: integer:: { IntCompressor , IntegerStats } ;
17
+ use crate :: patches:: compress_patches;
17
18
use crate :: {
18
19
Compressor , CompressorStats , GenerateStatsOptions , Scheme ,
19
20
estimate_compression_ratio_with_sampling, integer,
@@ -184,14 +185,6 @@ impl Scheme for ALPScheme {
184
185
return Ok ( 0.0 ) ;
185
186
}
186
187
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
-
195
188
estimate_compression_ratio_with_sampling (
196
189
self ,
197
190
stats,
@@ -225,10 +218,9 @@ impl Scheme for ALPScheme {
225
218
let compressed_alp_ints =
226
219
IntCompressor :: compress ( & alp_ints, is_sample, allowed_cascading - 1 , & int_excludes) ?;
227
220
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 ( ) )
232
224
}
233
225
}
234
226
@@ -273,7 +265,15 @@ impl Scheme for ALPRDScheme {
273
265
ptype => vortex_panic ! ( "cannot ALPRD compress ptype {ptype}" ) ,
274
266
} ;
275
267
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 ( ) )
277
277
}
278
278
}
279
279
0 commit comments