2015-01-26 15:27:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
#include <DataStreams/IBlockStream_fwd.h>
|
|
|
|
|
2015-01-26 15:27:51 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2019-01-19 23:27:52 +00:00
|
|
|
|
2015-01-26 15:27:51 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2015-01-30 13:43:16 +00:00
|
|
|
class IDictionarySource;
|
|
|
|
using DictionarySourcePtr = std::unique_ptr<IDictionarySource>;
|
|
|
|
|
2015-02-10 13:23:37 +00:00
|
|
|
/** Data-provider interface for external dictionaries,
|
2017-04-01 07:20:54 +00:00
|
|
|
* abstracts out the data source (file, MySQL, ClickHouse, external program, network request et cetera)
|
|
|
|
* from the presentation and memory layout (the dictionary itself).
|
2015-02-10 13:23:37 +00:00
|
|
|
*/
|
2015-01-26 15:27:51 +00:00
|
|
|
class IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2017-05-25 20:59:14 +00:00
|
|
|
/// Returns an input stream with all the data available from this source.
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual BlockInputStreamPtr loadAll() = 0;
|
2015-02-10 13:23:37 +00:00
|
|
|
|
2018-02-15 13:08:23 +00:00
|
|
|
/// Returns an input stream with updated data available from this source.
|
|
|
|
virtual BlockInputStreamPtr loadUpdatedAll() = 0;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/** Indicates whether this source supports "random access" loading of data
|
2017-05-25 20:59:14 +00:00
|
|
|
* loadId and loadIds can only be used if this function returns true.
|
|
|
|
*/
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual bool supportsSelectiveLoad() const = 0;
|
2015-02-10 13:23:37 +00:00
|
|
|
|
2017-05-25 20:59:14 +00:00
|
|
|
/** Returns an input stream with the data for a collection of identifiers.
|
2017-05-25 21:00:04 +00:00
|
|
|
* It must be guaranteed, that 'ids' array will live at least until all data will be read from returned stream.
|
2017-05-25 20:59:14 +00:00
|
|
|
*/
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) = 0;
|
2015-02-10 13:23:37 +00:00
|
|
|
|
2017-05-25 20:59:14 +00:00
|
|
|
/** Returns an input stream with the data for a collection of composite keys.
|
|
|
|
* `requested_rows` contains indices of all rows containing unique keys.
|
2017-05-25 21:00:04 +00:00
|
|
|
* It must be guaranteed, that 'requested_rows' array will live at least until all data will be read from returned stream.
|
2017-05-25 20:59:14 +00:00
|
|
|
*/
|
2018-12-10 15:25:45 +00:00
|
|
|
virtual BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) = 0;
|
2015-11-16 17:27:12 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// indicates whether the source has been modified since last load* operation
|
|
|
|
virtual bool isModified() const = 0;
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2018-01-15 12:44:39 +00:00
|
|
|
/// Returns true if update field is defined
|
|
|
|
virtual bool hasUpdateField() const = 0;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual DictionarySourcePtr clone() const = 0;
|
2015-01-30 13:43:16 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// returns an informal string describing the source
|
|
|
|
virtual std::string toString() const = 0;
|
2015-03-25 10:09:33 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual ~IDictionarySource() = default;
|
2015-01-26 15:27:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|