aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/simpletermfielddata.h
blob: e455d5371a47e6c8fa56bf2134dd1fbea55688c3 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "itermfielddata.h"

namespace search::fef {

/**
 * Information about a single field that is being searched for a term
 * (described by the TermData class). The field may be either an index
 * field or an attribute field. If more information about the field is
 * needed, the field id may be used to consult the index environment.
 **/
class SimpleTermFieldData : public ITermFieldData
{
private:
    TermFieldHandle _handle;

public:
    /**
     * Side-cast copy constructor.
     **/
    SimpleTermFieldData(const ITermFieldData &rhs) noexcept
        : ITermFieldData(rhs),
          _handle(rhs.getHandle())
    {}

    /**
     * Create a new instance for the given field.
     *
     * @param fieldId the field being searched
     **/
    SimpleTermFieldData(uint32_t fieldId) noexcept
        : ITermFieldData(fieldId),
          _handle(IllegalHandle)
    {}

    using ITermFieldData::getHandle;

    TermFieldHandle getHandle(MatchDataDetails requestedDetails) const override {
        (void) requestedDetails;
        return _handle;
    }

    /**
     * Sets the match handle for this field.
     **/
    SimpleTermFieldData &setHandle(TermFieldHandle handle) noexcept {
        _handle = handle;
        return *this;
    }
};

}