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
path: root/search
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-08-21 21:50:35 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:42:00 +0300
commit55dbe694da30f681c68e6ef9b1df1b6dbc7ff57b (patch)
tree87e061f3f01837679a935dcdff97cccf56b44b33 /search
parent8c24fdf04016b109c3cf932fd5b663a54d432d40 (diff)
[search] Some fixes.
Diffstat (limited to 'search')
-rw-r--r--search/feature_offset_match.hpp31
-rw-r--r--search/search_query.cpp32
2 files changed, 48 insertions, 15 deletions
diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp
index 091a3e4956..c64a845d32 100644
--- a/search/feature_offset_match.hpp
+++ b/search/feature_offset_match.hpp
@@ -13,6 +13,8 @@
#include "../std/utility.hpp"
#include "../std/vector.hpp"
+//#include "../sparsehash/dense_hash_set.hpp"
+
namespace search
{
@@ -176,10 +178,21 @@ template <class FilterT> class OffsetIntersecter
scoped_ptr<SetType> m_prevSet;
scoped_ptr<SetType> m_set;
+ void InitSet(scoped_ptr<SetType> & ptr)
+ {
+ ptr.reset(new SetType());
+
+ // this is not std compatible, but important for google::dense_hash_set
+ //ValueT zero;
+ //zero.m_featureId = 0;
+ //ptr->set_empty_key(zero);
+ }
+
public:
explicit OffsetIntersecter(FilterT const & filter)
- : m_filter(filter), m_set(new SetType())
+ : m_filter(filter)
{
+ InitSet(m_set);
}
void operator() (ValueT const & v)
@@ -196,7 +209,7 @@ public:
void NextStep()
{
if (!m_prevSet)
- m_prevSet.reset(new SetType());
+ InitSet(m_prevSet);
m_prevSet.swap(m_set);
m_set->clear();
@@ -293,11 +306,11 @@ void MatchFeaturesInTrie(vector<vector<strings::UniString> > const & tokens,
// match in trie
impl::FullMatchInTrie(trieRoot.m_root, trieRoot.m_prefix, trieRoot.m_prefixSize,
tokens[i][j], intersecter);
-
- // get additional features for token
- addHolder.GetValues(i, intersecter);
}
+ // get additional features for 'i' token
+ addHolder.GetValues(i, intersecter);
+
intersecter.NextStep();
}
@@ -310,13 +323,15 @@ void MatchFeaturesInTrie(vector<vector<strings::UniString> > const & tokens,
// match in trie
impl::PrefixMatchInTrie(trieRoot.m_root, trieRoot.m_prefix, trieRoot.m_prefixSize,
prefixTokens[i], intersecter);
-
- // get additional features for token
- addHolder.GetValues(count, intersecter);
}
if (prefixCount > 0)
+ {
+ // get additional features for prefix token
+ addHolder.GetValues(count, intersecter);
+
intersecter.NextStep();
+ }
intersecter.ForEachResult(toDo);
}
diff --git a/search/search_query.cpp b/search/search_query.cpp
index e53a67ce4b..cb69e71c4c 100644
--- a/search/search_query.cpp
+++ b/search/search_query.cpp
@@ -171,6 +171,7 @@ void Query::SetPreferredLanguage(string const & lang)
void Query::SetInputLanguage(int8_t lang)
{
+ LOG(LDEBUG, ("New input language = ", lang));
SetLanguage(LANG_INPUT, lang);
}
@@ -796,6 +797,16 @@ namespace impl
};
void swap(Locality & r1, Locality & r2) { r1.Swap(r2); }
+
+ string DebugPrint(Locality const & l)
+ {
+ string res("Locality: ");
+ res += "Name: " + l.m_name;
+ res += "; Name English: " + l.m_enName;
+ res += "; Rank: " + ::DebugPrint(l.m_value.m_rank);
+ res += "; Matched: " + ::DebugPrint(l.m_matchedTokens.size());
+ return res;
+ }
}
void Query::SearchAddress()
@@ -891,21 +902,25 @@ namespace impl
}
};
- int8_t m_lang, m_en, m_int;
+ int8_t m_lang;
+ int8_t m_arrEn[3];
+
void AssignEnglishName(FeatureType const & f, Locality & l)
{
- if (!f.GetName(m_en, l.m_enName))
- (void)f.GetName(m_int, l.m_enName);
+ for (int i = 0; i < 3; ++i)
+ if (f.GetName(m_arrEn[i], l.m_enName))
+ break;
}
volatile bool & m_isCancelled;
public:
- DoFindLocality(MwmValue * pMwm, int8_t lang, volatile bool & isCancelled)
+ DoFindLocality(Query & q, MwmValue * pMwm, int8_t lang, volatile bool & isCancelled)
: m_vector(pMwm->m_cont, pMwm->GetHeader()), m_lang(lang), m_isCancelled(isCancelled)
{
- m_en = StringUtf8Multilang::GetLangIndex("en");
- m_int = StringUtf8Multilang::GetLangIndex("int_name");
+ m_arrEn[0] = q.GetLanguage(LANG_ENGLISH);
+ m_arrEn[1] = q.GetLanguage(LANG_INTERNATIONAL);
+ m_arrEn[2] = q.GetLanguage(LANG_DEFAULT);
}
void Resize(size_t) {}
@@ -983,14 +998,17 @@ bool Query::SearchLocality(MwmValue * pMwm, impl::Locality & res)
{
scoped_ptr<TrieIterator> pLangRoot(pTrieRoot->GoToEdge(i));
- impl::DoFindLocality doFind(pMwm, lang, m_cancel);
+ impl::DoFindLocality doFind(*this, pMwm, lang, m_cancel);
GetFeaturesInTrie(params.m_tokens, params.m_prefixTokens,
TrieRootPrefix(*pLangRoot, edge), doFind);
// save better locality, if any
impl::Locality loc;
if (doFind.GetBestLocality(loc) && (res < loc))
+ {
+ LOG(LDEBUG, ("Better location ", loc, " for lang ", lang));
res = loc;
+ }
}
}