Skip to content

Commit

Permalink
bugfix: check if libsais_sparseness big enough
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonVandeVyver committed Oct 22, 2024
1 parent bba56bb commit ae2e5fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libsais64-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn sais64(text: &Vec<u8>, sparseness_factor: u8) -> Result<Vec<i64>, &str> {
libsais_sparseness -= 1;
}

if sparseness_factor % libsais_sparseness != 0 {
if libsais_sparseness * BITS_PER_CHAR <= 16 {
return Err("invalid sparseness factor");
}

Expand Down
3 changes: 1 addition & 2 deletions sa-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ pub fn build_ssa(
let mut sa = match construction_algorithm {
SAConstructionAlgorithm::LibSais => libsais64_rs::sais64(&text, sparseness_factor)?,
SAConstructionAlgorithm::LibDivSufSort => libdivsufsort_rs::divsufsort64(text).ok_or("Building suffix array failed")?
}
;
};

// make the SA sparse and decrease the vector size if we have sampling (sampling_rate > 1)
if *construction_algorithm == SAConstructionAlgorithm::LibDivSufSort {
Expand Down

0 comments on commit ae2e5fa

Please sign in to comment.