aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp
blob: db5518ce7798c1918d0b391ff4884815ff5c51cb (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.

#include "getdocsumargs.h"
#include <vespa/vespalib/stllike/hash_set_insert.hpp>

namespace search::docsummary {

GetDocsumArgs::GetDocsumArgs()
    : _resultClassName(),
      _dumpFeatures(false),
      _locations_possible(true),
      _stackDump(),
      _location(),
      _timeout(30s),
      _highlightTerms(),
      _fields()
{ }

GetDocsumArgs::~GetDocsumArgs() = default;

void
GetDocsumArgs::initFromDocsumRequest(const engine::DocsumRequest &req)
{
    _dumpFeatures       = req.dumpFeatures;
    _resultClassName    = req.resultClassName;
    _stackDump          = req.stackDump;
    _location           = req.location;
    _locations_possible = true;
    _timeout            = req.getTimeLeft();
    _highlightTerms     = req.propertiesMap.highlightTerms();
    _fields             = FieldSet(req.getFields().begin(), req.getFields().end());
}

void
GetDocsumArgs::setStackDump(uint32_t stackDumpLen, const char *stackDump)
{
    _stackDump.resize(stackDumpLen);
    memcpy(&_stackDump[0], stackDump, _stackDump.size());
}

bool
GetDocsumArgs::need_field(vespalib::stringref field) const {
    return _fields.empty() || _fields.contains(field);
}

}