提交 f70e38b9 编写于 作者: N Nikolai Kochetov

fixed ColumnVisitor; added LogColumnTypesBlockInputStream

上级 4c3c1d75
#pragma once
#include <Columns/IColumn.h>
#include <Columns/ColumnVisitor.h>
namespace DB
{
template <typename Derived>
class ColumnImpl : public IColumn
{
public:
void accept(ColumnVisitor & visitor) override { visitor.visit(*static_cast<Derived *>(this)); }
void accept(ColumnVisitor & visitor) const override { visitor.visit(*static_cast<const Derived *>(this)); }
};
}
#pragma once
#include <Columns/Columns.h>
#include <string>
namespace DB
{
template <typename ... Types>
class Visitor;
template <>
class Visitor<>
{
public:
virtual ~Visitor() {}
};
template <typename Type>
class Visitor<Type> : public Visitor<>
{
public:
virtual void visit(const Type &) = 0;
virtual void visit(Type &) = 0;
};
template <typename Type, typename ... Types>
class Visitor<Type, Types ...> : public Visitor<Types ...>
{
public:
using Visitor<Types ...>::visit;
virtual void visit(const Type &) = 0;
virtual void visit(Type &) = 0;
};
template <typename Derived, typename VisitorBase, typename ... Types>
class VisitorImplHelper;
template <typename Derived, typename VisitorBase>
class VisitorImplHelper<Derived, VisitorBase> : public VisitorBase {};
template <typename Derived, typename VisitorBase, typename Type, typename ... Types>
class VisitorImplHelper<Derived, VisitorBase, Type, Types ...> : public VisitorImplHelper<Derived, VisitorBase, Types ...>
{
public:
virtual void visit(const Type & value) override { static_cast<Derived *>(this)->visitImpl(value); }
virtual void visit(Type & value) override { static_cast<Derived *>(this)->visitImpl(value); }
protected:
template <typename T>
void visitImpl(const Type &) { throw Exception(std::string("visitImpl(const ") + typeid(T).name() + " &) is not implemented for class" + typeid(Derived).name()); }
template <typename T>
void visitImpl(Type &) { throw Exception(std::string("visitImpl(") + typeid(T).name() + " &) is not implemented for class" + typeid(Derived).name()); }
};
class ColumnVisitor : public DECLARE_WITH_COLUMNS_LIST(Visitor) {};
template <class Derived>
class ColumnVisitorImpl : public VisitorImplHelper<Derived, ColumnVisitor, COLUMN_LIST> {};
}
#pragma once
#include <Core/Types.h>
#include <Common/UInt128.h>
namespace DB
{
template <typename T>
class ColumnVector;
template <typename T>
class ColumnConst;
#define GET_COLUMN_VECTOR_TYPE(TYPE, M) M(ColumnVector< TYPE >)
#define COLUMN_VECTO_TYPE_LIST(M) APPLY_FOR_NUMBERS(GET_COLUMN_VECTOR_TYPE, M)
#define APPLY_FOR_COLUMN_VECTOR(M) COLUMN_VECTO_TYPE_LIST(M) M(ColumnVector<UInt128>)
#define GET_COLUMN_CONST_TYPE(TYPE, M) M(ColumnConst< TYPE >)
#define COLUMN_CONST_TYPE_LIST(M) APPLY_FOR_NUMBERS(GET_COLUMN_CONST_TYPE, M)
#define APPLY_FOR_COLUMN_CONST(M) COLUMN_CONST_TYPE_LIST(M) M(ColumnConst<UInt128>)
#define APPLY_FOR_NOT_TEMPLATE_COLUMNS(M) \
M(ColumnString) \
M(ColumnFixedString) \
M(ColumnAggregateFunction) \
M(ColumnArray) \
M(ColumnConstAggregateFunction) \
M(ColumnExpression) \
M(ColumnNullable) \
M(ColumnSet) \
M(ColumnTuple)
#define APPLY_FOR_COLUMNS(M) \
APPLY_FOR_COLUMN_VECTOR(M) \
APPLY_FOR_COLUMN_CONST(M) \
APPLY_FOR_NOT_TEMPLATE_COLUMNS(M)
#define DECLARE_COLUMNS(COLUMN) \
class COLUMN ;
APPLY_FOR_NOT_TEMPLATE_COLUMNS(DECLARE_COLUMNS);
template <typename T>
class ColumnConst;
template <typename T>
class ColumnVector;
#define MAKE_COLUMNS_LIST(COLUMN) COLUMN,
#define COLUMN_LIST APPLY_FOR_COLUMNS(MAKE_COLUMNS_LIST) IColumn
class IColumn;
#define DECLARE_WITH_COLUMNS_LIST(CLASS) CLASS < COLUMN_LIST >
}
......@@ -252,8 +252,8 @@ public:
virtual size_t allocatedBytes() const = 0;
/// For visitors
void accept(ColumnVisitor &) { throw Exception("Accept not implemented"); }
void accept(ColumnVisitor &) const { throw Exception("Accept not implemented"); }
virtual void accept(ColumnVisitor &) { throw Exception("Accept not implemented"); }
virtual void accept(ColumnVisitor &) const { throw Exception("Accept not implemented"); }
virtual ~IColumn() {}
......
#pragma once
#include <DataStreams/IProfilingBlockInputStream.h>
#include <common/logger_useful.h>
#include <Columns/ColumnVisitor.h>
#include <Columns/ColumnString.h>
namespace DB
{
/** Removes the specified columns from the block.
*/
class LogColumnTypesBlockInputStream : public IProfilingBlockInputStream, public ColumnVisitorImpl<LogColumnTypesBlockInputStream>
{
public:
LogColumnTypesBlockInputStream(
BlockInputStreamPtr input_) : log(&Poco::Logger::get("LogColumnTypesBlockInputStream"))
{
children.push_back(input_);
}
String getName() const override { return "LogColumnTypes"; }
String getID() const override
{
std::stringstream res;
res << "LogColumnTypes";
return res.str();
}
protected:
Block readImpl() override
{
Block res = children.back()->read();
for (const auto & it : res.getColumns())
it.column->accept(*this);
return res;
}
public:
template <typename T>
void visitImpl(T & column) { print_log(column); }
template <typename T>
void visitImpl(const T & column) { print_log(column); }
private:
void print_log(const ColumnString & column)
{
LOG_TRACE(log, typeid(ColumnString).name());
}
void print_log(ColumnString & column)
{
LOG_TRACE(log, typeid(ColumnString).name());
}
template <typename T>
void print_log(T & column)
{
LOG_TRACE(log, " other type");
}
template <typename T>
void print_log(const T & column)
{
LOG_TRACE(log, " other type");
}
Names columns_to_remove;
Poco::Logger * log;
};
}
......@@ -45,6 +45,7 @@
#include <Common/Collator.h>
#include <Common/typeid_cast.h>
#include <DataStreams/LogColumnTypesBlockInputStream.h>
namespace ProfileEvents
{
......@@ -353,7 +354,6 @@ Block InterpreterSelectQuery::getSampleBlock(const ASTPtr & query_ptr_, const Co
return InterpreterSelectQuery(OnlyAnalyzeTag(), query_ptr_, context_).getSampleBlock();
}
#incldue <DataStreams/LogColumnTypesBlockInputStream.h>
BlockIO InterpreterSelectQuery::execute()
{
(void) executeWithoutUnion();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册