@@ -13,14 +13,18 @@ use vortex_alp::alp_encode;
1313use vortex_array:: ArrayRef ;
1414use vortex_array:: Canonical ;
1515use vortex_array:: IntoArray ;
16+ use vortex_array:: LEGACY_SESSION ;
1617use vortex_array:: ToCanonical ;
18+ use vortex_array:: VortexSessionExecute ;
19+ use vortex_array:: arrays:: Patched ;
1720use vortex_array:: arrays:: primitive:: PrimitiveArrayExt ;
1821use vortex_array:: dtype:: PType ;
1922use vortex_compressor:: estimate:: CompressionEstimate ;
2023use vortex_compressor:: scheme:: ChildSelection ;
2124use vortex_compressor:: scheme:: DescendantExclusion ;
2225use vortex_error:: VortexResult ;
2326use vortex_error:: vortex_panic;
27+ use vortex_fastlanes:: USE_EXPERIMENTAL_PATCHES ;
2428use vortex_sparse:: Sparse ;
2529
2630use super :: integer:: SparseScheme as IntSparseScheme ;
@@ -107,11 +111,30 @@ impl Scheme for ALPScheme {
107111 let compressed_alp_ints =
108112 compressor. compress_child ( alp_encoded. encoded ( ) , & ctx, self . id ( ) , 0 ) ?;
109113
110- // Patches are not compressed. They should be infrequent, and if they are not then we want
111- // to keep them linear for easy indexing.
112- let patches = alp_encoded. patches ( ) . map ( compress_patches) . transpose ( ) ?;
114+ let alp_stats = alp_encoded. as_array ( ) . statistics ( ) . to_owned ( ) ;
115+ let exponents = alp_encoded. exponents ( ) ;
116+
117+ if * USE_EXPERIMENTAL_PATCHES {
118+ let patches = alp_encoded. patches ( ) ;
119+
120+ // Create ALP array without interior patches.
121+ let alp_array = ALP :: new ( compressed_alp_ints, exponents, None ) . into_array ( ) ;
122+
123+ match patches {
124+ None => Ok ( alp_array) ,
125+ Some ( p) => Ok ( Patched :: from_array_and_patches (
126+ alp_array,
127+ & p,
128+ & mut LEGACY_SESSION . create_execution_ctx ( ) ,
129+ ) ?
130+ . with_stats_set ( alp_stats)
131+ . into_array ( ) ) ,
132+ }
133+ } else {
134+ let patches = alp_encoded. patches ( ) . map ( compress_patches) . transpose ( ) ?;
113135
114- Ok ( ALP :: new ( compressed_alp_ints, alp_encoded. exponents ( ) , patches) . into_array ( ) )
136+ Ok ( ALP :: new ( compressed_alp_ints, exponents, patches) . into_array ( ) )
137+ }
115138 }
116139}
117140
0 commit comments