This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 36524f2b72 [improvement](functions) avoid copying of block in
create_block_with_nested_columns (#21526)
36524f2b72 is described below
commit 36524f2b72ce5b18a5834ecb299c363db4024aa0
Author: Jerry Hu <[email protected]>
AuthorDate: Mon Jul 10 17:21:23 2023 +0800
[improvement](functions) avoid copying of block in
create_block_with_nested_columns (#21526)
avoid copying of block in create_block_with_nested_columns
---
be/src/vec/core/block.cpp | 5 +++++
be/src/vec/core/block.h | 2 ++
be/src/vec/functions/function_helpers.cpp | 5 +++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index 8dbcf22486..5162a94c46 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -128,6 +128,11 @@ Block::Block(const PBlock& pblock) {
initialize_index_by_name();
}
+void Block::reserve(size_t count) {
+ index_by_name.reserve(count);
+ data.reserve(count);
+}
+
void Block::initialize_index_by_name() {
for (size_t i = 0, size = data.size(); i < size; ++i) {
index_by_name[data[i].name] = i;
diff --git a/be/src/vec/core/block.h b/be/src/vec/core/block.h
index dd095245ec..939b8b78db 100644
--- a/be/src/vec/core/block.h
+++ b/be/src/vec/core/block.h
@@ -91,6 +91,8 @@ public:
Block(const std::vector<SlotDescriptor*>& slots, size_t block_size,
bool ignore_trivial_slot = false);
+ void reserve(size_t count);
+
/// insert the column at the specified position
void insert(size_t position, const ColumnWithTypeAndName& elem);
void insert(size_t position, ColumnWithTypeAndName&& elem);
diff --git a/be/src/vec/functions/function_helpers.cpp
b/be/src/vec/functions/function_helpers.cpp
index c6fcfce190..9cb371fb08 100644
--- a/be/src/vec/functions/function_helpers.cpp
+++ b/be/src/vec/functions/function_helpers.cpp
@@ -44,6 +44,7 @@ std::tuple<Block, ColumnNumbers>
create_block_with_nested_columns(const Block& b
const bool
need_check_same) {
Block res;
ColumnNumbers res_args(args.size());
+ res.reserve(args.size() + 1);
// only build temp block by args column, if args[i] == args[j]
// just keep one
@@ -100,7 +101,7 @@ std::tuple<Block, ColumnNumbers>
create_block_with_nested_columns(const Block& b
}
}
- return {res, res_args};
+ return {std::move(res), std::move(res_args)};
}
std::tuple<Block, ColumnNumbers, size_t>
create_block_with_nested_columns(const Block& block,
@@ -109,7 +110,7 @@ std::tuple<Block, ColumnNumbers, size_t>
create_block_with_nested_columns(const
auto [res, res_args] = create_block_with_nested_columns(block, args, true);
// insert result column in temp block
res.insert(block.get_by_position(result));
- return {res, res_args, res.columns() - 1};
+ return {std::move(res), std::move(res_args), res.columns() - 1};
}
void validate_argument_type(const IFunction& func, const DataTypes& arguments,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]