MCPcopy Create free account
hub / github.com/comaps/comaps / MatchPostcodesInTrie

Function MatchPostcodesInTrie

libs/search/feature_offset_match.hpp:308–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307template <typename ValueList, typename Filter, typename ToDo>
308void MatchPostcodesInTrie(TokenSlice const & slice, trie::Iterator<ValueList> const & trieRoot, Filter const & filter,
309 ToDo && toDo)
310{
311 using namespace strings;
312 using Value = typename ValueList::Value;
313
314 uint32_t langIx = 0;
315 if (!impl::FindLangIndex(trieRoot, search::kPostcodesLang, langIx))
316 return;
317
318 auto const & edge = trieRoot.m_edges[langIx].m_label;
319 auto const postcodesRoot = trieRoot.GoToEdge(langIx);
320
321 impl::OffsetIntersector<Filter, Value> intersector(filter);
322 for (size_t i = 0; i < slice.Size(); ++i)
323 {
324 // Full match required even for prefix token. Reasons:
325 // 1. For postcode every symbol is important, partial matching can lead to wrong results.
326 // 2. For prefix match query like "streetname 40" where |streetname| is located in 40xxx
327 // postcode zone will give all street vicinity as the result which is wrong.
328 std::vector<UniStringDFA> dfas;
329 slice.Get(i).ForOriginalAndSynonyms([&dfas](UniString const & s) { dfas.emplace_back(s); });
330 MatchInTrie(dfas, TrieRootPrefix<ValueList>(*postcodesRoot, edge), intersector);
331
332 intersector.NextStep();
333 }
334
335 intersector.ForEachResult(toDo);
336}
337} // namespace search

Callers 1

Calls 9

FindLangIndexFunction · 0.85
MatchInTrieFunction · 0.85
NextStepMethod · 0.80
ForEachResultMethod · 0.80
GoToEdgeMethod · 0.45
SizeMethod · 0.45
GetMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected