ClickHouse/dbms/Storages/StorageDictionary.h

75 lines
1.9 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 final : 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"; }
Pipes read(const Names & column_names,
const SelectQueryInfo & query_info,
2017-04-25 09:10:27 +00:00
const Context & context,
QueryProcessingStage::Enum processed_stage,
2020-02-20 14:40:58 +00:00
size_t max_block_size,
unsigned threads) 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 dictionary_name;
Poco::Logger * logger;
void checkNamesAndTypesCompatibleWithDictionary(const DictionaryStructure & dictionary_structure) const;
2017-04-28 18:33:31 +00:00
protected:
StorageDictionary(
2019-12-04 16:06:55 +00:00
const StorageID & table_id_,
const ColumnsDescription & columns_,
const Context & context,
bool attach,
const String & dictionary_name_);
2017-04-25 09:10:27 +00:00
};
}