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

#pragma once

#include <cstdint>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/searchlib/index/field_length_info.h>

namespace search::index {
class PostingListParams;
class Schema;
}

namespace vespalib { class GenericHeader; }

namespace search::bitcompression {

class PosOccFieldParams
{
public:
    using PostingListParams = index::PostingListParams;
    using Schema = index::Schema;

    enum CollectionType
    {
        SINGLE,
        ARRAY,
        WEIGHTEDSET
    };

    uint8_t _elemLenK;
    bool    _hasElements;
    bool    _hasElementWeights;
    uint32_t _avgElemLen;
    CollectionType _collectionType;
    vespalib::string _name;
    index::FieldLengthInfo _field_length_info;

    PosOccFieldParams();

    bool operator==(const PosOccFieldParams &rhs) const;
    static vespalib::string getParamsPrefix(uint32_t idx);
    void getParams(PostingListParams &params, uint32_t idx) const;
    void setParams(const PostingListParams &params, uint32_t idx);
    void setSchemaParams(const Schema &schema, uint32_t fieldId);
    void readHeader(const vespalib::GenericHeader &header, const vespalib::string &prefix);
    void writeHeader(vespalib::GenericHeader &header, const vespalib::string &prefix) const;
    const index::FieldLengthInfo &get_field_length_info() const { return _field_length_info; }
    void set_field_length_info(const index::FieldLengthInfo &field_length_info) { _field_length_info = field_length_info; }
};

}