summaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/searchview.h
blob: c8174c0a9a661a6fa293faf79a050bd8f343c68c (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "matchview.h"
#include <vespa/searchcore/proton/docsummary/isummarymanager.h>
#include <vespa/searchcore/proton/summaryengine/isearchhandler.h>

namespace proton {

class SearchView : public ISearchHandler, public std::enable_shared_from_this<SearchView>
{
public:
    using SessionManagerSP = std::shared_ptr<matching::SessionManager>;
    using IndexSearchable = searchcorespi::IndexSearchable;
    using InternalDocsumReply = std::pair<std::unique_ptr<DocsumReply>, bool>;
    typedef std::shared_ptr<SearchView> SP;

    static std::shared_ptr<SearchView> create(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView);
    SearchView(const SearchView &) = delete;
    SearchView(SearchView &&) = delete;
    SearchView &operator=(const SearchView &) = delete;
    SearchView &operator=(SearchView &&) = delete;
    ~SearchView() override;

    const ISummaryManager::ISummarySetup::SP & getSummarySetup() const { return _summarySetup; }
    const MatchView::SP & getMatchView() const { return _matchView; }
    const Matchers::SP  & getMatchers()  const { return _matchView->getMatchers(); }
    const IndexSearchable::SP   & getIndexSearchable()  const { return _matchView->getIndexSearchable(); }
    const IAttributeManager::SP & getAttributeManager() const { return _matchView->getAttributeManager(); }
    const SessionManagerSP  & getSessionManager()    const { return _matchView->getSessionManager(); }
    const IDocumentMetaStoreContext::SP & getDocumentMetaStore() const { return _matchView->getDocumentMetaStore(); }
    DocIdLimit &getDocIdLimit() const { return _matchView->getDocIdLimit(); }
    matching::MatchingStats getMatcherStats(const vespalib::string &rankProfile) const { return _matchView->getMatcherStats(rankProfile); }

    std::unique_ptr<DocsumReply> getDocsums(const DocsumRequest & req) override;
    std::unique_ptr<SearchReply> match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const override;
private:
    SearchView(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView);
    InternalDocsumReply getDocsumsInternal(const DocsumRequest & req);
    ISummaryManager::ISummarySetup::SP _summarySetup;
    MatchView::SP                      _matchView;
};

} // namespace proton