aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/docsumstate.cpp
blob: 7a609f2c971929e4522d20f8388d2fb770db3555 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "docsumstate.h"
#include <vespa/juniper/rpinterface.h>
#include <vespa/searchcommon/attribute/iattributecontext.h>
#include <vespa/searchlib/common/location.h>
#include <vespa/searchlib/common/matching_elements.h>
#include "docsum_field_writer_state.h"

namespace search::docsummary {

GetDocsumsState::GetDocsumsState(GetDocsumsStateCallback &callback)
    : _args(),
      _docsumbuf(NULL),
      _docsumcnt(0),
      _kwExtractor(NULL),
      _keywords(NULL),
      _callback(callback),
      _dynteaser(),
      _docSumFieldSpace(_docSumFieldSpaceStore, sizeof(_docSumFieldSpaceStore)), // only alloc buffer if needed
      _attrCtx(),
      _attributes(),
      _fieldWriterStates(),
      _jsonStringer(),
      _parsedLocation(),
      _summaryFeatures(NULL),
      _summaryFeaturesCached(false),
      _rankFeatures(NULL),
      _matching_elements()
{
    _dynteaser._docid    = static_cast<uint32_t>(-1);
    _dynteaser._input    = static_cast<uint32_t>(-1);
    _dynteaser._lang     = static_cast<uint32_t>(-1);
    _dynteaser._config   = NULL;
    _dynteaser._query    = NULL;
    _dynteaser._result   = NULL;
}


GetDocsumsState::~GetDocsumsState()
{
    free(_docsumbuf);
    free(_keywords);
    if (_dynteaser._result != NULL) {
        juniper::ReleaseResult(_dynteaser._result);
    }
    if (_dynteaser._query != NULL) {
        juniper::ReleaseQueryHandle(_dynteaser._query);
    }
}

const MatchingElements &
GetDocsumsState::get_matching_elements()
{
    if (!_matching_elements) {
        _matching_elements = _callback.fill_matching_elements();
    }
    return *_matching_elements;
}

}