Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Dec 13, 2020
1 parent 46ca9c1 commit d65da76
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/core/src/index/greyhound.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down Expand Up @@ -179,14 +180,21 @@ impl RevIndex {
(a, b)
};

small_hashes.into_iter().for_each(|(hash, color)| {
let entry = large_hashes.entry(hash).or_insert_with(|| color);
if *entry != color {
let ids: Vec<_> = small_colors.indices(&color).cloned().collect();
let new_color =
large_colors.update(Some(*entry), ids.as_slice()).unwrap();
*entry = new_color;
}
small_hashes.into_iter().for_each(|(hash, small_color)| {
match large_hashes.entry(hash) {
Entry::Occupied(mut color) => {
let old_color = color.get();
if *old_color != small_color {
let ids: Vec<_> =
small_colors.indices(&small_color).cloned().collect();
let new_color = large_colors
.update(Some(*old_color), ids.as_slice())
.unwrap();
*color.get_mut() = new_color;
}
}
Entry::Vacant(old_color) => unimplemented!(),
};
});

(large_hashes, large_colors)
Expand Down

0 comments on commit d65da76

Please sign in to comment.