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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "isearchableindexcollection.h"
#include <vespa/searchlib/util/searchable_stats.h>
namespace searchcorespi {
/**
* Holds a set of index searchables with source ids, and a source selector for
* determining which index to use for each document.
*/
class IndexCollection : public ISearchableIndexCollection
{
struct SourceWithId {
uint32_t id;
IndexSearchable::SP source_wrapper;
SourceWithId(uint32_t id_in, const IndexSearchable::SP &source_in)
: id(id_in), source_wrapper(source_in)
{}
SourceWithId() : id(0), source_wrapper() {}
};
// Selector shared across memory dumps, replaced on disk fusion operations
using ISourceSelectorSP = std::shared_ptr<ISourceSelector>;
ISourceSelectorSP _source_selector;
std::vector<SourceWithId> _sources;
public:
IndexCollection(const ISourceSelectorSP & selector);
IndexCollection(const ISourceSelectorSP & selector, const ISearchableIndexCollection &sources);
~IndexCollection();
void append(uint32_t id, const IndexSearchable::SP &source) override;
void replace(uint32_t id, const IndexSearchable::SP &source) override;
IndexSearchable::SP getSearchableSP(uint32_t i) const override;
void setSource(uint32_t docId) override;
// Implements IIndexCollection
const ISourceSelector &getSourceSelector() const override;
size_t getSourceCount() const override;
IndexSearchable &getSearchable(uint32_t i) const override;
uint32_t getSourceId(uint32_t i) const override;
// Implements IndexSearchable
Blueprint::UP
createBlueprint(const IRequestContext & requestContext, const FieldSpec &field, const Node &term) override;
Blueprint::UP
createBlueprint(const IRequestContext & requestContext, const FieldSpecList &fields, const Node &term) override;
search::SearchableStats getSearchableStats() const override;
search::SerialNum getSerialNum() const override;
void accept(IndexSearchableVisitor &visitor) const override;
static ISearchableIndexCollection::UP
replaceAndRenumber(const ISourceSelectorSP & selector, const ISearchableIndexCollection &fsc,
uint32_t id_diff, const IndexSearchable::SP &new_source);
};
} // namespace searchcorespi
|