2017-04-27 17:16:24 +00:00
|
|
|
#pragma once
|
2018-08-24 05:20:18 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <memory>
|
2017-04-28 18:33:31 +00:00
|
|
|
#include <Columns/IColumn.h>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Core/Names.h>
|
2021-10-21 14:17:53 +00:00
|
|
|
#include <Processors/Sources/SourceWithProgress.h>
|
2021-08-11 12:32:01 +00:00
|
|
|
#include <Dictionaries/DictionaryStructure.h>
|
|
|
|
#include <Dictionaries/IDictionary.h>
|
2017-04-27 17:16:24 +00:00
|
|
|
|
2021-07-17 18:06:46 +00:00
|
|
|
|
2017-05-26 16:08:56 +00:00
|
|
|
namespace DB
|
2017-04-28 18:33:31 +00:00
|
|
|
{
|
2018-06-05 19:46:49 +00:00
|
|
|
|
2022-01-16 12:22:22 +00:00
|
|
|
class DictionarySource;
|
|
|
|
|
|
|
|
class DictionarySourceCoordinator final : public shared_ptr_helper<DictionarySourceCoordinator>, public std::enable_shared_from_this<DictionarySourceCoordinator>
|
2017-04-27 17:16:24 +00:00
|
|
|
{
|
2022-01-16 12:22:22 +00:00
|
|
|
friend struct shared_ptr_helper<DictionarySourceCoordinator>;
|
|
|
|
|
2017-04-27 17:16:24 +00:00
|
|
|
public:
|
2021-10-21 14:17:53 +00:00
|
|
|
|
2022-01-16 12:22:22 +00:00
|
|
|
Pipe read(size_t num_streams);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
explicit DictionarySourceCoordinator(
|
|
|
|
std::shared_ptr<const IDictionary> dictionary_,
|
2018-12-10 15:25:45 +00:00
|
|
|
const Names & column_names,
|
2021-10-21 14:17:53 +00:00
|
|
|
ColumnsWithTypeAndName && key_columns_with_type_,
|
|
|
|
size_t max_block_size_)
|
|
|
|
: dictionary(std::move(dictionary_))
|
|
|
|
, key_columns_with_type(std::move(key_columns_with_type_))
|
|
|
|
, max_block_size(max_block_size_)
|
|
|
|
{
|
|
|
|
initialize(column_names);
|
|
|
|
}
|
2017-06-05 09:02:05 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
explicit DictionarySourceCoordinator(
|
|
|
|
std::shared_ptr<const IDictionary> dictionary_,
|
|
|
|
const Names & column_names,
|
|
|
|
ColumnsWithTypeAndName && key_columns_with_type_,
|
|
|
|
ColumnsWithTypeAndName && data_columns_with_type_,
|
|
|
|
size_t max_block_size_)
|
|
|
|
: dictionary(std::move(dictionary_))
|
|
|
|
, key_columns_with_type(std::move(key_columns_with_type_))
|
|
|
|
, data_columns_with_type(std::move(data_columns_with_type_))
|
|
|
|
, max_block_size(max_block_size_)
|
|
|
|
{
|
|
|
|
initialize(column_names);
|
|
|
|
}
|
2017-05-04 18:14:23 +00:00
|
|
|
|
2022-01-16 12:22:22 +00:00
|
|
|
friend class DictionarySource;
|
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
bool getKeyColumnsNextRangeToRead(ColumnsWithTypeAndName & key_columns, ColumnsWithTypeAndName & data_columns);
|
2017-05-04 18:14:23 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
const Block & getHeader() const { return header; }
|
2018-08-24 05:37:06 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
const std::vector<std::string> & getAttributesNamesToRead() const { return attributes_names_to_read; }
|
2018-03-07 14:29:00 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
const std::vector<DataTypePtr> & getAttributesTypesToRead() const { return attributes_types_to_read; }
|
|
|
|
|
|
|
|
const std::vector<ColumnPtr> & getAttributesDefaultValuesColumns() const { return attributes_default_values_columns; }
|
|
|
|
|
|
|
|
const std::shared_ptr<const IDictionary> & getDictionary() const { return dictionary; }
|
2018-03-07 14:29:00 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
void initialize(const Names & column_names);
|
|
|
|
|
|
|
|
static ColumnsWithTypeAndName cutColumns(const ColumnsWithTypeAndName & columns_with_type, size_t start, size_t length);
|
|
|
|
|
|
|
|
std::shared_ptr<const IDictionary> dictionary;
|
2021-10-21 21:22:32 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
ColumnsWithTypeAndName key_columns_with_type;
|
|
|
|
ColumnsWithTypeAndName data_columns_with_type;
|
2021-10-21 21:22:32 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
Block header;
|
2021-10-21 21:22:32 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
std::vector<std::string> attributes_names_to_read;
|
|
|
|
std::vector<DataTypePtr> attributes_types_to_read;
|
|
|
|
std::vector<ColumnPtr> attributes_default_values_columns;
|
2021-10-21 21:22:32 +00:00
|
|
|
|
2021-10-21 14:17:53 +00:00
|
|
|
const size_t max_block_size;
|
|
|
|
std::atomic<size_t> parallel_read_block_index = 0;
|
2017-04-27 17:16:24 +00:00
|
|
|
};
|
|
|
|
|
2017-05-26 16:08:56 +00:00
|
|
|
}
|