summaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.h
blob: 44874e69b311ddf9554e13a3d51a1b3c49e1fcd9 (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
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
74
75
76
77
78
79
80
81
82
83
84
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "isummarymanager.h"
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/common/doctypename.h>
#include <vespa/searchcorespi/flush/iflushtarget.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/docstore/logdocumentstore.h>
#include <vespa/searchlib/transactionlog/syncproxy.h>
#include <vespa/document/fieldvalue/document.h>

namespace search { class IBucketizer; }
namespace search::common { class FileHeaderContext; }

class Fast_NormalizeWordFolder;

namespace proton {

class SummaryManager : public ISummaryManager
{
public:
    class SummarySetup : public ISummarySetup {
    private:
        std::unique_ptr<search::docsummary::DynamicDocsumWriter> _docsumWriter;
        std::unique_ptr<Fast_NormalizeWordFolder>                _wordFolder;
        search::docsummary::JuniperProperties _juniperProps;
        std::unique_ptr<juniper::Juniper>     _juniperConfig;
        search::IAttributeManager::SP         _attributeMgr;
        search::IDocumentStore::SP            _docStore;
        const std::shared_ptr<const document::DocumentTypeRepo>  _repo;
    public:
        SummarySetup(const vespalib::string & baseDir,
                     const vespa::config::search::SummaryConfig & summaryCfg,
                     const vespa::config::search::SummarymapConfig & summarymapCfg,
                     const vespa::config::search::summary::JuniperrcConfig & juniperCfg,
                     search::IAttributeManager::SP attributeMgr,
                     search::IDocumentStore::SP docStore,
                     std::shared_ptr<const document::DocumentTypeRepo> repo);

        search::docsummary::IDocsumWriter & getDocsumWriter() const override { return *_docsumWriter; }
        const search::docsummary::ResultConfig & getResultConfig() override { return *_docsumWriter->GetResultConfig(); }

        search::docsummary::IDocsumStore::UP createDocsumStore() override;

        const search::IAttributeManager * getAttributeManager() const override { return _attributeMgr.get(); }
        vespalib::string lookupIndex(const vespalib::string & s) const override { (void) s; return ""; }
        juniper::Juniper * getJuniper() override { return _juniperConfig.get(); }
    };

private:
    vespalib::string               _baseDir;
    std::shared_ptr<search::IDocumentStore> _docStore;

public:
    typedef std::shared_ptr<SummaryManager> SP;
    SummaryManager(vespalib::Executor &shared_executor,
                   const search::LogDocumentStore::Config & summary,
                   const search::GrowStrategy & growStrategy,
                   const vespalib::string &baseDir,
                   const search::TuneFileSummary &tuneFileSummary,
                   const search::common::FileHeaderContext &fileHeaderContext,
                   search::transactionlog::SyncProxy &tlSyncer,
                   std::shared_ptr<search::IBucketizer> bucketizer);
    ~SummaryManager() override;

    void putDocument(uint64_t syncToken, search::DocumentIdT lid, const document::Document & doc);
    void putDocument(uint64_t syncToken, search::DocumentIdT lid, const vespalib::nbostream & doc);
    void removeDocument(uint64_t syncToken, search::DocumentIdT lid);
    searchcorespi::IFlushTarget::List getFlushTargets(vespalib::Executor & summaryService);

    ISummarySetup::SP
    createSummarySetup(const vespa::config::search::SummaryConfig &summaryCfg,
                       const vespa::config::search::SummarymapConfig &summarymapCfg,
                       const vespa::config::search::summary::JuniperrcConfig &juniperCfg,
                       const std::shared_ptr<const document::DocumentTypeRepo> &repo,
                       const search::IAttributeManager::SP &attributeMgr) override;

    search::IDocumentStore & getBackingStore() override { return *_docStore; }
    void reconfigure(const search::LogDocumentStore::Config & config);
};

} // namespace proton