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

#pragma once

#include "general_result.h"
#include "resultconfig.h"
#include "docsum_field_writer.h"
#include "juniper_input.h"
#include <vespa/searchlib/util/rawbuf.h>
#include <vespa/vespalib/data/slime/inserter.h>
#include <vespa/juniper/rpinterface.h>

namespace search::docsummary {

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

    uint32_t                         _inputFieldEnumValue;
    vespalib::string                 _input_field_name;
    std::unique_ptr<juniper::Config> _juniperConfig;
    uint32_t                         _langFieldEnumValue;
    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 char *langFieldName,
              const ResultConfig & config, const char *inputField) override;
protected:
    JuniperTeaserDFW(juniper::Juniper * juniper) : JuniperDFW(juniper) { }
};


class DynamicTeaserDFW : public JuniperTeaserDFW
{
    JuniperInput getJuniperInput(GeneralResult *gres) __attribute__((noinline));
    vespalib::string makeDynamicTeaser(uint32_t docid,
                                       vespalib::stringref input,
                                       GetDocsumsState *state);
public:
    DynamicTeaserDFW(juniper::Juniper * juniper) : JuniperTeaserDFW(juniper) { }

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

}