1#pragma once
2
3#include <Columns/IColumn.h>
4#include <DataStreams/IBlockStream_fwd.h>
5
6#include <vector>
7
8
9namespace DB
10{
11class IDictionarySource;
12using DictionarySourcePtr = std::unique_ptr<IDictionarySource>;
13
14/** Data-provider interface for external dictionaries,
15* abstracts out the data source (file, MySQL, ClickHouse, external program, network request et cetera)
16* from the presentation and memory layout (the dictionary itself).
17*/
18class IDictionarySource
19{
20public:
21 /// Returns an input stream with all the data available from this source.
22 virtual BlockInputStreamPtr loadAll() = 0;
23
24 /// Returns an input stream with updated data available from this source.
25 virtual BlockInputStreamPtr loadUpdatedAll() = 0;
26
27 /** Indicates whether this source supports "random access" loading of data
28 * loadId and loadIds can only be used if this function returns true.
29 */
30 virtual bool supportsSelectiveLoad() const = 0;
31
32 /** Returns an input stream with the data for a collection of identifiers.
33 * It must be guaranteed, that 'ids' array will live at least until all data will be read from returned stream.
34 */
35 virtual BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) = 0;
36
37 /** Returns an input stream with the data for a collection of composite keys.
38 * `requested_rows` contains indices of all rows containing unique keys.
39 * It must be guaranteed, that 'requested_rows' array will live at least until all data will be read from returned stream.
40 */
41 virtual BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) = 0;
42
43 /// indicates whether the source has been modified since last load* operation
44 virtual bool isModified() const = 0;
45
46 /// Returns true if update field is defined
47 virtual bool hasUpdateField() const = 0;
48
49 virtual DictionarySourcePtr clone() const = 0;
50
51 /// returns an informal string describing the source
52 virtual std::string toString() const = 0;
53
54 virtual ~IDictionarySource() = default;
55};
56
57}
58