Allow insertFrom for ColumnFunction

This commit is contained in:
Alexey Milovidov 2022-01-16 06:18:35 +03:00
parent d4f5028f26
commit 7848ea7d60
3 changed files with 37 additions and 9 deletions

View File

@ -3,9 +3,11 @@
#include <Columns/ColumnsCommon.h> #include <Columns/ColumnsCommon.h>
#include <Common/PODArray.h> #include <Common/PODArray.h>
#include <Common/ProfileEvents.h> #include <Common/ProfileEvents.h>
#include <Common/assert_cast.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
#include <Functions/IFunction.h> #include <Functions/IFunction.h>
namespace ProfileEvents namespace ProfileEvents
{ {
extern const Event FunctionExecute; extern const Event FunctionExecute;
@ -59,6 +61,34 @@ ColumnPtr ColumnFunction::cut(size_t start, size_t length) const
return ColumnFunction::create(length, function, capture, is_short_circuit_argument, is_function_compiled); return ColumnFunction::create(length, function, capture, is_short_circuit_argument, is_function_compiled);
} }
void ColumnFunction::insertFrom(const IColumn & src, size_t n)
{
const ColumnFunction & src_func = assert_cast<const ColumnFunction &>(src);
for (size_t i = 0, size = captured_columns.size(); i < size; ++i)
{
auto mut_column = IColumn::mutate(std::move(captured_columns[i].column));
mut_column->insertFrom(*src_func.captured_columns[i].column, n);
captured_columns[i].column = std::move(mut_column);
}
++size_;
}
void ColumnFunction::insertRangeFrom(const IColumn & src, size_t start, size_t length)
{
const ColumnFunction & src_func = assert_cast<const ColumnFunction &>(src);
for (size_t i = 0, size = captured_columns.size(); i < size; ++i)
{
auto mut_column = IColumn::mutate(std::move(captured_columns[i].column));
mut_column->insertRangeFrom(*src_func.captured_columns[i].column, start, length);
captured_columns[i].column = std::move(mut_column);
}
size_ += length;
}
ColumnPtr ColumnFunction::filter(const Filter & filt, ssize_t result_size_hint) const ColumnPtr ColumnFunction::filter(const Filter & filt, ssize_t result_size_hint) const
{ {
if (size_ != filt.size()) if (size_ != filt.size())

View File

@ -88,10 +88,8 @@ public:
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED); throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
} }
void insertRangeFrom(const IColumn &, size_t, size_t) override void insertFrom(const IColumn & src, size_t n) override;
{ void insertRangeFrom(const IColumn &, size_t start, size_t length) override;
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
void insertData(const char *, size_t) override void insertData(const char *, size_t) override
{ {