blob: 83554e6624a50b143b8f2231e49795581454065e (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* \class document::WeightedSetDataType
* \ingroup datatype
*
* \brief DataType describing a weighted set.
*
* Describes what can be stored and behaviour of weighted sets with this type.
* The create if non-existing and remove if zero weight functionality, as used
* in tagging, is a part of the type.
*/
#pragma once
#include "collectiondatatype.h"
namespace document {
class WeightedSetDataType final : public CollectionDataType {
bool _createIfNonExistent;
bool _removeIfZero;
public:
WeightedSetDataType(const DataType& nestedType, bool createIfNonExistent, bool removeIfZero);
WeightedSetDataType(const DataType& nestedType, bool createIfNonExistent, bool removeIfZero, int id);
WeightedSetDataType(const WeightedSetDataType &) = delete;
WeightedSetDataType & operator=(const WeightedSetDataType &) = delete;
~WeightedSetDataType() override;
/**
* @return Whether values of this datatype will autogenerate entries if
* operations that require an existing entries operates on non-existing
* ones.
*/
bool createIfNonExistent() const { return _createIfNonExistent; };
/**
* @return Whether values of this datatype will automatically
* remove entries with zero weight.
*/
bool removeIfZero() const { return _removeIfZero; };
bool isWeightedSet() const noexcept override { return true; }
std::unique_ptr<FieldValue> createFieldValue() const override;
void print(std::ostream&, bool verbose, const std::string& indent) const override;
bool equals(const DataType& other) const noexcept override;
void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
};
} // document
|