2017-04-25 09:10:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/IStorage.h>
|
2017-07-24 12:58:01 +00:00
|
|
|
#include <Core/Defines.h>
|
2019-01-11 19:12:36 +00:00
|
|
|
#include <Common/MultiVersion.h>
|
2017-06-23 15:55:45 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2018-03-13 13:28:32 +00:00
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
#include <IO/Operators.h>
|
2017-04-25 09:10:27 +00:00
|
|
|
|
|
|
|
|
2017-06-23 15:55:45 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
class Logger;
|
|
|
|
}
|
2017-04-25 09:10:27 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-06-26 08:54:58 +00:00
|
|
|
struct DictionaryStructure;
|
|
|
|
struct IDictionaryBase;
|
2017-06-23 15:55:45 +00:00
|
|
|
class ExternalDictionaries;
|
2017-04-25 09:10:27 +00:00
|
|
|
|
2017-12-30 00:36:06 +00:00
|
|
|
class StorageDictionary : public ext::shared_ptr_helper<StorageDictionary>, public IStorage
|
2017-04-25 09:10:27 +00:00
|
|
|
{
|
2019-08-26 19:07:29 +00:00
|
|
|
friend struct ext::shared_ptr_helper<StorageDictionary>;
|
2017-04-25 09:10:27 +00:00
|
|
|
public:
|
|
|
|
std::string getName() const override { return "Dictionary"; }
|
|
|
|
std::string getTableName() const override { return table_name; }
|
2019-07-09 15:40:21 +00:00
|
|
|
std::string getDatabaseName() const override { return database_name; }
|
|
|
|
|
2017-06-23 15:55:45 +00:00
|
|
|
BlockInputStreams read(const Names & column_names,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-25 09:10:27 +00:00
|
|
|
const Context & context,
|
2018-04-19 14:47:09 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
2019-02-18 23:38:44 +00:00
|
|
|
size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
2017-04-25 09:10:27 +00:00
|
|
|
unsigned threads = 1) override;
|
|
|
|
|
2017-12-25 21:57:29 +00:00
|
|
|
static NamesAndTypesList getNamesAndTypes(const DictionaryStructure & dictionary_structure);
|
2017-04-25 09:10:27 +00:00
|
|
|
|
2018-03-13 13:28:32 +00:00
|
|
|
template <typename ForwardIterator>
|
|
|
|
static std::string generateNamesAndTypesDescription(ForwardIterator begin, ForwardIterator end)
|
|
|
|
{
|
|
|
|
std::string description;
|
|
|
|
{
|
|
|
|
WriteBufferFromString buffer(description);
|
|
|
|
bool first = true;
|
|
|
|
for (; begin != end; ++begin)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
buffer << ", ";
|
|
|
|
first = false;
|
|
|
|
|
|
|
|
buffer << begin->name << ' ' << begin->type->getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
2017-04-25 09:10:27 +00:00
|
|
|
private:
|
2017-05-15 13:58:40 +00:00
|
|
|
using Ptr = MultiVersion<IDictionaryBase>::Version;
|
|
|
|
|
2017-04-25 09:10:27 +00:00
|
|
|
String table_name;
|
2019-07-09 15:40:21 +00:00
|
|
|
String database_name;
|
2017-04-25 09:10:27 +00:00
|
|
|
String dictionary_name;
|
|
|
|
Poco::Logger * logger;
|
|
|
|
|
2017-12-25 21:10:46 +00:00
|
|
|
void checkNamesAndTypesCompatibleWithDictionary(const DictionaryStructure & dictionary_structure) const;
|
2017-04-28 18:33:31 +00:00
|
|
|
|
2017-11-03 21:50:22 +00:00
|
|
|
protected:
|
2019-07-09 15:40:21 +00:00
|
|
|
StorageDictionary(
|
|
|
|
const String & database_name_,
|
|
|
|
const String & table_name_,
|
2018-03-06 20:18:34 +00:00
|
|
|
const ColumnsDescription & columns_,
|
2019-02-04 19:45:22 +00:00
|
|
|
const Context & context,
|
|
|
|
bool attach,
|
2017-11-03 21:50:22 +00:00
|
|
|
const String & dictionary_name_);
|
2017-04-25 09:10:27 +00:00
|
|
|
};
|
2017-11-03 21:50:22 +00:00
|
|
|
|
2017-05-15 13:58:40 +00:00
|
|
|
}
|