Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'search/categories_cache.cpp')
-rw-r--r--search/categories_cache.cpp46
1 files changed, 8 insertions, 38 deletions
diff --git a/search/categories_cache.cpp b/search/categories_cache.cpp
index 233b21b84f..a0e6b6e21b 100644
--- a/search/categories_cache.cpp
+++ b/search/categories_cache.cpp
@@ -4,33 +4,17 @@
#include "search/query_params.hpp"
#include "search/retrieval.hpp"
+#include "indexer/classificator.hpp"
#include "indexer/ftypes_matcher.hpp"
+#include "indexer/search_string_utils.hpp"
#include "base/assert.hpp"
+#include "base/levenshtein_dfa.hpp"
#include "std/vector.hpp"
namespace search
{
-namespace
-{
-// Performs pairwise union of adjacent bit vectors
-// until at most one bit vector is left.
-void UniteCBVs(vector<CBV> & cbvs)
-{
- while (cbvs.size() > 1)
- {
- size_t i = 0;
- size_t j = 0;
- for (; j + 1 < cbvs.size(); j += 2)
- cbvs[i++] = cbvs[j].Union(cbvs[j + 1]);
- for (; j < cbvs.size(); ++j)
- cbvs[i++] = move(cbvs[j]);
- cbvs.resize(i);
- }
-}
-} // namespace
-
// CategoriesCache ---------------------------------------------------------------------------------
CBV CategoriesCache::Get(MwmContext const & context)
{
@@ -52,29 +36,15 @@ CBV CategoriesCache::Load(MwmContext const & context)
ASSERT(context.m_handle.IsAlive(), ());
ASSERT(context.m_value.HasSearchIndex(), ());
- QueryParams params;
- params.m_tokens.resize(1);
- params.m_tokens[0].resize(1);
+ auto const & c = classif();
- params.m_types.resize(1);
- params.m_types[0].resize(1);
+ SearchTrieRequest<strings::LevenshteinDFA> request;
- vector<CBV> cbvs;
-
- m_categories.ForEach([&](strings::UniString const & key, uint32_t const type) {
- params.m_tokens[0][0] = key;
- params.m_types[0][0] = type;
-
- CBV cbv(RetrieveAddressFeatures(context, m_cancellable, params));
- if (!cbv.IsEmpty())
- cbvs.push_back(move(cbv));
+ m_categories.ForEach([&request, &c](uint32_t const type) {
+ request.m_categories.emplace_back(FeatureTypeToString(c.GetIndexForType(type)));
});
- UniteCBVs(cbvs);
- if (cbvs.empty())
- cbvs.emplace_back();
-
- return cbvs[0];
+ return CBV(RetrieveAddressFeatures(context, m_cancellable, request));
}
// StreetsCache ------------------------------------------------------------------------------------