cambyzju commented on a change in pull request #8766:
URL: https://github.com/apache/incubator-doris/pull/8766#discussion_r840194505



##########
File path: be/src/vec/exprs/table_function/vexplode.cpp
##########
@@ -0,0 +1,112 @@
+// 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.
+
+#include "vec/exprs/table_function/vexplode.h"
+
+#include "vec/exprs/vexpr.h"
+
+namespace doris::vectorized {
+
+VExplodeTableFunction::VExplodeTableFunction() {
+    _fn_name = "vexplode_outer";
+}
+
+Status VExplodeTableFunction::process_init(vectorized::Block* block) {
+    CHECK(_vexpr_context->root()->children().size() == 1)
+            << "VExplodeTableFunction must be have 1 children but have "
+            << _vexpr_context->root()->children().size();
+
+    int value_column_idx = -1;
+    _vexpr_context->root()->children()[0]->execute(_vexpr_context, block, 
&value_column_idx);
+    VLOG_DEBUG << "get_name:" << 
block->get_by_position(value_column_idx).column->get_name()
+               << " get_family_name: "
+               << 
block->get_by_position(value_column_idx).column->get_family_name();
+
+    if (block->get_by_position(value_column_idx).column->is_nullable()) {
+        auto array_nullable_column = check_and_get_column<ColumnNullable>(
+                *block->get_by_position(value_column_idx).column);
+        _array_null_map = 
array_nullable_column->get_null_map_column().get_data().data();
+        _array_column =
+                
check_and_get_column<ColumnArray>(array_nullable_column->get_nested_column_ptr());
+    } else {
+        _array_null_map = nullptr;
+        _array_column =
+                
check_and_get_column<ColumnArray>(*block->get_by_position(value_column_idx).column);
+    }
+    if (!_array_column) {
+        return Status::NotSupported("column type " +
+                                    
block->get_by_position(value_column_idx).column->get_name() +
+                                    " not supported now");
+    }
+
+    return Status::OK();
+}
+
+Status VExplodeTableFunction::process_row(size_t row_idx) {
+    DCHECK(row_idx < _array_column->size());
+    _is_current_empty = false;
+    _eos = false;
+
+    if (_array_null_map && _array_null_map[row_idx]) {
+        _is_current_empty = true;
+        _cur_size = 0;
+        _cur_offset = 0;
+        _pos = 0;
+    } else {
+        _cur_size =
+                _array_column->get_offsets()[row_idx] - 
_array_column->get_offsets()[row_idx - 1];

Review comment:
       offsets[-1] always has value 0.
   
   // pod_array.h  
   * The template parameter `pad_left` - always allocate memory before 0th 
element of the array (rounded up to the whole number of elements)
     *  and zero initialize -1th element. It allows to use -1th element that 
will have value 0.
     * This gives performance benefits when converting an array of offsets to 
array of sizes.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to