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

retrieval.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba8b320e066fe0f52e64b824513117333fbc587b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once

#include "search/feature_offset_match.hpp"
#include "search/query_params.hpp"

#include "platform/mwm_traits.hpp"

#include "coding/reader.hpp"

#include "geometry/rect2d.hpp"

#include "base/cancellable.hpp"
#include "base/dfa_helpers.hpp"
#include "base/levenshtein_dfa.hpp"

#include "std/unique_ptr.hpp"

class MwmValue;

namespace coding
{
class CompressedBitVector;
}

namespace search
{
class MwmContext;
class TokenSlice;

class Retrieval
{
public:
  template<typename Value>
  using TrieRoot = trie::Iterator<ValueList<Value>>;

  Retrieval(MwmContext const & context, base::Cancellable const & cancellable);

  // Following functions retrieve from the search index corresponding to
  // |value| all features matching to |request|.
  unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(
      SearchTrieRequest<strings::UniStringDFA> const & request) const;

  unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(
      SearchTrieRequest<strings::PrefixDFAModifier<strings::UniStringDFA>> const & request) const;

  unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(
      SearchTrieRequest<strings::LevenshteinDFA> const & request) const;

  unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(
      SearchTrieRequest<strings::PrefixDFAModifier<strings::LevenshteinDFA>> const & request) const;

  // Retrieves from the search index corresponding to |value| all
  // postcodes matching to |slice|.
  unique_ptr<coding::CompressedBitVector> RetrievePostcodeFeatures(TokenSlice const & slice) const;

  // Retrieves from the geometry index corresponding to |value| all features belonging to |rect|.
  unique_ptr<coding::CompressedBitVector> RetrieveGeometryFeatures(m2::RectD const & rect,
                                                                   int scale) const;

private:
  template <template <typename> class R, typename... Args>
  unique_ptr<coding::CompressedBitVector> Retrieve(Args &&... args) const;

  MwmContext const & m_context;
  base::Cancellable const & m_cancellable;
  ModelReaderPtr m_reader;

  version::MwmTraits::SearchIndexFormat m_format;

  unique_ptr<TrieRoot<FeatureWithRankAndCenter>> m_root0;
  unique_ptr<TrieRoot<FeatureIndexValue>> m_root1;
};
}  // namespace search