Attempt to make compositions with COWPtr more convenient

This commit is contained in:
Alexey Milovidov 2019-03-25 20:56:18 +03:00
parent fb19cf1eec
commit 67b6a8966b
2 changed files with 18 additions and 6 deletions

View File

@ -67,10 +67,10 @@ struct UniqVariadicHash<false, true>
{
UInt64 hash;
const Columns & tuple_columns = static_cast<const ColumnTuple *>(columns[0])->getColumns();
const auto & tuple_columns = static_cast<const ColumnTuple *>(columns[0])->getColumns();
const ColumnPtr * column = tuple_columns.data();
const ColumnPtr * columns_end = column + num_args;
const auto * column = tuple_columns.data();
const auto * columns_end = column + num_args;
{
StringRef value = column->get()->getDataAt(row_num);
@ -116,10 +116,10 @@ struct UniqVariadicHash<true, true>
{
static inline UInt128 apply(size_t num_args, const IColumn ** columns, size_t row_num)
{
const Columns & tuple_columns = static_cast<const ColumnTuple *>(columns[0])->getColumns();
const auto & tuple_columns = static_cast<const ColumnTuple *>(columns[0])->getColumns();
const ColumnPtr * column = tuple_columns.data();
const ColumnPtr * columns_end = column + num_args;
const auto * column = tuple_columns.data();
const auto * columns_end = column + num_args;
SipHash hash;

View File

@ -58,6 +58,18 @@ ColumnTuple::Ptr ColumnTuple::create(const Columns & columns)
return column_tuple;
}
ColumnTuple::Ptr ColumnTuple::create(const TupleColumns & columns)
{
for (const auto & column : columns)
if (column->isColumnConst())
throw Exception{"ColumnTuple cannot have ColumnConst as its element", ErrorCodes::ILLEGAL_COLUMN};
auto column_tuple = ColumnTuple::create(MutableColumns());
column_tuple->columns = columns;
return column_tuple;
}
MutableColumnPtr ColumnTuple::cloneEmpty() const
{
const size_t tuple_size = columns.size();