blob: b2490f012328a6f0f412f21184f5332053fd6877 (
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
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/base/field.h>
namespace document {
class DocumentType;
class AllFields final : public FieldSet
{
public:
static constexpr const char * NAME = "[all]";
bool contains(const FieldSet&) const override { return true; }
Type getType() const override { return Type::ALL; }
};
class NoFields final : public FieldSet
{
public:
static constexpr const char * NAME = "[none]";
bool contains(const FieldSet& f) const override { return f.getType() == Type::NONE; }
Type getType() const override { return Type::NONE; }
};
class DocIdOnly final : public FieldSet
{
public:
static constexpr const char * NAME = "[id]";
bool contains(const FieldSet& fields) const override {
return fields.getType() == Type::DOCID || fields.getType() == Type::NONE;
}
Type getType() const override { return Type::DOCID; }
};
class DocumentOnly final : public FieldSet
{
public:
static constexpr const char * NAME = "[document]";
bool contains(const FieldSet& fields) const override {
return fields.getType() == Type::DOCUMENT_ONLY
|| fields.getType() == Type::DOCID
|| fields.getType() == Type::NONE;
}
Type getType() const override { return Type::DOCUMENT_ONLY; }
};
class FieldCollection : public FieldSet
{
public:
using UP = std::unique_ptr<FieldCollection>;
FieldCollection(const DocumentType& docType, Field::Set set);
FieldCollection(const FieldCollection &);
FieldCollection(FieldCollection&&) noexcept = default;
~FieldCollection() override;
FieldCollection& operator=(const FieldCollection&) = default;
FieldCollection& operator=(FieldCollection&&) noexcept = default;
bool contains(const FieldSet& fields) const override;
Type getType() const override { return Type::SET; }
const DocumentType& getDocumentType() const { return *_docType; }
const Field::Set& getFields() const { return _set; }
uint64_t hash() const { return _hash; }
private:
Field::Set _set;
uint64_t _hash;
const DocumentType* _docType;
};
}
|