@@ -36,7 +36,7 @@ use lance_file::{
36
36
format:: MAGIC ,
37
37
writer:: { FileWriter , FileWriterOptions } ,
38
38
} ;
39
- use lance_index:: vector:: flat:: index:: { FlatIndex , FlatQuantizer } ;
39
+ use lance_index:: vector:: flat:: index:: { FlatBinQuantizer , FlatIndex , FlatQuantizer } ;
40
40
use lance_index:: vector:: ivf:: storage:: IvfModel ;
41
41
use lance_index:: vector:: pq:: storage:: transpose;
42
42
use lance_index:: vector:: quantizer:: QuantizationType ;
@@ -402,25 +402,46 @@ pub(crate) async fn optimize_vector_indices_v2(
402
402
} ;
403
403
let indices_to_merge = existing_indices[ start_pos..] . to_vec ( ) ;
404
404
let merged_num = indices_to_merge. len ( ) ;
405
+
406
+ let ( _, element_type) = get_vector_type ( dataset. schema ( ) , vector_column) ?;
405
407
match index_type {
406
408
// IVF_FLAT
407
409
( SubIndexType :: Flat , QuantizationType :: Flat ) => {
408
- IvfIndexBuilder :: < FlatIndex , FlatQuantizer > :: new_incremental (
409
- dataset. clone ( ) ,
410
- vector_column. to_owned ( ) ,
411
- index_dir,
412
- distance_type,
413
- shuffler,
414
- ( ) ,
415
- ) ?
416
- . with_ivf ( ivf_model. clone ( ) )
417
- . with_quantizer ( quantizer. try_into ( ) ?)
418
- . with_existing_indices ( indices_to_merge)
419
- . retrain ( retrain)
420
- . shuffle_data ( unindexed)
421
- . await ?
422
- . build ( )
423
- . await ?;
410
+ if element_type == DataType :: UInt8 {
411
+ IvfIndexBuilder :: < FlatIndex , FlatBinQuantizer > :: new_incremental (
412
+ dataset. clone ( ) ,
413
+ vector_column. to_owned ( ) ,
414
+ index_dir,
415
+ distance_type,
416
+ shuffler,
417
+ ( ) ,
418
+ ) ?
419
+ . with_ivf ( ivf_model. clone ( ) )
420
+ . with_quantizer ( quantizer. try_into ( ) ?)
421
+ . with_existing_indices ( indices_to_merge)
422
+ . retrain ( retrain)
423
+ . shuffle_data ( unindexed)
424
+ . await ?
425
+ . build ( )
426
+ . await ?;
427
+ } else {
428
+ IvfIndexBuilder :: < FlatIndex , FlatQuantizer > :: new_incremental (
429
+ dataset. clone ( ) ,
430
+ vector_column. to_owned ( ) ,
431
+ index_dir,
432
+ distance_type,
433
+ shuffler,
434
+ ( ) ,
435
+ ) ?
436
+ . with_ivf ( ivf_model. clone ( ) )
437
+ . with_quantizer ( quantizer. try_into ( ) ?)
438
+ . with_existing_indices ( indices_to_merge)
439
+ . retrain ( retrain)
440
+ . shuffle_data ( unindexed)
441
+ . await ?
442
+ . build ( )
443
+ . await ?;
444
+ }
424
445
}
425
446
// IVF_PQ
426
447
( SubIndexType :: Flat , QuantizationType :: Product ) => {
0 commit comments