Add typo ranking rule to new search impl

This commit is contained in:
Loïc Lecrenier
2023-02-28 14:19:57 +01:00
parent 71f18e4379
commit caa1e1b923
6 changed files with 193 additions and 17 deletions

View File

@ -70,14 +70,16 @@ impl<'transaction, G: RankingRuleGraphTrait> RankingRule<'transaction, QueryGrap
) -> Result<Option<RankingRuleOutput<QueryGraph>>> {
assert!(universe.len() > 1);
let mut state = self.state.take().unwrap();
let Some(mut cheapest_paths_state) = state.cheapest_paths_state.take() else {
if state.cheapest_paths_state.is_none() {
return Ok(None);
};
}
let mut paths = PathsMap::default();
while paths.is_empty() {
let Some(cheapest_paths_state) = state.cheapest_paths_state.take() else {
break;
};
if let Some(next_cheapest_paths_state) = cheapest_paths_state
.compute_paths_of_next_lowest_cost(
&mut state.graph,
@ -85,13 +87,15 @@ impl<'transaction, G: RankingRuleGraphTrait> RankingRule<'transaction, QueryGrap
&mut paths,
)
{
cheapest_paths_state = next_cheapest_paths_state;
state.cheapest_paths_state = Some(next_cheapest_paths_state);
} else {
self.state = None;
return Ok(None);
break;
}
}
state.cheapest_paths_state = Some(cheapest_paths_state);
if paths.is_empty() && state.cheapest_paths_state.is_none() {
return Ok(None);
}
G::log_state(&state.graph, &paths, &state.empty_paths_cache, logger);