From 463856b89fbfb5056d1d830001c25cb2673f1ee9 Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Wed, 20 Mar 2019 20:44:39 +0300 Subject: [PATCH] [search] Minor fixes. --- search/engine.cpp | 10 --------- search/engine.hpp | 5 ----- search/geometry_utils.cpp | 5 ++++- .../assessment_tool/context.cpp | 11 +++++----- .../search_quality/assessment_tool/edits.cpp | 22 +++++++++---------- .../search_quality/assessment_tool/edits.hpp | 6 ++--- .../assessment_tool/main_model.cpp | 2 -- .../assessment_tool/result_view.cpp | 1 + 8 files changed, 24 insertions(+), 38 deletions(-) diff --git a/search/engine.cpp b/search/engine.cpp index 5e0b90655e..75cc6b6171 100644 --- a/search/engine.cpp +++ b/search/engine.cpp @@ -1,22 +1,12 @@ #include "search/engine.hpp" -#include "search/geometry_utils.hpp" #include "search/processor.hpp" -#include "search/search_params.hpp" #include "storage/country_info_getter.hpp" #include "indexer/categories_holder.hpp" -#include "indexer/classificator.hpp" -#include "indexer/scales.hpp" #include "indexer/search_string_utils.hpp" -#include "platform/platform.hpp" - -#include "geometry/distance_on_sphere.hpp" -#include "geometry/mercator.hpp" - -#include "base/logging.hpp" #include "base/scope_guard.hpp" #include "base/stl_helpers.hpp" diff --git a/search/engine.hpp b/search/engine.hpp index a18e096633..48a5e2054f 100644 --- a/search/engine.hpp +++ b/search/engine.hpp @@ -1,14 +1,11 @@ #pragma once #include "search/bookmarks/processor.hpp" -#include "search/result.hpp" #include "search/search_params.hpp" #include "search/suggest.hpp" #include "indexer/categories_holder.hpp" -#include "coding/reader.hpp" - #include "base/macros.hpp" #include "base/thread.hpp" @@ -135,8 +132,6 @@ private: Fn m_fn; }; - // alignas() is used here to prevent false-sharing between different - // threads. struct Context { // This field *CAN* be accessed by other threads, so |m_mu| must diff --git a/search/geometry_utils.cpp b/search/geometry_utils.cpp index 68b730c0ae..f94ccab1c0 100644 --- a/search/geometry_utils.cpp +++ b/search/geometry_utils.cpp @@ -1,4 +1,4 @@ -#include "geometry_utils.hpp" +#include "search/geometry_utils.hpp" #include "indexer/scales.hpp" @@ -16,6 +16,9 @@ bool IsEqualMercator(m2::RectD const & r1, m2::RectD const & r2, double eps) return m2::IsEqual(r1, r2, eps, eps); } +// 11.5 - lower bound for rect when we need to inflate it +// 1.5 - inflate delta for viewport scale +// 7 - query scale depth to cache viewport features bool GetInflatedViewport(m2::RectD & viewport) { // 11.5 - lower bound for rect when we need to inflate it diff --git a/search/search_quality/assessment_tool/context.cpp b/search/search_quality/assessment_tool/context.cpp index ec02b87313..8a968b2a4c 100644 --- a/search/search_quality/assessment_tool/context.cpp +++ b/search/search_quality/assessment_tool/context.cpp @@ -43,7 +43,6 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const // Iterates over original (loaded from the file with search samples) // results first. - size_t k = 0; for (size_t i = 0; i < m_sample.m_results.size(); ++i) { @@ -53,7 +52,7 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const { auto const & entry = nonFoundEntries[k++]; auto const deleted = entry.m_deleted; - auto const & curr = entry.m_curr; + auto const & curr = entry.m_currRelevance; if (!deleted && curr) { auto result = m_sample.m_results[i]; @@ -63,11 +62,11 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const continue; } - if (!foundEntries[j].m_curr) + if (!foundEntries[j].m_currRelevance) continue; auto result = m_sample.m_results[i]; - result.m_relevance = *foundEntries[j].m_curr; + result.m_relevance = *foundEntries[j].m_currRelevance; outResults.push_back(move(result)); } @@ -81,7 +80,7 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const continue; } - if (!foundEntries[i].m_curr) + if (!foundEntries[i].m_currRelevance) continue; auto const & result = m_foundResults[i]; @@ -91,7 +90,7 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const auto ft = loader.Load(result.GetFeatureID()); CHECK(ft, ()); - outResults.push_back(search::Sample::Result::Build(*ft, *foundEntries[i].m_curr)); + outResults.push_back(search::Sample::Result::Build(*ft, *foundEntries[i].m_currRelevance)); } return outSample; diff --git a/search/search_quality/assessment_tool/edits.cpp b/search/search_quality/assessment_tool/edits.cpp index 1a2e19c380..1e0ea94a11 100644 --- a/search/search_quality/assessment_tool/edits.cpp +++ b/search/search_quality/assessment_tool/edits.cpp @@ -8,12 +8,12 @@ namespace { void UpdateNumEdits(Edits::Entry const & entry, Edits::Relevance const & r, size_t & numEdits) { - if (entry.m_curr != entry.m_orig && r == entry.m_orig) + if (entry.m_currRelevance != entry.m_origRelevance && r == entry.m_origRelevance) { CHECK_GREATER(numEdits, 0, ()); --numEdits; } - if (entry.m_curr == entry.m_orig && r != entry.m_orig) + if (entry.m_currRelevance == entry.m_origRelevance && r != entry.m_origRelevance) ++numEdits; } } // namespace @@ -31,7 +31,7 @@ bool Edits::Editor::Set(Relevance relevance) boost::optional const & Edits::Editor::Get() const { - return m_parent.Get(m_index).m_curr; + return m_parent.Get(m_index).m_currRelevance; } bool Edits::Editor::HasChanges() const { return m_parent.HasChanges(m_index); } @@ -47,7 +47,7 @@ void Edits::Apply() WithObserver(Update::MakeAll(), [this]() { for (auto & entry : m_entries) { - entry.m_orig = entry.m_curr; + entry.m_origRelevance = entry.m_currRelevance; entry.m_type = Entry::Type::Loaded; } m_numEdits = 0; @@ -61,8 +61,8 @@ void Edits::Reset(vector> const & relevances) for (size_t i = 0; i < m_entries.size(); ++i) { auto & entry = m_entries[i]; - entry.m_orig = relevances[i]; - entry.m_curr = relevances[i]; + entry.m_origRelevance = relevances[i]; + entry.m_currRelevance = relevances[i]; entry.m_deleted = false; entry.m_type = Entry::Type::Loaded; } @@ -79,8 +79,8 @@ bool Edits::SetRelevance(size_t index, Relevance relevance) UpdateNumEdits(entry, relevance, m_numEdits); - entry.m_curr = relevance; - return entry.m_curr != entry.m_orig; + entry.m_currRelevance = relevance; + return entry.m_currRelevance != entry.m_origRelevance; }); } @@ -90,7 +90,7 @@ void Edits::SetAllRelevances(Relevance relevance) for (auto & entry : m_entries) { UpdateNumEdits(entry, relevance, m_numEdits); - entry.m_curr = relevance; + entry.m_currRelevance = relevance; } }); } @@ -153,7 +153,7 @@ vector> Edits::GetRelevances() const { vector> relevances(m_entries.size()); for (size_t i = 0; i < m_entries.size(); ++i) - relevances[i] = m_entries[i].m_curr; + relevances[i] = m_entries[i].m_currRelevance; return relevances; } @@ -177,5 +177,5 @@ bool Edits::HasChanges(size_t index) const { CHECK_LESS(index, m_entries.size(), ()); auto const & entry = m_entries[index]; - return entry.m_curr != entry.m_orig; + return entry.m_currRelevance != entry.m_origRelevance; } diff --git a/search/search_quality/assessment_tool/edits.hpp b/search/search_quality/assessment_tool/edits.hpp index df1793ed2e..3e782f7d98 100644 --- a/search/search_quality/assessment_tool/edits.hpp +++ b/search/search_quality/assessment_tool/edits.hpp @@ -27,12 +27,12 @@ public: Entry() = default; Entry(boost::optional relevance, Type type) - : m_curr(relevance), m_orig(relevance), m_type(type) + : m_currRelevance(relevance), m_origRelevance(relevance), m_type(type) { } - boost::optional m_curr = {}; - boost::optional m_orig = {}; + boost::optional m_currRelevance = {}; + boost::optional m_origRelevance = {}; bool m_deleted = false; Type m_type = Type::Loaded; }; diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index e25a736d8f..d55b68a873 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -25,8 +25,6 @@ using namespace std; -// MainModel::SampleContext ------------------------------------------------------------------------ - // MainModel --------------------------------------------------------------------------------------- MainModel::MainModel(Framework & framework) : m_framework(framework) diff --git a/search/search_quality/assessment_tool/result_view.cpp b/search/search_quality/assessment_tool/result_view.cpp index dd330f64d4..f8cdb6cb9b 100644 --- a/search/search_quality/assessment_tool/result_view.cpp +++ b/search/search_quality/assessment_tool/result_view.cpp @@ -181,6 +181,7 @@ void ResultView::UpdateRelevanceRadioButtons() m_vital->setChecked(false); auto const & r = m_editor->Get(); + if (!r) return;