aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/juniperdfw.h
blob: 6a117fbc0cd45e3eac5b18195b6d496707730d1a (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "docsum_field_writer.h"
#include <memory>

namespace juniper {
class Config;
class Juniper;
}
namespace vespalib::slime { struct Inserter; }

namespace search::docsummary {

class JuniperDFW : public DocsumFieldWriter
{
public:
    virtual bool Init(
            const char *fieldName,
            const vespalib::string& inputField);
protected:
    explicit JuniperDFW(juniper::Juniper * juniper);
    ~JuniperDFW() override;

    vespalib::string                 _input_field_name;
    std::unique_ptr<juniper::Config> _juniperConfig;
    juniper::Juniper                *_juniper;
private:
    bool IsGenerated() const override { return false; }
    JuniperDFW(const JuniperDFW &);
    JuniperDFW & operator=(const JuniperDFW &);
};


class JuniperTeaserDFW : public JuniperDFW
{
public:
    bool Init(const char *fieldName,
              const vespalib::string& inputField) override;
protected:
    explicit JuniperTeaserDFW(juniper::Juniper * juniper) : JuniperDFW(juniper) { }
};


class DynamicTeaserDFW : public JuniperTeaserDFW
{
    vespalib::string makeDynamicTeaser(uint32_t docid,
                                       vespalib::stringref input,
                                       GetDocsumsState *state) const;
public:
    explicit DynamicTeaserDFW(juniper::Juniper * juniper) : JuniperTeaserDFW(juniper) { }

    void insertField(uint32_t docid, const IDocsumStoreDocument* doc, GetDocsumsState *state,
                     ResType type, vespalib::slime::Inserter &target) const override;
};

}