@@ -171,7 +171,7 @@ pub unsafe fn turboquant_encode_unchecked(
171171
172172 let core = turboquant_quantize_core ( & fsl, seed, config. bit_width , config. num_rounds , ctx) ?;
173173 let quantized_fsl =
174- build_quantized_fsl ( num_rows, core. all_indices , & core. centroids , core. padded_dim ) ?;
174+ build_quantized_fsl ( num_rows, core. all_indices , core. centroids , core. padded_dim ) ?;
175175 let padded_vector = Vector :: try_new_vector_array ( quantized_fsl) ?;
176176
177177 let sorf_options = SorfOptions {
@@ -185,8 +185,8 @@ pub unsafe fn turboquant_encode_unchecked(
185185
186186/// Shared intermediate results from the quantization loop.
187187struct QuantizationResult {
188- centroids : Vec < f32 > ,
189- all_indices : BufferMut < u8 > ,
188+ centroids : Buffer < f32 > ,
189+ all_indices : Buffer < u8 > ,
190190 padded_dim : usize ,
191191}
192192
@@ -202,8 +202,7 @@ fn turboquant_quantize_core(
202202 num_rounds : u8 ,
203203 ctx : & mut ExecutionCtx ,
204204) -> VortexResult < QuantizationResult > {
205- let dimension =
206- usize:: try_from ( fsl. list_size ( ) ) . vortex_expect ( "u32 FixedSizeList dimension fits in usize" ) ;
205+ let dimension = fsl. list_size ( ) as usize ;
207206 let num_rows = fsl. len ( ) ;
208207
209208 let rotation = SorfMatrix :: try_new ( seed, dimension, num_rounds as usize ) ?;
@@ -238,7 +237,7 @@ fn turboquant_quantize_core(
238237
239238 Ok ( QuantizationResult {
240239 centroids,
241- all_indices,
240+ all_indices : all_indices . freeze ( ) ,
242241 padded_dim,
243242 } )
244243}
@@ -250,13 +249,12 @@ fn turboquant_quantize_core(
250249/// without knowledge of the rotation.
251250fn build_quantized_fsl (
252251 num_rows : usize ,
253- all_indices : BufferMut < u8 > ,
254- centroids : & [ f32 ] ,
252+ all_indices : Buffer < u8 > ,
253+ centroids : Buffer < f32 > ,
255254 padded_dim : usize ,
256255) -> VortexResult < ArrayRef > {
257- let codes = PrimitiveArray :: new :: < u8 > ( all_indices. freeze ( ) , Validity :: NonNullable ) ;
258- let centroids_array =
259- PrimitiveArray :: new :: < f32 > ( Buffer :: copy_from ( centroids) , Validity :: NonNullable ) ;
256+ let codes = PrimitiveArray :: new :: < u8 > ( all_indices, Validity :: NonNullable ) ;
257+ let centroids_array = PrimitiveArray :: new :: < f32 > ( centroids, Validity :: NonNullable ) ;
260258
261259 let dict = DictArray :: try_new ( codes. into_array ( ) , centroids_array. into_array ( ) ) ?;
262260
0 commit comments