Skip to content

Commit

Permalink
KmerMinHash as roaring bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Dec 18, 2024
1 parent f4f5187 commit b12fb55
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 98 deletions.
8 changes: 4 additions & 4 deletions src/core/src/index/revindex/disk_revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl RevIndexOps for RevIndex {
let hashes_iter = query.iter_mins().map(|hash| {
let mut v = vec![0_u8; 8];
(&mut v[..])
.write_u64::<LittleEndian>(*hash)
.write_u64::<LittleEndian>(hash)
.expect("error writing bytes");
(&cf_hashes, v)
});
Expand All @@ -306,7 +306,7 @@ impl RevIndexOps for RevIndex {
let hashes_iter = query.iter_mins().map(|hash| {
let mut v = vec![0_u8; 8];
(&mut v[..])
.write_u64::<LittleEndian>(*hash)
.write_u64::<LittleEndian>(hash)
.expect("error writing bytes");
(&cf_hashes, v)
});
Expand All @@ -332,7 +332,7 @@ impl RevIndexOps for RevIndex {
.entry(color)
.or_insert_with(|| new_vals.clone());
counter.update(new_vals);
(*k, color)
(k, color)
})
})
.collect();
Expand Down Expand Up @@ -449,7 +449,7 @@ impl RevIndexOps for RevIndex {
// Prepare counter for finding the next match by decrementing
// all hashes found in the current match in other datasets
// TODO: not used at the moment, so just skip.
query.remove_many(match_mh.iter_mins().copied())?; // is there a better way?
query.remove_many(match_mh.iter_mins())?; // is there a better way?

// TODO: Use HashesToColors here instead. If not initialized,
// build it.
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/index/revindex/mem_revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl RevIndex {
// Prepare counter for finding the next match by decrementing
// all hashes found in the current match in other datasets
for hash in match_mh.iter_mins() {
if let Some(color) = self.hash_to_color.get(hash) {
if let Some(color) = self.hash_to_color.get(&hash) {
counter.subtract(self.colors.indices(color).cloned());
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl RevIndex {
pub fn counter_for_query(&self, query: &KmerMinHash) -> SigCounter {
query
.iter_mins()
.filter_map(|hash| self.hash_to_color.get(hash))
.filter_map(|hash| self.hash_to_color.get(&hash))
.flat_map(|color| self.colors.indices(color))
.cloned()
.collect()
Expand Down
Loading

0 comments on commit b12fb55

Please sign in to comment.