github-actions[bot] commented on code in PR #15665:
URL: https://github.com/apache/doris/pull/15665#discussion_r1067720102


##########
be/src/olap/rowset/segment_v2/column_reader.cpp:
##########
@@ -398,6 +416,24 @@ Status ColumnReader::new_iterator(ColumnIterator** 
iterator) {
     } else {
         auto type = (FieldType)_meta.type();
         switch (type) {
+        case FieldType::OLAP_FIELD_TYPE_STRUCT: {
+            std::vector<ColumnIterator*> sub_column_iterators;
+            size_t child_size = is_nullable() ? _sub_readers.size() - 1 : 
_sub_readers.size();
+            sub_column_iterators.reserve(child_size);
+
+            ColumnIterator* sub_column_iterator;
+            for (size_t i = 0; i < child_size; i++) {
+                
RETURN_IF_ERROR(_sub_readers[i]->new_iterator(&sub_column_iterator));
+                sub_column_iterators.push_back(std::move(sub_column_iterator));

Review Comment:
   warning: std::move of the variable 'sub_column_iterator' of the 
trivially-copyable type 'doris::segment_v2::ColumnIterator *' has no effect 
[performance-move-const-arg]
   ```cpp
                   
sub_column_iterators.push_back(std::move(sub_column_iterator));
                                                  ^
   ```
   



##########
be/src/vec/data_types/data_type_factory.cpp:
##########
@@ -125,8 +149,23 @@
     case TYPE_ARRAY:
         DCHECK(col_desc.children.size() == 1);
         nested = std::make_shared<vectorized::DataTypeArray>(
-                create_data_type(col_desc.children[0], 
col_desc.contains_null));
+                create_data_type(col_desc.children[0], 
col_desc.contains_nulls[0]));
+        break;
+    case TYPE_STRUCT: {
+        DCHECK(col_desc.children.size() >= 1);
+        size_t child_size = col_desc.children.size();
+        DCHECK_EQ(col_desc.field_names.size(), child_size);
+        DataTypes dataTypes;
+        Strings names;
+        dataTypes.reserve(child_size);
+        names.reserve(child_size);
+        for (size_t i = 0; i < child_size; i++) {
+            
dataTypes.push_back(std::move(create_data_type(col_desc.children[i], 
col_desc.contains_nulls[i])));

Review Comment:
   warning: moving a temporary object prevents copy elision 
[clang-diagnostic-pessimizing-move]
   ```cpp
               
dataTypes.push_back(std::move(create_data_type(col_desc.children[i], 
col_desc.contains_nulls[i])));
                                   ^
   ```
   **be/src/vec/data_types/data_type_factory.cpp:162:** remove std::move call 
here
   ```cpp
               
dataTypes.push_back(std::move(create_data_type(col_desc.children[i], 
col_desc.contains_nulls[i])));
                                   ^
   ```
   



##########
be/src/vec/exprs/vstruct_literal.h:
##########
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "vec/exprs/vliteral.h"
+
+namespace doris {
+
+namespace vectorized {
+    class VStructLiteral : public VLiteral {
+    public:
+        VStructLiteral(const TExprNode& node) : VLiteral(node, false) {}
+        virtual ~VStructLiteral() = default;
+        virtual Status prepare(RuntimeState* state, const RowDescriptor& 
row_desc,

Review Comment:
   warning: 'virtual' is redundant since the function is already declared 
'override' [modernize-use-override]
   
   ```suggestion
           Status prepare(RuntimeState* state, const RowDescriptor& row_desc,
   ```
   



##########
be/src/vec/exprs/vstruct_literal.h:
##########
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "vec/exprs/vliteral.h"
+
+namespace doris {
+
+namespace vectorized {
+    class VStructLiteral : public VLiteral {
+    public:
+        VStructLiteral(const TExprNode& node) : VLiteral(node, false) {}
+        virtual ~VStructLiteral() = default;

Review Comment:
   warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' 
[modernize-use-override]
   
   ```suggestion
           ~VStructLiteral() override = default;
   ```
   



##########
be/src/vec/data_types/data_type_factory.cpp:
##########
@@ -27,6 +27,18 @@ DataTypePtr DataTypeFactory::create_data_type(const 
doris::Field& col_desc) {
     if (col_desc.type() == OLAP_FIELD_TYPE_ARRAY) {
         DCHECK(col_desc.get_sub_field_count() == 1);
         nested = 
std::make_shared<DataTypeArray>(create_data_type(*col_desc.get_sub_field(0)));
+    } else if (col_desc.type() == OLAP_FIELD_TYPE_STRUCT) {
+        DCHECK(col_desc.get_sub_field_count() >= 1);
+        size_t field_size = col_desc.get_sub_field_count();
+        DataTypes dataTypes;
+        Strings names;
+        dataTypes.reserve(field_size);
+        names.reserve(field_size);
+        for (size_t i = 0; i < field_size; i++) {
+            
dataTypes.push_back(std::move(create_data_type(*col_desc.get_sub_field(i))));

Review Comment:
   warning: moving a temporary object prevents copy elision 
[clang-diagnostic-pessimizing-move]
   ```cpp
               
dataTypes.push_back(std::move(create_data_type(*col_desc.get_sub_field(i))));
                                   ^
   ```
   **be/src/vec/data_types/data_type_factory.cpp:37:** remove std::move call 
here
   ```cpp
               
dataTypes.push_back(std::move(create_data_type(*col_desc.get_sub_field(i))));
                                   ^
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to