mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Better semantic of sharing columns: development [#CLICKHOUSE-2].
This commit is contained in:
parent
bce801a663
commit
ddfb1fab9e
@ -135,7 +135,7 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto dst = ColumnVector<Float64>::create();
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
auto & dst_data = dst->getData();
|
||||
dst_data.resize(size);
|
||||
Float64 vals[instrs.size()];
|
||||
@ -273,7 +273,7 @@ private:
|
||||
const auto col_vec_x = static_cast<const ColumnVector<Float64> *> (col_x);
|
||||
const auto col_vec_y = static_cast<const ColumnVector<Float64> *> (col_y);
|
||||
|
||||
const auto dst = ColumnVector<UInt8>::create();
|
||||
auto dst = ColumnVector<UInt8>::create();
|
||||
auto & dst_data = dst->getData();
|
||||
dst_data.resize(size);
|
||||
|
||||
|
@ -557,8 +557,8 @@ private:
|
||||
size_t tuple_size = tuple_columns.size();
|
||||
for (size_t i = 0; i < tuple_size; ++i)
|
||||
{
|
||||
ColumnConst tmp(tuple_columns[i], column->size());
|
||||
executeForArgument(tuple_types[i].get(), &tmp, vec_to, is_first);
|
||||
auto tmp = ColumnConst::create(tuple_columns[i], column->size());
|
||||
executeForArgument(tuple_types[i].get(), tmp.get(), vec_to, is_first);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -762,7 +762,7 @@ private:
|
||||
if (const auto col_from = checkAndGetColumn<ColumnString>(col_untyped))
|
||||
{
|
||||
const auto size = col_from->size();
|
||||
const auto col_to = ColumnUInt64::create(size);
|
||||
auto col_to = ColumnUInt64::create(size);
|
||||
|
||||
const auto & chars = col_from->getChars();
|
||||
const auto & offsets = col_from->getOffsets();
|
||||
@ -796,7 +796,7 @@ private:
|
||||
if (const auto col_from = checkAndGetColumn<ColumnString>(col_untyped))
|
||||
{
|
||||
const auto size = col_from->size();
|
||||
const auto col_to = ColumnUInt64::create(size);
|
||||
auto col_to = ColumnUInt64::create(size);
|
||||
|
||||
const auto & chars = col_from->getChars();
|
||||
const auto & offsets = col_from->getOffsets();
|
||||
|
@ -145,7 +145,7 @@ struct ArrayCountImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
else
|
||||
return DataTypeUInt32().createColumnConst(array.size(), UInt64(0));
|
||||
@ -168,7 +168,7 @@ struct ArrayCountImpl
|
||||
out_counts[i] = count;
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
};
|
||||
|
||||
@ -207,7 +207,7 @@ struct ArrayExistsImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
else
|
||||
return DataTypeUInt8().createColumnConst(array.size(), UInt64(0));
|
||||
@ -234,7 +234,7 @@ struct ArrayExistsImpl
|
||||
out_exists[i] = exists;
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
};
|
||||
|
||||
@ -275,7 +275,7 @@ struct ArrayAllImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ struct ArrayAllImpl
|
||||
out_all[i] = all;
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
};
|
||||
|
||||
@ -346,7 +346,6 @@ struct ArraySumImpl
|
||||
const Element x = column_const->template getValue<Element>();
|
||||
|
||||
auto res_column = ColumnVector<Result>::create(offsets.size());
|
||||
res_ptr = res_column;
|
||||
typename ColumnVector<Result>::Container & res = res_column->getData();
|
||||
|
||||
size_t pos = 0;
|
||||
@ -356,12 +355,12 @@ struct ArraySumImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
res_ptr = std::move(res_column);
|
||||
return true;
|
||||
}
|
||||
|
||||
const typename ColumnVector<Element>::Container & data = column->getData();
|
||||
auto res_column = ColumnVector<Result>::create(offsets.size());
|
||||
res_ptr = res_column;
|
||||
typename ColumnVector<Result>::Container & res = res_column->getData();
|
||||
|
||||
size_t pos = 0;
|
||||
@ -375,6 +374,7 @@ struct ArraySumImpl
|
||||
res[i] = s;
|
||||
}
|
||||
|
||||
res_ptr = std::move(res_column);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ struct ArrayFirstImpl
|
||||
{
|
||||
const auto & offsets = array.getOffsets();
|
||||
const auto & data = array.getData();
|
||||
ColumnPtr out{data.cloneEmpty()};
|
||||
auto out = data.cloneEmpty();
|
||||
|
||||
size_t pos{};
|
||||
for (size_t i = 0; i < offsets.size(); ++i)
|
||||
@ -438,11 +438,11 @@ struct ArrayFirstImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
return out;
|
||||
return std::move(out);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColumnPtr out{array.getData().cloneEmpty()};
|
||||
auto out = array.getData().cloneEmpty();
|
||||
out->insertDefault();
|
||||
return out->replicate(IColumn::Offsets(1, array.size()));
|
||||
}
|
||||
@ -451,7 +451,7 @@ struct ArrayFirstImpl
|
||||
const auto & filter = column_filter->getData();
|
||||
const auto & offsets = array.getOffsets();
|
||||
const auto & data = array.getData();
|
||||
ColumnPtr out{data.cloneEmpty()};
|
||||
auto out = data.cloneEmpty();
|
||||
|
||||
size_t pos{};
|
||||
for (size_t i = 0; i < offsets.size(); ++i)
|
||||
@ -472,7 +472,7 @@ struct ArrayFirstImpl
|
||||
out->insertDefault();
|
||||
}
|
||||
|
||||
return out;
|
||||
return std::move(out);
|
||||
}
|
||||
};
|
||||
|
||||
@ -511,7 +511,7 @@ struct ArrayFirstIndexImpl
|
||||
pos = offsets[i];
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
else
|
||||
return DataTypeUInt32().createColumnConst(array.size(), UInt64(0));
|
||||
@ -539,7 +539,7 @@ struct ArrayFirstIndexImpl
|
||||
out_index[i] = index;
|
||||
}
|
||||
|
||||
return out_column;
|
||||
return std::move(out_column);
|
||||
}
|
||||
};
|
||||
|
||||
@ -798,7 +798,7 @@ public:
|
||||
throw Exception("First argument for function " + getName() + " must be an expression.",
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
ColumnExpression * column_expression = typeid_cast<ColumnExpression *>(column_with_type_and_name.column.get());
|
||||
const ColumnExpression * column_expression = typeid_cast<const ColumnExpression *>(column_with_type_and_name.column.get());
|
||||
|
||||
ColumnPtr offsets_column;
|
||||
|
||||
@ -870,7 +870,7 @@ public:
|
||||
ColumnWithTypeAndName replicated_column = block.getByPosition(prerequisites[prerequisite_index]);
|
||||
|
||||
replicated_column.name = name;
|
||||
replicated_column.column = typeid_cast<ColumnArray &>(*replicated_column.column).getDataPtr();
|
||||
replicated_column.column = typeid_cast<const ColumnArray &>(*replicated_column.column).getDataPtr();
|
||||
replicated_column.type = typeid_cast<const DataTypeArray &>(*replicated_column.type).getNestedType(),
|
||||
temp_block.insert(std::move(replicated_column));
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
||||
{
|
||||
if (const auto col = checkAndGetColumn<ColumnVector<FieldType>>(arg))
|
||||
{
|
||||
const auto dst = ColumnVector<Float64>::create();
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
|
||||
const auto & src_data = col->getData();
|
||||
const auto src_size = src_data.size();
|
||||
@ -221,7 +221,7 @@ private:
|
||||
{
|
||||
if (const auto right_arg_typed = checkAndGetColumn<ColumnVector<RightType>>(right_arg))
|
||||
{
|
||||
const auto dst = ColumnVector<Float64>::create();
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
|
||||
LeftType left_src_data[Impl::rows_per_iteration];
|
||||
std::fill(std::begin(left_src_data), std::end(left_src_data), left_arg->template getValue<LeftType>());
|
||||
@ -261,7 +261,7 @@ private:
|
||||
{
|
||||
if (const auto right_arg_typed = checkAndGetColumn<ColumnVector<RightType>>(right_arg))
|
||||
{
|
||||
const auto dst = ColumnVector<Float64>::create();
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
|
||||
const auto & left_src_data = left_arg->getData();
|
||||
const auto & right_src_data = right_arg_typed->getData();
|
||||
@ -295,7 +295,7 @@ private:
|
||||
}
|
||||
else if (const auto right_arg_typed = checkAndGetColumnConst<ColumnVector<RightType>>(right_arg))
|
||||
{
|
||||
const auto dst = ColumnVector<Float64>::create();
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
|
||||
const auto & left_src_data = left_arg->getData();
|
||||
RightType right_src_data[Impl::rows_per_iteration];
|
||||
|
@ -593,7 +593,7 @@ public:
|
||||
|
||||
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
||||
{
|
||||
IColumn * col = block.getByPosition(arguments[0]).column.get();
|
||||
const IColumn * col = block.getByPosition(arguments[0]).column.get();
|
||||
double seconds;
|
||||
size_t size = col->size();
|
||||
|
||||
@ -1667,22 +1667,25 @@ public:
|
||||
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
||||
{
|
||||
auto & src = block.getByPosition(arguments.at(0));
|
||||
auto & res = block.getByPosition(result);
|
||||
const auto & res_type = block.getByPosition(result).type;
|
||||
|
||||
/// When column is constant, its difference is zero.
|
||||
if (src.column->isColumnConst())
|
||||
{
|
||||
res.column = res.type->createColumnConst(block.rows(), res.type->getDefault());
|
||||
block.getByPosition(result).column = res_type->createColumnConst(block.rows(), res_type->getDefault());
|
||||
return;
|
||||
}
|
||||
|
||||
res.column = res.type->createColumn();
|
||||
auto res_column = res_type->createColumn();
|
||||
|
||||
dispatchForSourceType(*src.type, [&](auto field_type_tag) {
|
||||
dispatchForSourceType(*src.type, [&](auto field_type_tag)
|
||||
{
|
||||
using SrcFieldType = decltype(field_type_tag);
|
||||
process(static_cast<const ColumnVector<SrcFieldType> &>(*src.column).getData(),
|
||||
static_cast<ColumnVector<DstFieldType<SrcFieldType>> &>(*res.column).getData());
|
||||
static_cast<ColumnVector<DstFieldType<SrcFieldType>> &>(*res_column).getData());
|
||||
});
|
||||
|
||||
block.getByPosition(result).column = std::move(res_column);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1723,8 +1726,8 @@ public:
|
||||
|
||||
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override
|
||||
{
|
||||
ColumnAggregateFunction * column_with_states
|
||||
= typeid_cast<ColumnAggregateFunction *>(&*block.getByPosition(arguments.at(0)).column);
|
||||
const ColumnAggregateFunction * column_with_states
|
||||
= typeid_cast<const ColumnAggregateFunction *>(&*block.getByPosition(arguments.at(0)).column);
|
||||
if (!column_with_states)
|
||||
throw Exception("Illegal column " + block.getByPosition(arguments.at(0)).column->getName()
|
||||
+ " of first argument of function "
|
||||
|
@ -216,7 +216,7 @@ void FunctionCoalesce::executeImpl(Block & block, const ColumnNumbers & argument
|
||||
|
||||
FunctionMultiIf{context}.execute(temp_block, multi_if_args, result);
|
||||
|
||||
auto res = std::move(temp_block.getByPosition(result).column)->mutate();
|
||||
ColumnPtr res = std::move(temp_block.getByPosition(result).column);
|
||||
|
||||
/// if last argument is not nullable, result should be also not nullable
|
||||
if (!block.getByPosition(multi_if_args.back()).column->isColumnNullable() && res->isColumnNullable())
|
||||
|
@ -528,7 +528,7 @@ ColumnPtr pointInPolygon(const ColumnVector<T> & x, const ColumnVector<U> & y, P
|
||||
data[i] = static_cast<UInt8>(impl.contains(x_data[i], y_data[i]));
|
||||
}
|
||||
|
||||
return result;
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
template <typename ... Types>
|
||||
|
Loading…
Reference in New Issue
Block a user