From 0b76b61c730938693b1de76c05f80458f83da850 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 15 Dec 2017 22:46:24 +0300 Subject: [PATCH] Better semantic of sharing columns: development [#CLICKHOUSE-2]. --- dbms/src/Columns/ColumnAggregateFunction.cpp | 4 +- dbms/src/Columns/ColumnArray.cpp | 65 +++++++++++--------- dbms/src/Columns/ColumnArray.h | 5 +- dbms/src/Columns/ColumnConst.cpp | 2 +- dbms/src/Columns/ColumnConst.h | 2 +- dbms/src/Columns/ColumnExpression.cpp | 12 ++-- dbms/src/Columns/ColumnExpression.h | 4 +- dbms/src/Columns/ColumnFixedString.cpp | 8 +-- dbms/src/Columns/ColumnNullable.cpp | 10 +-- dbms/src/Columns/ColumnNullable.h | 2 +- dbms/src/Columns/ColumnString.cpp | 12 ++-- dbms/src/Columns/ColumnTuple.cpp | 11 ++-- dbms/src/Columns/ColumnTuple.h | 2 + dbms/src/Columns/ColumnVector.cpp | 18 +++--- 14 files changed, 87 insertions(+), 70 deletions(-) diff --git a/dbms/src/Columns/ColumnAggregateFunction.cpp b/dbms/src/Columns/ColumnAggregateFunction.cpp index 1d25e295f7d..1df7abf160e 100644 --- a/dbms/src/Columns/ColumnAggregateFunction.cpp +++ b/dbms/src/Columns/ColumnAggregateFunction.cpp @@ -75,7 +75,7 @@ MutableColumnPtr ColumnAggregateFunction::convertToValues() const for (auto val : getData()) function->insertResultInto(val, *res); - return std::move(res); + return res; } @@ -372,7 +372,7 @@ MutableColumns ColumnAggregateFunction::scatter(IColumn::ColumnIndex num_columns for (size_t i = 0; i < num_rows; ++i) static_cast(*columns[selector[i]]).data.push_back(data[i]); - return std::move(columns); + return columns; } void ColumnAggregateFunction::getPermutation(bool /*reverse*/, size_t /*limit*/, int /*nan_direction_hint*/, IColumn::Permutation & res) const diff --git a/dbms/src/Columns/ColumnArray.cpp b/dbms/src/Columns/ColumnArray.cpp index f115d2d7a1e..0622d663c20 100644 --- a/dbms/src/Columns/ColumnArray.cpp +++ b/dbms/src/Columns/ColumnArray.cpp @@ -34,7 +34,7 @@ namespace ErrorCodes ColumnArray::ColumnArray(const ColumnPtr & nested_column, const ColumnPtr & offsets_column) : data(nested_column), offsets(offsets_column) { - if (!typeid_cast(offsets_column.get())) + if (!typeid_cast(offsets_column.get())) throw Exception("offsets_column must be a ColumnUInt64", ErrorCodes::ILLEGAL_COLUMN); /** NOTE @@ -43,13 +43,22 @@ ColumnArray::ColumnArray(const ColumnPtr & nested_column, const ColumnPtr & offs */ } +ColumnArray::ColumnArray(const ColumnPtr & nested_column) + : data(nested_column) +{ + if (!data->empty()) + throw Exception("Not empty data passed to ColumnArray, but no offsets passed", ErrorCodes::ILLEGAL_COLUMN); + + offsets = ColumnOffsets_t::create(); +} + std::string ColumnArray::getName() const { return "Array(" + getData().getName() + ")"; } MutableColumnPtr ColumnArray::cloneResized(size_t to_size) const { - auto res = ColumnArray::create(getData().cloneEmpty(), ColumnOffsets_t::create()); + auto res = ColumnArray::create(getData().cloneEmpty()); if (to_size == 0) return std::move(res); @@ -141,7 +150,7 @@ void ColumnArray::insertData(const char * pos, size_t length) { /** Similarly - only for arrays of fixed length values. */ - IColumn * data_ = getData().get(); + IColumn * data_ = &getData(); if (!data_->isFixedAndContiguous()) throw Exception("Method insertData is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED); @@ -312,7 +321,7 @@ MutableColumnPtr ColumnArray::convertToFullColumnIfConst() const { ColumnPtr new_data; - if (auto full_column = getData().convertToFullColumnIfConst()) + if (ColumnPtr full_column = getData().convertToFullColumnIfConst()) new_data = full_column; else new_data = data; @@ -361,7 +370,7 @@ void ColumnArray::insertRangeFrom(const IColumn & src, size_t start, size_t leng size_t nested_offset = src_concrete.offsetAt(start); size_t nested_length = src_concrete.getOffsets()[start + length - 1] - nested_offset; - data->insertRangeFrom(src_concrete.getData(), nested_offset, nested_length); + insertRangeFrom(src_concrete.getData(), nested_offset, nested_length); Offsets_t & cur_offsets = getOffsets(); const Offsets_t & src_offsets = src_concrete.getOffsets(); @@ -404,15 +413,15 @@ template MutableColumnPtr ColumnArray::filterNumber(const Filter & filt, ssize_t result_size_hint) const { if (getOffsets().size() == 0) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); - auto res = ColumnArray::create(data->cloneEmpty(), ColumnOffsets_t::create()); + auto res = ColumnArray::create(data->cloneEmpty()); auto & res_elems = static_cast &>(res->getData()).getData(); Offsets_t & res_offsets = res->getOffsets(); filterArraysImpl(static_cast &>(*data).getData(), getOffsets(), res_elems, res_offsets, filt, result_size_hint); - return res; + return std::move(res); } MutableColumnPtr ColumnArray::filterString(const Filter & filt, ssize_t result_size_hint) const @@ -422,9 +431,9 @@ MutableColumnPtr ColumnArray::filterString(const Filter & filt, ssize_t result_s throw Exception("Size of filter doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); if (0 == col_size) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); - auto res = ColumnArray::create(data->cloneEmpty(), ColumnOffsets_t::create()); + auto res = ColumnArray::create(data->cloneEmpty()); const ColumnString & src_string = typeid_cast(*data); const ColumnString::Chars_t & src_chars = src_string.getChars(); @@ -480,7 +489,7 @@ MutableColumnPtr ColumnArray::filterString(const Filter & filt, ssize_t result_s } } - return res; + return std::move(res); } MutableColumnPtr ColumnArray::filterGeneric(const Filter & filt, ssize_t result_size_hint) const @@ -490,7 +499,7 @@ MutableColumnPtr ColumnArray::filterGeneric(const Filter & filt, ssize_t result_ throw Exception("Size of filter doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); if (size == 0) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); Filter nested_filt(getOffsets().back()); for (size_t i = 0; i < size; ++i) @@ -501,7 +510,7 @@ MutableColumnPtr ColumnArray::filterGeneric(const Filter & filt, ssize_t result_ memset(&nested_filt[offsetAt(i)], 0, sizeAt(i)); } - auto res = ColumnArray::create(data, ColumnOffsets_t::create()); + auto res = ColumnArray::create(data); ssize_t nested_result_size_hint = 0; if (result_size_hint < 0) @@ -525,36 +534,36 @@ MutableColumnPtr ColumnArray::filterGeneric(const Filter & filt, ssize_t result_ } } - return res; + return std::move(res); } MutableColumnPtr ColumnArray::filterNullable(const Filter & filt, ssize_t result_size_hint) const { if (getOffsets().size() == 0) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); const ColumnNullable & nullable_elems = static_cast(*data); auto array_of_nested = ColumnArray::create(nullable_elems.getNestedColumnPtr(), offsets); auto filtered_array_of_nested_owner = array_of_nested->filter(filt, result_size_hint); - auto & filtered_array_of_nested = static_cast(*filtered_array_of_nested_owner); + auto & filtered_array_of_nested = static_cast(*filtered_array_of_nested_owner); auto & filtered_offsets = filtered_array_of_nested.getOffsetsPtr(); auto res_null_map = ColumnUInt8::create(); - auto res = ColumnArray::create( + + filterArraysImplOnlyData(nullable_elems.getNullMapData(), getOffsets(), res_null_map->getData(), filt, result_size_hint); + + return ColumnArray::create( ColumnNullable::create( filtered_array_of_nested.getDataPtr(), res_null_map), filtered_offsets); - - filterArraysImplOnlyData(nullable_elems.getNullMapData(), getOffsets(), res_null_map->getData(), filt, result_size_hint); - return res; } MutableColumnPtr ColumnArray::filterTuple(const Filter & filt, ssize_t result_size_hint) const { if (getOffsets().size() == 0) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); const ColumnTuple & tuple = static_cast(*data); @@ -571,11 +580,11 @@ MutableColumnPtr ColumnArray::filterTuple(const Filter & filt, ssize_t result_si Columns tuple_columns(tuple_size); for (size_t i = 0; i < tuple_size; ++i) - tuple_columns[i] = static_cast(*temporary_arrays[i]).getDataPtr(); + tuple_columns[i] = static_cast(*temporary_arrays[i]).getDataPtr(); return ColumnArray::create( ColumnTuple::create(tuple_columns), - static_cast(*temporary_arrays.front()).getOffsetsPtr()); + static_cast(*temporary_arrays.front()).getOffsetsPtr()); } @@ -592,11 +601,11 @@ MutableColumnPtr ColumnArray::permute(const Permutation & perm, size_t limit) co throw Exception("Size of permutation is less than required.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); if (limit == 0) - return ColumnArray::create(data, ColumnOffsets_t::create()); + return ColumnArray::create(data); Permutation nested_perm(getOffsets().back()); - auto res = ColumnArray::create(data->cloneEmpty(), ColumnOffsets_t::create()); + auto res = ColumnArray::create(data->cloneEmpty()); Offsets_t & res_offsets = res->getOffsets(); res_offsets.resize(limit); @@ -613,7 +622,7 @@ MutableColumnPtr ColumnArray::permute(const Permutation & perm, size_t limit) co if (current_offset != 0) res->data = data->permute(nested_perm, current_offset); - return res; + return std::move(res); } void ColumnArray::getPermutation(bool reverse, size_t limit, int nan_direction_hint, Permutation & res) const @@ -886,11 +895,11 @@ MutableColumnPtr ColumnArray::replicateTuple(const Offsets_t & replicate_offsets Columns tuple_columns(tuple_size); for (size_t i = 0; i < tuple_size; ++i) - tuple_columns[i] = static_cast(*temporary_arrays[i]).getDataPtr(); + tuple_columns[i] = static_cast(*temporary_arrays[i]).getDataPtr(); return ColumnArray::create( ColumnTuple::create(tuple_columns), - static_cast(*temporary_arrays.front()).getOffsetsPtr()); + static_cast(*temporary_arrays.front()).getOffsetsPtr()); } diff --git a/dbms/src/Columns/ColumnArray.h b/dbms/src/Columns/ColumnArray.h index 1e9c0da6973..cbbf55182b8 100644 --- a/dbms/src/Columns/ColumnArray.h +++ b/dbms/src/Columns/ColumnArray.h @@ -23,9 +23,12 @@ class ColumnArray final : public COWPtrHelper private: friend class COWPtrHelper; - /** Create an empty column of arrays with the type of values as in the column `nested_column` */ + /** Create an array column with specified values and offsets. */ ColumnArray(const ColumnPtr & nested_column, const ColumnPtr & offsets_column); + /** Create an empty column of arrays with the type of values as in the column `nested_column` */ + ColumnArray(const ColumnPtr & nested_column); + ColumnArray(const ColumnArray & src) = default; public: diff --git a/dbms/src/Columns/ColumnConst.cpp b/dbms/src/Columns/ColumnConst.cpp index 1b16382a03b..33d9d28667c 100644 --- a/dbms/src/Columns/ColumnConst.cpp +++ b/dbms/src/Columns/ColumnConst.cpp @@ -10,7 +10,7 @@ namespace DB { -ColumnConst::ColumnConst(ColumnPtr data_, size_t s) +ColumnConst::ColumnConst(const ColumnPtr & data_, size_t s) : data(data_), s(s) { /// Squash Const of Const. diff --git a/dbms/src/Columns/ColumnConst.h b/dbms/src/Columns/ColumnConst.h index 8e9dc814952..943f01fd128 100644 --- a/dbms/src/Columns/ColumnConst.h +++ b/dbms/src/Columns/ColumnConst.h @@ -27,7 +27,7 @@ private: ColumnPtr data; size_t s; - ColumnConst(ColumnPtr data, size_t s); + ColumnConst(const ColumnPtr & data, size_t s); ColumnConst(const ColumnConst & src) = default; public: diff --git a/dbms/src/Columns/ColumnExpression.cpp b/dbms/src/Columns/ColumnExpression.cpp index f240fd91ac7..9db3fba0a69 100644 --- a/dbms/src/Columns/ColumnExpression.cpp +++ b/dbms/src/Columns/ColumnExpression.cpp @@ -6,18 +6,20 @@ namespace DB { ColumnExpression::ColumnExpression( - size_t s_, ExpressionActionsPtr expression_, const NamesAndTypes & arguments_, DataTypePtr return_type_, std::string return_name_) - : IColumnDummy(s_), expression(expression_), arguments(arguments_), return_type(return_type_), return_name(return_name_) + size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypes & arguments_, const DataTypePtr & return_type_, const String & return_name_) + : expression(expression_), arguments(arguments_), return_type(return_type_), return_name(return_name_) { + s = s_; } ColumnExpression::ColumnExpression( - size_t s_, ExpressionActionsPtr expression_, const NamesAndTypesList & arguments_, DataTypePtr return_type_, std::string return_name_) - : IColumnDummy(s_), expression(expression_), arguments(arguments_.begin(), arguments_.end()), return_type(return_type_), return_name(return_name_) + size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypesList & arguments_, const DataTypePtr & return_type_, const String & return_name_) + : expression(expression_), arguments(arguments_.begin(), arguments_.end()), return_type(return_type_), return_name(return_name_) { + s = s_; } -ColumnPtr ColumnExpression::cloneDummy(size_t s_) const +MutableColumnPtr ColumnExpression::cloneDummy(size_t s_) const { return ColumnExpression::create(s_, expression, arguments, return_type, return_name); } diff --git a/dbms/src/Columns/ColumnExpression.h b/dbms/src/Columns/ColumnExpression.h index 32bc0825bf8..cfbd8cb5353 100644 --- a/dbms/src/Columns/ColumnExpression.h +++ b/dbms/src/Columns/ColumnExpression.h @@ -19,8 +19,8 @@ private: using ExpressionActionsPtr = std::shared_ptr; - ColumnExpression(size_t s_, ExpressionActionsPtr expression_, const NamesAndTypes & arguments_, DataTypePtr return_type_, String return_name_); - ColumnExpression(size_t s_, ExpressionActionsPtr expression_, const NamesAndTypesList & arguments_, DataTypePtr return_type_, String return_name_); + ColumnExpression(size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypes & arguments_, const DataTypePtr & return_type_, const String & return_name_); + ColumnExpression(size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypesList & arguments_, const DataTypePtr & return_type_, const String & return_name_); ColumnExpression(const ColumnExpression &) = default; diff --git a/dbms/src/Columns/ColumnFixedString.cpp b/dbms/src/Columns/ColumnFixedString.cpp index 40dc9359ca4..5c6573b50e2 100644 --- a/dbms/src/Columns/ColumnFixedString.cpp +++ b/dbms/src/Columns/ColumnFixedString.cpp @@ -227,7 +227,7 @@ MutableColumnPtr ColumnFixedString::filter(const IColumn::Filter & filt, ssize_t data_pos += n; } - return res; + return std::move(res); } MutableColumnPtr ColumnFixedString::permute(const Permutation & perm, size_t limit) const @@ -255,7 +255,7 @@ MutableColumnPtr ColumnFixedString::permute(const Permutation & perm, size_t lim for (size_t i = 0; i < limit; ++i, offset += n) memcpySmallAllowReadWriteOverflow15(&res_chars[offset], &chars[perm[i] * n], n); - return res; + return std::move(res); } MutableColumnPtr ColumnFixedString::replicate(const Offsets_t & offsets) const @@ -267,7 +267,7 @@ MutableColumnPtr ColumnFixedString::replicate(const Offsets_t & offsets) const auto res = ColumnFixedString::create(n); if (0 == col_size) - return res; + return std::move(res); Chars_t & res_chars = res->chars; res_chars.resize(n * offsets.back()); @@ -277,7 +277,7 @@ MutableColumnPtr ColumnFixedString::replicate(const Offsets_t & offsets) const for (size_t next_offset = offsets[i]; curr_offset < next_offset; ++curr_offset) memcpySmallAllowReadWriteOverflow15(&res->chars[curr_offset * n], &chars[i * n], n); - return res; + return std::move(res); } void ColumnFixedString::gather(ColumnGathererStream & gatherer) diff --git a/dbms/src/Columns/ColumnNullable.cpp b/dbms/src/Columns/ColumnNullable.cpp index 23e899de561..9c06592ee05 100644 --- a/dbms/src/Columns/ColumnNullable.cpp +++ b/dbms/src/Columns/ColumnNullable.cpp @@ -18,11 +18,11 @@ namespace ErrorCodes } -ColumnNullable::ColumnNullable(ColumnPtr nested_column_, ColumnPtr null_map_) +ColumnNullable::ColumnNullable(const ColumnPtr & nested_column_, const ColumnPtr & null_map_) : nested_column{nested_column_}, null_map{null_map_} { /// ColumnNullable cannot have constant nested column. But constant argument could be passed. Materialize it. - if (auto nested_column_materialized = getNestedColumn().convertToFullColumnIfConst()) + if (ColumnPtr nested_column_materialized = getNestedColumn().convertToFullColumnIfConst()) nested_column = nested_column_materialized; if (!getNestedColumn().canBeInsideNullable()) @@ -42,7 +42,7 @@ void ColumnNullable::updateHashWithValue(size_t n, SipHash & hash) const } -ColumnPtr ColumnNullable::cloneResized(size_t new_size) const +MutableColumnPtr ColumnNullable::cloneResized(size_t new_size) const { ColumnPtr new_nested_col = getNestedColumn().cloneResized(new_size); auto new_null_map = ColumnUInt8::create(); @@ -59,7 +59,7 @@ ColumnPtr ColumnNullable::cloneResized(size_t new_size) const memset(&new_null_map->getData()[count], 1, new_size - count); } - return ColumnNullable::create(new_nested_col, new_null_map); + return ColumnNullable::create(new_nested_col, std::move(new_null_map)); } @@ -437,7 +437,7 @@ ColumnPtr makeNullable(const ColumnPtr & column) return column; if (column->isColumnConst()) - return ColumnConst::create(makeNullable(static_cast(*column).getDataColumnPtr()), column->size()); + return ColumnConst::create(makeNullable(static_cast(*column).getDataColumnPtr()), column->size()); return ColumnNullable::create(column, ColumnUInt8::create(column->size(), 0)); } diff --git a/dbms/src/Columns/ColumnNullable.h b/dbms/src/Columns/ColumnNullable.h index 408190b6fdd..fb8e77e1d8e 100644 --- a/dbms/src/Columns/ColumnNullable.h +++ b/dbms/src/Columns/ColumnNullable.h @@ -23,7 +23,7 @@ class ColumnNullable final : public COWPtrHelper private: friend class COWPtrHelper; - ColumnNullable(ColumnPtr nested_column_, ColumnPtr null_map_); + ColumnNullable(const ColumnPtr & nested_column_, const ColumnPtr & null_map_); ColumnNullable(ColumnNullable &) = default; public: diff --git a/dbms/src/Columns/ColumnString.cpp b/dbms/src/Columns/ColumnString.cpp index f65a4f170ef..67ab1bebc24 100644 --- a/dbms/src/Columns/ColumnString.cpp +++ b/dbms/src/Columns/ColumnString.cpp @@ -24,7 +24,7 @@ MutableColumnPtr ColumnString::cloneResized(size_t to_size) const auto res = ColumnString::create(); if (to_size == 0) - return res; + return std::move(res); size_t from_size = size(); @@ -59,7 +59,7 @@ MutableColumnPtr ColumnString::cloneResized(size_t to_size) const } } - return res; + return std::move(res); } @@ -108,7 +108,7 @@ MutableColumnPtr ColumnString::filter(const Filter & filt, ssize_t result_size_h Offsets_t & res_offsets = res->offsets; filterArraysImpl(chars, offsets, res_chars, res_offsets, filt, result_size_hint); - return res; + return std::move(res); } @@ -158,7 +158,7 @@ MutableColumnPtr ColumnString::permute(const Permutation & perm, size_t limit) c res_offsets[i] = current_new_offset; } - return res; + return std::move(res); } @@ -217,7 +217,7 @@ MutableColumnPtr ColumnString::replicate(const Offsets_t & replicate_offsets) co auto res = ColumnString::create(); if (0 == col_size) - return res; + return std::move(res); Chars_t & res_chars = res->chars; Offsets_t & res_offsets = res->offsets; @@ -247,7 +247,7 @@ MutableColumnPtr ColumnString::replicate(const Offsets_t & replicate_offsets) co prev_string_offset = offsets[i]; } - return res; + return std::move(res); } diff --git a/dbms/src/Columns/ColumnTuple.cpp b/dbms/src/Columns/ColumnTuple.cpp index d27b6cdc9da..9ddee4b1a37 100644 --- a/dbms/src/Columns/ColumnTuple.cpp +++ b/dbms/src/Columns/ColumnTuple.cpp @@ -38,7 +38,7 @@ ColumnTuple::ColumnTuple(const Columns & columns) : columns(columns) throw Exception{"ColumnTuple cannot have ColumnConst as its element", ErrorCodes::ILLEGAL_COLUMN}; } -ColumnPtr ColumnTuple::cloneEmpty() const +MutableColumnPtr ColumnTuple::cloneEmpty() const { const size_t tuple_size = columns.size(); Columns new_columns(tuple_size); @@ -176,7 +176,7 @@ MutableColumnPtr ColumnTuple::replicate(const Offsets_t & offsets) const MutableColumns ColumnTuple::scatter(ColumnIndex num_columns, const Selector & selector) const { const size_t tuple_size = columns.size(); - std::vector scattered_tuple_elements(tuple_size); + std::vector scattered_tuple_elements(tuple_size); for (size_t tuple_element_idx = 0; tuple_element_idx < tuple_size; ++tuple_element_idx) scattered_tuple_elements[tuple_element_idx] = columns[tuple_element_idx]->scatter(num_columns, selector); @@ -187,7 +187,7 @@ MutableColumns ColumnTuple::scatter(ColumnIndex num_columns, const Selector & se { Columns new_columns(tuple_size); for (size_t tuple_element_idx = 0; tuple_element_idx < tuple_size; ++tuple_element_idx) - new_columns[tuple_element_idx] = scattered_tuple_elements[tuple_element_idx][scattered_idx]; + new_columns[tuple_element_idx] = std::move(scattered_tuple_elements[tuple_element_idx][scattered_idx]); res[scattered_idx] = ColumnTuple::create(new_columns); } @@ -264,8 +264,9 @@ void ColumnTuple::gather(ColumnGathererStream & gatherer) void ColumnTuple::reserve(size_t n) { - for (auto & column : columns) - column->reserve(n); + const size_t tuple_size = columns.size(); + for (size_t i = 0; i < tuple_size; ++i) + getColumnPtr(i)->reserve(n); } size_t ColumnTuple::byteSize() const diff --git a/dbms/src/Columns/ColumnTuple.h b/dbms/src/Columns/ColumnTuple.h index 6584be35ad7..d75d8c316ec 100644 --- a/dbms/src/Columns/ColumnTuple.h +++ b/dbms/src/Columns/ColumnTuple.h @@ -62,6 +62,8 @@ public: size_t allocatedBytes() const override; void forEachSubcolumn(ColumnCallback callback) override; + size_t tupleSize() const { return columns.size(); } + const Columns & getColumns() const { return columns; } const ColumnPtr & getColumnPtr(size_t idx) const { return columns[idx]; } diff --git a/dbms/src/Columns/ColumnVector.cpp b/dbms/src/Columns/ColumnVector.cpp index 3510f10527d..9dd9210d448 100644 --- a/dbms/src/Columns/ColumnVector.cpp +++ b/dbms/src/Columns/ColumnVector.cpp @@ -105,7 +105,7 @@ const char * ColumnVector::getFamilyName() const template MutableColumnPtr ColumnVector::cloneResized(size_t size) const { - auto res = create(); + auto res = this->create(); if (size > 0) { @@ -119,7 +119,7 @@ MutableColumnPtr ColumnVector::cloneResized(size_t size) const memset(&new_col.data[count], static_cast(value_type()), size - count); } - return res; + return std::move(res); } template @@ -152,7 +152,7 @@ MutableColumnPtr ColumnVector::filter(const IColumn::Filter & filt, ssize_t r if (size != filt.size()) throw Exception("Size of filter doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); - auto res = create(); + auto res = this->create(); Container_t & res_data = res->getData(); if (result_size_hint) @@ -206,7 +206,7 @@ MutableColumnPtr ColumnVector::filter(const IColumn::Filter & filt, ssize_t r ++data_pos; } - return res; + return std::move(res); } template @@ -222,12 +222,12 @@ MutableColumnPtr ColumnVector::permute(const IColumn::Permutation & perm, siz if (perm.size() < limit) throw Exception("Size of permutation is less than required.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); - auto res = create(limit); + auto res = this->create(limit); typename Self::Container_t & res_data = res->getData(); for (size_t i = 0; i < limit; ++i) res_data[i] = data[perm[i]]; - return res; + return std::move(res); } template @@ -238,9 +238,9 @@ MutableColumnPtr ColumnVector::replicate(const IColumn::Offsets_t & offsets) throw Exception("Size of offsets doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); if (0 == size) - return create(); + return this->create(); - auto res = create(); + auto res = this->create(); typename Self::Container_t & res_data = res->getData(); res_data.reserve(offsets.back()); @@ -254,7 +254,7 @@ MutableColumnPtr ColumnVector::replicate(const IColumn::Offsets_t & offsets) res_data.push_back(data[i]); } - return res; + return std::move(res); } template