Skip to content

Commit

Permalink
Donot reserve memory for non-fixed type columns in decodeAndSquash (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 6, 2023
1 parent 69b80c5 commit 3eed664
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dbms/src/Flash/Coprocessor/CHBlockChunkCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <DataStreams/IBlockInputStream.h>
#include <DataStreams/NativeBlockInputStream.h>
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/DataTypeNullable.h>
#include <Flash/Coprocessor/CHBlockChunkCodec.h>
#include <Flash/Coprocessor/DAGUtils.h>
#include <IO/ReadBufferFromString.h>
Expand Down Expand Up @@ -163,10 +164,14 @@ Block CHBlockChunkCodec::decodeImpl(ReadBuffer & istr, size_t reserve_size)

/// Data
MutableColumnPtr read_column = column.type->createColumn();
if (reserve_size > 0)
read_column->reserve(std::max(rows, reserve_size));
else if (rows)
read_column->reserve(rows);
const auto & type_removed_nullable = removeNullable(column.type);
if (type_removed_nullable->isValueRepresentedByNumber() || type_removed_nullable->isFixedString())
{
if (reserve_size > 0)
read_column->reserve(std::max(rows, reserve_size));
else if (rows)
read_column->reserve(rows);
}

if (rows) /// If no rows, nothing to read.
readData(*column.type, *read_column, istr, rows);
Expand Down

0 comments on commit 3eed664

Please sign in to comment.