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

@ -125,11 +125,11 @@ public:
template <size_t Bits, typename Signed, size_t Bits2, typename Signed2>
struct common_type<wide::integer<Bits, Signed>, wide::integer<Bits2, Signed2>>
{
using type = std::conditional_t < Bits == Bits2,
wide::integer<
Bits,
std::conditional_t<(std::is_same_v<Signed, Signed2> && std::is_same_v<Signed2, signed>), signed, unsigned>>,
std::conditional_t<Bits2<Bits, wide::integer<Bits, Signed>, wide::integer<Bits2, Signed2>>>;
using type = std::conditional_t<Bits == Bits2,
wide::integer<
Bits,
std::conditional_t<(std::is_same_v<Signed, Signed2> && std::is_same_v<Signed2, signed>), signed, unsigned>>,
std::conditional_t<Bits2<Bits, wide::integer<Bits, Signed>, wide::integer<Bits2, Signed2>>>;
};
template <size_t Bits, typename Signed, typename Arithmetic>

View File

@ -3,9 +3,11 @@
#include <Columns/ColumnsCommon.h>
#include <Common/PODArray.h>
#include <Common/ProfileEvents.h>
#include <Common/assert_cast.h>
#include <IO/WriteHelpers.h>
#include <Functions/IFunction.h>
namespace ProfileEvents
{
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);
}
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
{
if (size_ != filt.size())

View File

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