blob: 65796fd4c744bc2dfc4763fb9c72dc3936d6c8cb (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "attribute_collection_spec.h"
#include "exclusive_attribute_read_accessor.h"
#include "i_attribute_factory.h"
#include <vespa/searchcommon/attribute/i_attribute_functor.h>
#include <vespa/searchcorespi/flush/iflushtarget.h>
#include <vespa/searchlib/attribute/iattributemanager.h>
#include <vespa/searchlib/common/serialnum.h>
namespace search::attribute { class IAttributeFunctor; }
namespace vespalib {
class ISequencedTaskExecutor;
class ThreadExecutor;
class IDestructorCallback;
}
namespace proton {
class ImportedAttributesRepo;
/**
* Proton specific interface for an attribute manager that handles a set of attribute vectors.
*
* The attribute manager should handle initialization and loading of attribute vectors,
* and then provide access to the attributes for feeding, searching and flushing.
*/
struct IAttributeManager : public search::IAttributeManager
{
using SP = std::shared_ptr<IAttributeManager>;
using OnWriteDoneType = const std::shared_ptr<vespalib::IDestructorCallback> &;
using IAttributeFunctor = search::attribute::IAttributeFunctor;
using IConstAttributeFunctor = search::attribute::IConstAttributeFunctor;
/**
* Create a new attribute manager based on the content of the current one and
* the given attribute collection spec.
*/
virtual IAttributeManager::SP create(const AttributeCollectionSpec &spec) const = 0;
/**
* Return the list of flush targets for this attribute manager.
*/
virtual std::vector<searchcorespi::IFlushTarget::SP> getFlushTargets() const = 0;
/**
* Returns the flushed serial num for the given attribute.
* Return 0 if attribute is not found.
*/
virtual search::SerialNum getFlushedSerialNum(const vespalib::string &name) const = 0;
/**
* Return the oldest flushed serial number among the underlying attribute vectors.
*/
virtual search::SerialNum getOldestFlushedSerialNumber() const = 0;
virtual search::SerialNum getNewestFlushedSerialNumber() const = 0;
/**
* Fills all underlying attribute vectors (including extra attributes) into the given list.
*/
virtual void getAttributeListAll(std::vector<search::AttributeGuard> &list) const = 0;
/**
* Prune removed attributes from file system.
*/
virtual void pruneRemovedFields(search::SerialNum serialNum) = 0;
/**
* Returns the attribute factory used by this manager.
*/
virtual const IAttributeFactory::SP &getFactory() const = 0;
virtual vespalib::ISequencedTaskExecutor &getAttributeFieldWriter() const = 0;
virtual vespalib::ThreadExecutor& get_shared_executor() const = 0;
/*
* Get pointer to named writable attribute. If attribute isn't
* found or is an extra attribute then nullptr is returned.
*
* The attribute writer doesn't need attribute guards to access
* attributes. Lifetime should be guaranteed by syncing threads
* at config changes.
*/
virtual search::AttributeVector *getWritableAttribute(const vespalib::string &name) const = 0;
/*
* Get pointers to all writable attributes.
*
* The attribute writer doesn't need attribute guards to access
* attributes. Lifetime should be guaranteed by syncing threads
* at config changes.
*/
virtual const std::vector<search::AttributeVector *> &getWritableAttributes() const = 0;
virtual void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const = 0;
virtual ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const = 0;
virtual void setImportedAttributes(std::unique_ptr<ImportedAttributesRepo> attributes) = 0;
virtual const ImportedAttributesRepo *getImportedAttributes() const = 0;
};
} // namespace proton
|