Skip to content

Commit

Permalink
remove match_ from mem revindex gather, still working on FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Nov 12, 2024
1 parent 4841d43 commit 06867ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/core/src/ffi/index/revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,13 @@ unsafe fn revindex_gather(
let threshold: usize = (threshold * (mh.size() as f64)) as _;

let counter = revindex.counter_for_query(mh);
dbg!(&counter);

let results: Vec<(f64, Signature, String)> = revindex
.gather(counter, threshold, mh)
.unwrap() // TODO: proper error handling
.into_iter()
.map(|r| {

Check warning on line 215 in src/core/src/ffi/index/revindex.rs

View workflow job for this annotation

GitHub Actions / minimum_rust_version

unused variable: `r`
let filename = r.filename().to_owned();
let sig = r.get_match();
(r.f_match(), sig, filename)
todo!()

Check warning on line 216 in src/core/src/ffi/index/revindex.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/ffi/index/revindex.rs#L216

Added line #L216 was not covered by tests
})
.collect();

Expand Down
31 changes: 17 additions & 14 deletions src/core/src/index/revindex/mem_revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,29 @@ impl RevIndex {
let mut matches = vec![];

while match_size > threshold && !counter.is_empty() {
let (dataset_id, size) = counter.most_common()[0];
let (dataset_id, size) = counter.k_most_common_ordered(1)[0];
match_size = if size >= threshold { size } else { break };
let result = self
.linear
.gather_round(dataset_id, match_size, query, matches.len())?;
if let Some(Sketch::MinHash(match_mh)) =
result.match_.select_sketch(self.linear.template())
{
// 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) {
counter.subtract(self.colors.indices(color).cloned());
}

// handle special case where threshold was set to 0
if match_size == 0 {
break;
}

let match_sig = self.linear.collection().sig_for_dataset(dataset_id)?;
let match_mh = match_sig.minhash().unwrap().clone();

// 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) {

Check warning on line 228 in src/core/src/index/revindex/mem_revindex.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/index/revindex/mem_revindex.rs#L228

Added line #L228 was not covered by tests
counter.subtract(self.colors.indices(color).cloned());
}
counter.remove(&dataset_id);
matches.push(result);
} else {
unimplemented!()
}
counter.remove(&dataset_id);
matches.push(result);
}
Ok(matches)
}
Expand Down

0 comments on commit 06867ac

Please sign in to comment.