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

#pragma once

#include "handle.h"
#include "matchdata.h"

namespace search::fef {

/**
 * This class is used to describe the layout of term match data and
 * features within MatchData objects for a single query.
 **/
class MatchDataLayout
{
private:
    uint32_t _numTermFields;
    std::vector<uint32_t> _fieldIds;

public:
    /**
     * Create an empty object.
     **/
    MatchDataLayout();
    ~MatchDataLayout();

    /**
     * Allocate space for a term field match data structure.
     *
     * @param fieldId the field ID the space will be used for
     * @return handle to be used with match data objects
     **/
    TermFieldHandle allocTermField(uint32_t fieldId) {
        _fieldIds.push_back(fieldId);
        return _numTermFields++;
    }

    /**
     * Create a match data object with the layout described by this
     * object. Note that this method should only be invoked after all
     * terms and features have been allocated.
     *
     * @return auto-pointer to a match data object
     **/
    MatchData::UP createMatchData() const;
};

}