@@ -512,6 +512,7 @@ where
512
512
/// Args:
513
513
/// * `max_query_len`: prefix length
514
514
fn set_suffix_array_mem ( & mut self , max_query_len : Option < usize > ) -> Result < ( ) > {
515
+
515
516
let mut max_query_len = max_query_len. unwrap_or ( 0 ) ;
516
517
517
518
// If ".sufr" file was built with a nonzero max_query_len or seed mask
@@ -535,8 +536,14 @@ where
535
536
}
536
537
}
537
538
538
- // The requested MQL matches how the SA was built
539
- if max_query_len == built_max_query_len {
539
+ // Do nothing if we've already loaded the correct SA/MQL
540
+ if !self . suffix_array_mem . is_empty ( )
541
+ && self . suffix_array_mem_mql == Some ( max_query_len)
542
+ {
543
+ info ! ( "Using existing suffix_array_mem" ) ;
544
+ return Ok ( ( ) ) ;
545
+ } else if max_query_len == built_max_query_len {
546
+ // The requested MQL matches how the SA was built
540
547
// Stuff entire SA into memory
541
548
let now = Instant :: now ( ) ;
542
549
self . suffix_array_file . reset ( ) ;
@@ -546,13 +553,6 @@ where
546
553
// There will be no ranks
547
554
self . suffix_array_rank_mem = vec ! [ ] ;
548
555
} else {
549
- // Do nothing if we've already loaded the correct SA/MQL
550
- if !self . suffix_array_mem . is_empty ( )
551
- && self . suffix_array_mem_mql == Some ( max_query_len)
552
- {
553
- info ! ( "Using existing suffix_array_mem" ) ;
554
- return Ok ( ( ) ) ;
555
- }
556
556
557
557
info ! ( "Loading suffix_array_mem using max_query_len {max_query_len}" ) ;
558
558
@@ -619,7 +619,6 @@ where
619
619
} else {
620
620
let now = Instant :: now ( ) ;
621
621
let ( sub_sa, sub_rank) = & self . subsample_suffix_array ( max_query_len) ;
622
- self . suffix_array_mem_mql = Some ( max_query_len) ;
623
622
self . suffix_array_mem = sub_sa. to_vec ( ) ;
624
623
self . suffix_array_rank_mem = sub_rank. to_vec ( ) ;
625
624
@@ -663,6 +662,7 @@ where
663
662
}
664
663
}
665
664
}
665
+ self . suffix_array_mem_mql = Some ( max_query_len) ;
666
666
667
667
Ok ( ( ) )
668
668
}
0 commit comments