2015-01-26 15:27:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IBlockInputStream.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
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,
|
|
|
|
* abstracts out the data source (file, MySQL, ClickHouse, external program, network request et cetera)
|
|
|
|
* from the presentation and memory layout (the dictionary itself).
|
|
|
|
*/
|
2015-01-26 15:27:51 +00:00
|
|
|
class IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2015-02-10 13:23:37 +00:00
|
|
|
/// returns an input stream with all the data available from this source
|
2015-01-26 15:27:51 +00:00
|
|
|
virtual BlockInputStreamPtr loadAll() = 0;
|
2015-02-10 13:23:37 +00:00
|
|
|
|
|
|
|
/** Indicates whether this source supports "random access" loading of data
|
|
|
|
* loadId and loadIds can only be used if this function returns true.
|
|
|
|
*/
|
|
|
|
virtual bool supportsSelectiveLoad() const = 0;
|
|
|
|
|
|
|
|
/// returns an input stream with the data for a collection of identifiers
|
2015-05-22 13:25:45 +00:00
|
|
|
virtual BlockInputStreamPtr loadIds(const std::vector<std::uint64_t> & ids) = 0;
|
2015-02-10 13:23:37 +00:00
|
|
|
|
2015-11-16 17:27:12 +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. */
|
|
|
|
virtual BlockInputStreamPtr loadKeys(
|
|
|
|
const ConstColumnPlainPtrs & key_columns, const std::vector<std::size_t> & requested_rows) = 0;
|
|
|
|
|
2015-02-10 13:23:37 +00:00
|
|
|
/// indicates whether the source has been modified since last load* operation
|
2015-01-29 15:47:21 +00:00
|
|
|
virtual bool isModified() const = 0;
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2015-01-30 13:43:16 +00:00
|
|
|
virtual DictionarySourcePtr clone() const = 0;
|
|
|
|
|
2015-03-25 10:09:33 +00:00
|
|
|
/// returns an informal string describing the source
|
|
|
|
virtual std::string toString() const = 0;
|
|
|
|
|
2015-01-26 15:27:51 +00:00
|
|
|
virtual ~IDictionarySource() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|