From 8b7a11cc2cc01ed47405cac0f8313408d9faa844 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 16 Feb 2024 01:23:00 +0100 Subject: [PATCH] Alternative way --- .../Serializations/SerializationAggregateFunction.cpp | 2 +- src/DataTypes/Serializations/SerializationSparse.cpp | 2 +- src/DataTypes/Serializations/SerializationString.cpp | 4 ++-- src/DataTypes/Serializations/SerializationVariant.cpp | 2 +- src/DataTypes/Serializations/SerializationVariantElement.cpp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/DataTypes/Serializations/SerializationAggregateFunction.cpp b/src/DataTypes/Serializations/SerializationAggregateFunction.cpp index c9af5d1f838..f0c107495c1 100644 --- a/src/DataTypes/Serializations/SerializationAggregateFunction.cpp +++ b/src/DataTypes/Serializations/SerializationAggregateFunction.cpp @@ -79,7 +79,7 @@ void SerializationAggregateFunction::deserializeBinaryBulk(IColumn & column, Rea Arena & arena = real_column.createOrGetArena(); real_column.set(function, version); - vec.reserve(vec.size() + limit); + vec.reserve_exact(vec.size() + limit); size_t size_of_state = function->sizeOfData(); size_t align_of_state = function->alignOfData(); diff --git a/src/DataTypes/Serializations/SerializationSparse.cpp b/src/DataTypes/Serializations/SerializationSparse.cpp index 4d7514271ad..0557e6d470c 100644 --- a/src/DataTypes/Serializations/SerializationSparse.cpp +++ b/src/DataTypes/Serializations/SerializationSparse.cpp @@ -66,7 +66,7 @@ size_t deserializeOffsets(IColumn::Offsets & offsets, } /// Just try to guess number of offsets. - offsets.reserve(offsets.size() + offsets.reserve_exact(offsets.size() + static_cast(limit * (1.0 - ColumnSparse::DEFAULT_RATIO_FOR_SPARSE_SERIALIZATION))); bool first = true; diff --git a/src/DataTypes/Serializations/SerializationString.cpp b/src/DataTypes/Serializations/SerializationString.cpp index 6bffa0ff72e..fd00b79806b 100644 --- a/src/DataTypes/Serializations/SerializationString.cpp +++ b/src/DataTypes/Serializations/SerializationString.cpp @@ -235,7 +235,7 @@ void SerializationString::deserializeBinaryBulk(IColumn & column, ReadBuffer & i { try { - data.reserve(size_to_reserve); + data.reserve_exact(size_to_reserve); } catch (Exception & e) { @@ -247,7 +247,7 @@ void SerializationString::deserializeBinaryBulk(IColumn & column, ReadBuffer & i } } - offsets.reserve(offsets.size() + limit); + offsets.reserve_exact(offsets.size() + limit); if (avg_chars_size >= 64) deserializeBinarySSE2<4>(data, offsets, istr, limit); diff --git a/src/DataTypes/Serializations/SerializationVariant.cpp b/src/DataTypes/Serializations/SerializationVariant.cpp index 5af94364167..4bed965acd3 100644 --- a/src/DataTypes/Serializations/SerializationVariant.cpp +++ b/src/DataTypes/Serializations/SerializationVariant.cpp @@ -320,7 +320,7 @@ void SerializationVariant::deserializeBinaryBulkWithMultipleStreams( else { auto & offsets = col.getOffsets(); - offsets.reserve(offsets.size() + limit); + offsets.reserve_exact(offsets.size() + limit); std::vector variant_offsets; variant_offsets.reserve(variants.size()); for (size_t i = 0; i != variants.size(); ++i) diff --git a/src/DataTypes/Serializations/SerializationVariantElement.cpp b/src/DataTypes/Serializations/SerializationVariantElement.cpp index 053f8d22d5a..27796ebc9de 100644 --- a/src/DataTypes/Serializations/SerializationVariantElement.cpp +++ b/src/DataTypes/Serializations/SerializationVariantElement.cpp @@ -129,7 +129,7 @@ void SerializationVariantElement::deserializeBinaryBulkWithMultipleStreams( /// Otherwise we should iterate through discriminators to fill null map. else { - null_map.reserve(null_map.size() + limit); + null_map.reserve_exact(null_map.size() + limit); for (size_t i = discriminators_offset; i != discriminators_data.size(); ++i) null_map.push_back(discriminators_data[i] != variant_discriminator); } @@ -241,7 +241,7 @@ ColumnPtr SerializationVariantElement::VariantSubcolumnCreator::create(const DB: /// In general case we should iterate through discriminators and create null-map for our variant. NullMap null_map; - null_map.reserve(local_discriminators->size()); + null_map.reserve_exact(local_discriminators->size()); const auto & local_discriminators_data = assert_cast(*local_discriminators).getData(); for (auto local_discr : local_discriminators_data) null_map.push_back(local_discr != local_variant_discriminator);