mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Remove IFunction::createResultColumn.
Given that the list of supported types is hardcoded in LLVMContext::Data::toNativeType, this method is redundant because LLVMPreparedFunction can create a ColumnVector itself.
This commit is contained in:
parent
6b526f784c
commit
3810173103
@ -1,4 +1,3 @@
|
||||
#include <Columns/ColumnVector.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <Functions/IFunction.h>
|
||||
@ -36,31 +35,6 @@ public:
|
||||
return static_cast<llvm::IRBuilder<>&>(builder).CreateFAdd(values[0], values[1]);
|
||||
return static_cast<llvm::IRBuilder<>&>(builder).CreateAdd(values[0], values[1]);
|
||||
}
|
||||
|
||||
IColumn::Ptr createResultColumn(const DataTypes & types, size_t size) const
|
||||
{
|
||||
if (types[0]->equals(DataTypeInt8{}))
|
||||
return ColumnVector<Int8>::create(size);
|
||||
if (types[0]->equals(DataTypeInt16{}))
|
||||
return ColumnVector<Int16>::create(size);
|
||||
if (types[0]->equals(DataTypeInt32{}))
|
||||
return ColumnVector<Int32>::create(size);
|
||||
if (types[0]->equals(DataTypeInt64{}))
|
||||
return ColumnVector<Int64>::create(size);
|
||||
if (types[0]->equals(DataTypeUInt8{}))
|
||||
return ColumnVector<UInt8>::create(size);
|
||||
if (types[0]->equals(DataTypeUInt16{}))
|
||||
return ColumnVector<UInt16>::create(size);
|
||||
if (types[0]->equals(DataTypeUInt32{}))
|
||||
return ColumnVector<UInt32>::create(size);
|
||||
if (types[0]->equals(DataTypeUInt64{}))
|
||||
return ColumnVector<UInt64>::create(size);
|
||||
if (types[0]->equals(DataTypeFloat32{}))
|
||||
return ColumnVector<Float32>::create(size);
|
||||
if (types[0]->equals(DataTypeFloat64{}))
|
||||
return ColumnVector<Float64>::create(size);
|
||||
throw Exception("invalid input type", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
//#endif
|
||||
|
||||
static FunctionPtr create(const Context &) { return std::make_shared<FunctionSomething>(); }
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <Columns/IColumn.h>
|
||||
#include <Core/Names.h>
|
||||
#include <Core/Field.h>
|
||||
#include <Core/Block.h>
|
||||
@ -91,12 +90,6 @@ public:
|
||||
virtual const DataTypes & getArgumentTypes() const = 0;
|
||||
virtual const DataTypePtr & getReturnType() const = 0;
|
||||
|
||||
/// Create an empty result column of a given size. Only called on JIT-compilable functions.
|
||||
virtual IColumn::Ptr createResultColumn(size_t /*size*/) const
|
||||
{
|
||||
throw Exception(getName() + " is not JIT-compilable", ErrorCodes::NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/// Do preparations and return executable.
|
||||
/// sample_block should contain data types of arguments and values of constants, if relevant.
|
||||
virtual PreparedFunctionPtr prepare(const Block & sample_block) const = 0;
|
||||
@ -318,11 +311,6 @@ public:
|
||||
throw Exception("getReturnType is not implemented for IFunction", ErrorCodes::NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
virtual IColumn::Ptr createResultColumn(const DataTypes & /*arguments*/, size_t /*size*/) const
|
||||
{
|
||||
throw Exception(getName() + " is not JIT-compilable", ErrorCodes::NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
protected:
|
||||
FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & /*arguments*/, const DataTypePtr & /*return_type*/) const final
|
||||
{
|
||||
@ -363,8 +351,6 @@ public:
|
||||
const DataTypes & getArgumentTypes() const override { return arguments; }
|
||||
const DataTypePtr & getReturnType() const override { return return_type; }
|
||||
|
||||
IColumn::Ptr createResultColumn(size_t size) const override { return function->createResultColumn(arguments, size); }
|
||||
|
||||
bool isCompilable() const override { return function->isCompilable(arguments); }
|
||||
|
||||
llvm::Value * compile(llvm::IRBuilderBase & builder, const ValuePlaceholders & values) const override { return function->compile(builder, arguments, values); }
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Interpreters/ExpressionJIT.h>
|
||||
|
||||
#include <llvm/IR/BasicBlock.h>
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Columns/ColumnVector.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Functions/IFunction.h>
|
||||
|
||||
#include <Interpreters/ExpressionActions.h>
|
||||
@ -7,6 +9,11 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
class LLVMContext
|
||||
{
|
||||
struct Data;
|
||||
@ -54,11 +61,38 @@ public:
|
||||
is_const[i] = column->isColumnConst();
|
||||
block_size = column->size();
|
||||
}
|
||||
auto col_res = parent->createResultColumn(block_size);
|
||||
if (!col_res->isColumnConst() && !col_res->isDummy() && block_size)
|
||||
auto col_res = createColumn(parent->getReturnType(), block_size);
|
||||
if (block_size)
|
||||
function(columns.data(), is_const.data(), const_cast<char *>(col_res->getDataAt(0).data), block_size);
|
||||
block.getByPosition(result).column = std::move(col_res);
|
||||
};
|
||||
|
||||
private:
|
||||
static IColumn::Ptr createColumn(const DataTypePtr & type, size_t size)
|
||||
{
|
||||
if (type->equals(DataTypeInt8{}))
|
||||
return ColumnVector<Int8>::create(size);
|
||||
if (type->equals(DataTypeInt16{}))
|
||||
return ColumnVector<Int16>::create(size);
|
||||
if (type->equals(DataTypeInt32{}))
|
||||
return ColumnVector<Int32>::create(size);
|
||||
if (type->equals(DataTypeInt64{}))
|
||||
return ColumnVector<Int64>::create(size);
|
||||
if (type->equals(DataTypeUInt8{}))
|
||||
return ColumnVector<UInt8>::create(size);
|
||||
if (type->equals(DataTypeUInt16{}))
|
||||
return ColumnVector<UInt16>::create(size);
|
||||
if (type->equals(DataTypeUInt32{}))
|
||||
return ColumnVector<UInt32>::create(size);
|
||||
if (type->equals(DataTypeUInt64{}))
|
||||
return ColumnVector<UInt64>::create(size);
|
||||
if (type->equals(DataTypeFloat32{}))
|
||||
return ColumnVector<Float32>::create(size);
|
||||
if (type->equals(DataTypeFloat64{}))
|
||||
return ColumnVector<Float64>::create(size);
|
||||
throw Exception("LLVMPreparedFunction::createColumn received an unsupported data type; check "
|
||||
"that the list is consistent with LLVMContext::Data::toNativeType", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
};
|
||||
|
||||
class LLVMFunction : public std::enable_shared_from_this<LLVMFunction>, public IFunctionBase
|
||||
@ -81,8 +115,6 @@ public:
|
||||
|
||||
PreparedFunctionPtr prepare(const Block &) const override { return std::make_shared<LLVMPreparedFunction>(context, shared_from_this()); }
|
||||
|
||||
IColumn::Ptr createResultColumn(size_t size) const override { return actions.back().function->createResultColumn(size); }
|
||||
|
||||
bool isDeterministic() override
|
||||
{
|
||||
for (const auto & action : actions)
|
||||
|
Loading…
Reference in New Issue
Block a user