ClickHouse/dbms/src/Storages/StorageDictionary.h

74 lines
2.0 KiB
C++
Raw Normal View History

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>
2017-04-25 09:10:27 +00:00
#include <common/MultiVersion.h>
#include <ext/shared_ptr_helper.h>
#include <IO/WriteBufferFromString.h>
#include <IO/Operators.h>
2017-04-25 09:10:27 +00:00
namespace Poco
{
class Logger;
}
2017-04-25 09:10:27 +00:00
namespace DB
{
struct DictionaryStructure;
struct IDictionaryBase;
class ExternalDictionaries;
2017-04-25 09:10:27 +00:00
class StorageDictionary : public ext::shared_ptr_helper<StorageDictionary>, public IStorage
2017-04-25 09:10:27 +00:00
{
public:
std::string getName() const override { return "Dictionary"; }
std::string getTableName() const override { return table_name; }
BlockInputStreams read(const Names & column_names,
const SelectQueryInfo & query_info,
2017-04-25 09:10:27 +00:00
const Context & context,
QueryProcessingStage::Enum processed_stage,
2017-04-25 09:10:27 +00:00
size_t max_block_size = DEFAULT_BLOCK_SIZE,
unsigned threads = 1) override;
void drop() override {}
static NamesAndTypesList getNamesAndTypes(const DictionaryStructure & dictionary_structure);
2017-04-25 09:10:27 +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:
using Ptr = MultiVersion<IDictionaryBase>::Version;
2017-04-25 09:10:27 +00:00
String table_name;
String dictionary_name;
Poco::Logger * logger;
void checkNamesAndTypesCompatibleWithDictionary(const DictionaryStructure & dictionary_structure) const;
2017-04-28 18:33:31 +00:00
protected:
StorageDictionary(const String & table_name_,
const ColumnsDescription & columns_,
const DictionaryStructure & dictionary_structure_,
const String & dictionary_name_);
2017-04-25 09:10:27 +00:00
};
}