ClickHouse/dbms/src/Storages/StorageDictionary.h

80 lines
2.1 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>
#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
{
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; }
std::string getDatabaseName() const override { return database_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,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
2017-04-25 09:10:27 +00:00
unsigned threads = 1) 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 database_name;
2017-04-25 09:10:27 +00:00
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 & database_name_,
const String & table_name_,
const ColumnsDescription & columns_,
const Context & context,
bool attach,
const String & dictionary_name_);
2017-04-25 09:10:27 +00:00
};
}