Fix query ids to be usize

This commit is contained in:
Clément Renault 2020-01-14 12:13:41 +01:00
parent 21c1473e0c
commit 681711fced
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 6 additions and 10 deletions

View File

@ -108,7 +108,7 @@ where
let posting_list_index = arena.add(range);
let bare_match = BareMatch {
document_id,
query_index: u16::try_from(query.id).unwrap(),
query_index: query.id,
distance: distance,
is_exact: true, // TODO where can I find this info?
postings_list: posting_list_index,
@ -232,7 +232,7 @@ where
pub struct BareMatch<'tag> {
pub document_id: DocumentId,
pub query_index: u16,
pub query_index: usize,
pub distance: u8,
pub is_exact: bool,
pub postings_list: Idx32<'tag>,
@ -251,7 +251,7 @@ impl fmt::Debug for BareMatch<'_> {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct SimpleMatch {
pub query_index: u16,
pub query_index: usize,
pub distance: u8,
pub attribute: u16,
pub word_index: u16,
@ -413,7 +413,7 @@ fn fetch_matches<'txn, 'tag>(
let posting_list_index = arena.add(range);
let bare_match = BareMatch {
document_id,
query_index: query_index as u16,
query_index,
distance: 0,
is_exact: *is_exact,
postings_list: posting_list_index,
@ -478,7 +478,7 @@ fn fetch_matches<'txn, 'tag>(
let posting_list_index = arena.add(range);
let bare_match = BareMatch {
document_id,
query_index: query_index as u16,
query_index,
distance,
is_exact,
postings_list: posting_list_index,

View File

@ -225,7 +225,6 @@ fn multiword_rewrite_matches(
if let Some(query_index) = replacement.next() {
let word_index = match_.word_index + padding as u16;
let query_index = query_index as u16;
let match_ = SimpleMatch { query_index, word_index, ..*match_ };
padded_matches.push(match_);
}
@ -237,12 +236,11 @@ fn multiword_rewrite_matches(
'padding: for (x, next_group) in nexts.enumerate() {
for (i, query_index) in replacement.clone().enumerate().skip(x) {
let word_index = match_.word_index + padding as u16 + (i + 1) as u16;
let query_index = query_index as u16;
let padmatch = SimpleMatch { query_index, word_index, ..*match_ };
for nmatch_ in next_group {
let mut rep = query_mapping[&(nmatch_.query_index as usize)].clone();
let query_index = rep.next().unwrap() as u16;
let query_index = rep.next().unwrap();
if query_index == padmatch.query_index {
if !found {
// if we find a corresponding padding for the
@ -250,7 +248,6 @@ fn multiword_rewrite_matches(
for (i, query_index) in replacement.clone().enumerate().take(i)
{
let word_index = match_.word_index + padding as u16 + (i + 1) as u16;
let query_index = query_index as u16;
let match_ = SimpleMatch { query_index, word_index, ..*match_ };
padded_matches.push(match_);
biggest = biggest.max(i + 1);
@ -274,7 +271,6 @@ fn multiword_rewrite_matches(
// we must insert the entire padding
for (i, query_index) in replacement.enumerate() {
let word_index = match_.word_index + padding as u16 + (i + 1) as u16;
let query_index = query_index as u16;
let match_ = SimpleMatch { query_index, word_index, ..*match_ };
padded_matches.push(match_);
}