This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch vectorized
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit e4619d98a18952a24e2e3583d3ab82da2d0a1ba8
Author: thinker <zchw...@qq.com>
AuthorDate: Fri Jan 7 15:37:35 2022 +0800

    [vectorized] [block] Add new method get_data_type to avoid unnecessary copy 
 by the method get_data_type (#7600)
    
    Co-authored-by: zuochunwei <zuochun...@meituan.com>
---
 be/src/vec/core/block.cpp        | 4 ++--
 be/src/vec/core/block.h          | 7 ++++++-
 be/src/vec/olap/block_reader.cpp | 4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index a5e445d..2aff751 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -51,7 +51,7 @@
 
 namespace doris::vectorized {
 
-inline DataTypePtr get_data_type(const PColumn& pcolumn) {
+inline DataTypePtr create_data_type(const PColumn& pcolumn) {
     switch (pcolumn.type()) {
     case PColumn::UINT8: {
         return std::make_shared<DataTypeUInt8>();
@@ -176,7 +176,7 @@ Block::Block(const ColumnsWithTypeAndName& data_) : data 
{data_} {
 
 Block::Block(const PBlock& pblock) {
     for (const auto& pcolumn : pblock.columns()) {
-        DataTypePtr type = get_data_type(pcolumn);
+        DataTypePtr type = create_data_type(pcolumn);
         MutableColumnPtr data_column;
         if (pcolumn.is_null_size() > 0) {
             data_column =
diff --git a/be/src/vec/core/block.h b/be/src/vec/core/block.h
index addecf7..1c435ee 100644
--- a/be/src/vec/core/block.h
+++ b/be/src/vec/core/block.h
@@ -130,6 +130,11 @@ public:
     Names get_names() const;
     DataTypes get_data_types() const;
 
+    DataTypePtr get_data_type(size_t index) const { 
+        CHECK(index < data.size());
+        return data[index].type; 
+    }
+
     /// Returns number of rows from first column in block, not equal to 
nullptr. If no columns, returns 0.
     size_t rows() const;
 
@@ -204,7 +209,7 @@ public:
     static Status filter_block(Block* block, int filter_conlumn_id, int 
column_to_keep);
 
     static inline void erase_useless_column(Block* block, int column_to_keep) {
-        for (size_t i = block->columns() - 1; i >= column_to_keep; --i) {
+        for (int i = block->columns() - 1; i >= column_to_keep; --i) {
             block->erase(i);
         }
     }
diff --git a/be/src/vec/olap/block_reader.cpp b/be/src/vec/olap/block_reader.cpp
index 769e27e..8e2d4b2 100644
--- a/be/src/vec/olap/block_reader.cpp
+++ b/be/src/vec/olap/block_reader.cpp
@@ -94,11 +94,11 @@ void BlockReader::_init_agg_state() {
 
         // create aggregate function
         DataTypes argument_types;
-        argument_types.push_back(_next_row.block->get_data_types()[idx]);
+        argument_types.push_back(_next_row.block->get_data_type(idx));
         Array params;
         AggregateFunctionPtr function = 
AggregateFunctionSimpleFactory::instance().get(
                 agg_name, argument_types, params,
-                _next_row.block->get_data_types()[idx]->is_nullable());
+                _next_row.block->get_data_type(idx)->is_nullable());
         DCHECK(function != nullptr);
         _agg_functions.push_back(function);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to