diff --git a/be/src/exec/olap_scan_node.cpp b/be/src/exec/olap_scan_node.cpp index 29738f582e49f8..83b963992a3ea0 100644 --- a/be/src/exec/olap_scan_node.cpp +++ b/be/src/exec/olap_scan_node.cpp @@ -160,8 +160,6 @@ void OlapScanNode::_init_counter(RuntimeState* state) { // time of node to wait for batch/block queue _olap_wait_batch_queue_timer = ADD_TIMER(_runtime_profile, "BatchQueueWaitTime"); - // time of row cursor to convert batch/block - _row_cursor_convert_timer = ADD_TIMER(_runtime_profile, "RowCursorConvertTime"); } Status OlapScanNode::prepare(RuntimeState* state) { @@ -658,10 +656,10 @@ Status OlapScanNode::build_scan_key() { } Status OlapScanNode::get_hints(const TPaloScanRange& scan_range, int block_row_count, - bool is_begin_include, bool is_end_include, - const std::vector>& scan_key_range, - std::vector>* sub_scan_range, - RuntimeProfile* profile) { + bool is_begin_include, bool is_end_include, + const std::vector>& scan_key_range, + std::vector>* sub_scan_range, + RuntimeProfile* profile) { auto tablet_id = scan_range.tablet_id; int32_t schema_hash = strtoul(scan_range.schema_hash.c_str(), NULL, 10); std::string err; diff --git a/be/src/exec/olap_scan_node.h b/be/src/exec/olap_scan_node.h index b417c6265ee8f0..37f571fa17a02c 100644 --- a/be/src/exec/olap_scan_node.h +++ b/be/src/exec/olap_scan_node.h @@ -34,7 +34,6 @@ #include "runtime/vectorized_row_batch.h" #include "util/progress_updater.h" #include "util/spinlock.h" - #include "vec/exec/volap_scanner.h" namespace doris { @@ -197,10 +196,10 @@ class OlapScanNode : public ScanNode { int conj_idx, int child_idx); static Status get_hints(const TPaloScanRange& scan_range, int block_row_count, - bool is_begin_include, bool is_end_include, - const std::vector>& scan_key_range, - std::vector>* sub_scan_range, - RuntimeProfile* profile); + bool is_begin_include, bool is_end_include, + const std::vector>& scan_key_range, + std::vector>* sub_scan_range, + RuntimeProfile* profile); friend class OlapScanner; friend class doris::vectorized::VOlapScanner; @@ -365,7 +364,6 @@ class OlapScanNode : public ScanNode { RuntimeProfile::Counter* _scanner_wait_worker_timer = nullptr; RuntimeProfile::Counter* _olap_wait_batch_queue_timer = nullptr; - RuntimeProfile::Counter* _row_cursor_convert_timer = nullptr; }; } // namespace doris diff --git a/be/src/exec/olap_scanner.cpp b/be/src/exec/olap_scanner.cpp index ea01a88e596de4..84a43683cb8daa 100644 --- a/be/src/exec/olap_scanner.cpp +++ b/be/src/exec/olap_scanner.cpp @@ -384,7 +384,6 @@ Status OlapScanner::get_batch(RuntimeState* state, RowBatch* batch, bool* eof) { } void OlapScanner::_convert_row_to_tuple(Tuple* tuple) { - SCOPED_TIMER(_parent->_row_cursor_convert_timer); size_t slots_size = _query_slots.size(); for (int i = 0; i < slots_size; ++i) { SlotDescriptor* slot_desc = _query_slots[i]; diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt index 5060055a7fa296..c2e102b2d31c7c 100644 --- a/be/src/vec/CMakeLists.txt +++ b/be/src/vec/CMakeLists.txt @@ -69,6 +69,9 @@ set(VEC_FILES exprs/vcast_expr.cpp functions/abs.cpp functions/comparison.cpp + functions/comparison_less.cpp + functions/comparison_equels.cpp + functions/comparison_greater.cpp functions/function.cpp functions/function_helpers.cpp functions/functions_logical.cpp diff --git a/be/src/vec/aggregate_functions/aggregate_function_null.h b/be/src/vec/aggregate_functions/aggregate_function_null.h index 23415b28d9642c..a4f9501834e712 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_null.h +++ b/be/src/vec/aggregate_functions/aggregate_function_null.h @@ -180,6 +180,26 @@ class AggregateFunctionNullUnary final this->nested_function->add(this->nestedPlace(place), &nested_column, row_num, arena); } } + + void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn** columns, + Arena* arena) const override { + const ColumnNullable* column = assert_cast(columns[0]); + bool has_null = column->has_null(); + + if (has_null) { + for (size_t i = 0; i < batch_size; ++i) { + if (!column->isNullAt(i)) { + this->setFlag(place); + this->add(place, columns, i, arena); + } + } + } else { + this->setFlag(place); + const IColumn* nested_column = &column->getNestedColumn(); + this->nested_function->addBatchSinglePlace(batch_size, this->nestedPlace(place), + &nested_column, arena); + } + } }; template diff --git a/be/src/vec/columns/column_nullable.h b/be/src/vec/columns/column_nullable.h index f08f8b188b0171..c30c29841799ef 100644 --- a/be/src/vec/columns/column_nullable.h +++ b/be/src/vec/columns/column_nullable.h @@ -94,7 +94,8 @@ class ColumnNullable final : public COWHelper { ColumnPtr permute(const Permutation& perm, size_t limit) const override; // ColumnPtr index(const IColumn & indexes, size_t limit) const override; int compareAt(size_t n, size_t m, const IColumn& rhs_, int null_direction_hint) const override; - void getPermutation(bool reverse, size_t limit, int null_direction_hint, Permutation & res) const override; + void getPermutation(bool reverse, size_t limit, int null_direction_hint, + Permutation& res) const override; void reserve(size_t n) override; size_t byteSize() const override; size_t allocatedBytes() const override; @@ -157,6 +158,18 @@ class ColumnNullable final : public COWHelper { /// Check that size of null map equals to size of nested column. void checkConsistency() const; + bool has_null() const { + auto begin = getNullMapData().begin(); + auto end = getNullMapData().end(); + while (begin < end) { + if (*begin != 0) { + return *begin; + } + ++begin; + } + return false; + } + private: WrappedPtr nested_column; WrappedPtr null_map; diff --git a/be/src/vec/exec/volap_scanner.cpp b/be/src/vec/exec/volap_scanner.cpp index b8921e905e2cd9..729246ae4106d9 100644 --- a/be/src/vec/exec/volap_scanner.cpp +++ b/be/src/vec/exec/volap_scanner.cpp @@ -87,7 +87,7 @@ Status VOlapScanner::get_block(RuntimeState* state, vectorized::Block* block, bo slot_desc->col_name())); } VLOG_ROW << "VOlapScanner output rows: " << block->rows(); - + if (_vconjunct_ctx != nullptr) { int result_column_id = -1; _vconjunct_ctx->execute(block, &result_column_id); @@ -99,7 +99,6 @@ Status VOlapScanner::get_block(RuntimeState* state, vectorized::Block* block, bo } void VOlapScanner::_convert_row_to_block(std::vector* columns) { - SCOPED_TIMER(_parent->_row_cursor_convert_timer); size_t slots_size = _query_slots.size(); for (int i = 0; i < slots_size; ++i) { SlotDescriptor* slot_desc = _query_slots[i]; diff --git a/be/src/vec/functions/comparison.cpp b/be/src/vec/functions/comparison.cpp index 98c1d1ed1f847f..0636ed6a89606a 100644 --- a/be/src/vec/functions/comparison.cpp +++ b/be/src/vec/functions/comparison.cpp @@ -15,23 +15,16 @@ // specific language governing permissions and limitations // under the License. -#include "vec/functions/functions_comparison.h" #include "vec/functions/simple_function_factory.h" namespace doris::vectorized { -using FunctionGreater = FunctionComparison; -using FunctionGreaterOrEquals = FunctionComparison; -using FunctionLess = FunctionComparison; -using FunctionLessOrEquals = FunctionComparison; -using FunctionEquals = FunctionComparison; -using FunctionNotEquals = FunctionComparison; +void registerFunctionComparisonEquals(SimpleFunctionFactory& factory); +void registerFunctionComparisonGreater(SimpleFunctionFactory& factory); +void registerFunctionComparisonLess(SimpleFunctionFactory& factory); void registerFunctionComparison(SimpleFunctionFactory& factory) { - factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); + registerFunctionComparisonEquals(factory); + registerFunctionComparisonGreater(factory); + registerFunctionComparisonLess(factory); } } // namespace doris::vectorized diff --git a/be/src/vec/functions/comparison_equels.cpp b/be/src/vec/functions/comparison_equels.cpp new file mode 100644 index 00000000000000..973bc8c34600f6 --- /dev/null +++ b/be/src/vec/functions/comparison_equels.cpp @@ -0,0 +1,29 @@ +// 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/functions/functions_comparison.h" +#include "vec/functions/simple_function_factory.h" + +namespace doris::vectorized { +using FunctionEquals = FunctionComparison; +using FunctionNotEquals = FunctionComparison; + +void registerFunctionComparisonEquals(SimpleFunctionFactory& factory) { + factory.registerFunction(); + factory.registerFunction(); +} +} // namespace doris::vectorized diff --git a/be/src/vec/functions/comparison_greater.cpp b/be/src/vec/functions/comparison_greater.cpp new file mode 100644 index 00000000000000..f6d88ae0f9d837 --- /dev/null +++ b/be/src/vec/functions/comparison_greater.cpp @@ -0,0 +1,29 @@ +// 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/functions/functions_comparison.h" +#include "vec/functions/simple_function_factory.h" + +namespace doris::vectorized { +using FunctionGreater = FunctionComparison; +using FunctionGreaterOrEquals = FunctionComparison; + +void registerFunctionComparisonGreater(SimpleFunctionFactory& factory) { + factory.registerFunction(); + factory.registerFunction(); +} +} // namespace doris::vectorized diff --git a/be/src/vec/functions/comparison_less.cpp b/be/src/vec/functions/comparison_less.cpp new file mode 100644 index 00000000000000..2c8a4f78ac390d --- /dev/null +++ b/be/src/vec/functions/comparison_less.cpp @@ -0,0 +1,29 @@ +// 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/functions/functions_comparison.h" +#include "vec/functions/simple_function_factory.h" + +namespace doris::vectorized { +using FunctionLess = FunctionComparison; +using FunctionLessOrEquals = FunctionComparison; + +void registerFunctionComparisonLess(SimpleFunctionFactory& factory) { + factory.registerFunction(); + factory.registerFunction(); +} +} // namespace doris::vectorized