aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcorespi/index/iindexcollection.h
blob: 97bc48c3cf17451671850f8a6f63db9559c63135 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "indexsearchable.h"

namespace search::queryeval { class ISourceSelector; }
namespace searchcorespi {

/**
 * Interface for a set of index searchables with source ids,
 * and a source selector for determining which index searchable to use for each document.
 */
class IIndexCollection {
protected:
    using ISourceSelector = search::queryeval::ISourceSelector;
public:
    using UP = std::unique_ptr<IIndexCollection>;
    using SP = std::shared_ptr<IIndexCollection>;

    virtual ~IIndexCollection() {}

    /**
     * Returns the source selector used to determine which index to use for each document.
     */
    virtual const ISourceSelector &getSourceSelector() const = 0;

    /**
     * Returns the number sources (index searchables) for this collection.
     */
    virtual size_t getSourceCount() const = 0;

    /**
     * Returns the index searchable for source i (i in the range [0, getSourceCount()>).
     */
    virtual IndexSearchable &getSearchable(uint32_t i) const = 0;

    /**
     * Returns the source id for source i (i in the range [0, getSourceCount()>).
     * The source id is used for this source in the source selector.
     */
    virtual uint32_t getSourceId(uint32_t i) const = 0;

    virtual vespalib::string toString() const;

};

}  // namespace searchcorespi