You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2020/11/01 01:12:38 UTC
[incubator-doris] branch master updated: [Refactor] Refactor olap
scan node code (#4823)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new b1c1ffd [Refactor] Refactor olap scan node code (#4823)
b1c1ffd is described below
commit b1c1ffda4a0d5ff2f0be4f9d2f25997a31537ea8
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Sun Nov 1 09:12:23 2020 +0800
[Refactor] Refactor olap scan node code (#4823)
1. Remove meaningless code in Doris
2. Replace string copy by string reference
3. Simplified the implementation of some functions
---
be/src/exec/olap_common.h | 30 ++++++++----------------------
be/src/exec/olap_scan_node.cpp | 17 +++++++----------
be/src/exec/olap_scan_node.h | 8 ++++----
be/src/exec/olap_scanner.cpp | 5 -----
4 files changed, 19 insertions(+), 41 deletions(-)
diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h
index 8eda626..9d4c7cf 100644
--- a/be/src/exec/olap_common.h
+++ b/be/src/exec/olap_common.h
@@ -115,13 +115,13 @@ public:
return _fixed_values.size();
}
- std::string to_olap_filter(std::list<TCondition> &filters) {
+ void to_olap_filter(std::list<TCondition> &filters) {
if (is_fixed_value_range()) {
TCondition condition;
condition.__set_column_name(_column_name);
condition.__set_condition_op("*=");
- for (auto value : _fixed_values) {
+ for (const auto& value : _fixed_values) {
condition.condition_values.push_back(cast_to_string(value));
}
@@ -151,8 +151,6 @@ public:
filters.push_back(high);
}
}
-
- return "";
}
void clear() {
@@ -635,9 +633,9 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range, int32_t max_sca
//for this case, we need to add null value to fixed values
bool has_converted = false;
+ auto scan_keys_size = _begin_scan_keys.empty() ? 1 : _begin_scan_keys.size();
if (range.is_fixed_value_range()) {
- if ((_begin_scan_keys.empty() && range.get_fixed_value_size() > max_scan_key_num)
- || range.get_fixed_value_size() * _begin_scan_keys.size() > max_scan_key_num) {
+ if (range.get_fixed_value_size() * scan_keys_size > max_scan_key_num) {
if (range.is_range_value_convertible()) {
range.convert_to_range_value();
} else {
@@ -646,23 +644,11 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range, int32_t max_sca
}
} else {
if (range.is_fixed_value_convertible() && _is_convertible) {
- if (_begin_scan_keys.empty()) {
- if (range.get_convertible_fixed_value_size() < max_scan_key_num) {
- if (range.is_low_value_mininum() && range.is_high_value_maximum()) {
- has_converted = true;
- }
-
- range.convert_to_fixed_value();
- }
- } else {
- if (range.get_convertible_fixed_value_size() * _begin_scan_keys.size()
- < max_scan_key_num) {
- if (range.is_low_value_mininum() && range.is_high_value_maximum()) {
- has_converted = true;
- }
-
- range.convert_to_fixed_value();
+ if (range.get_convertible_fixed_value_size() * scan_keys_size < max_scan_key_num) {
+ if (range.is_low_value_mininum() && range.is_high_value_maximum()) {
+ has_converted = true;
}
+ range.convert_to_fixed_value();
}
}
}
diff --git a/be/src/exec/olap_scan_node.cpp b/be/src/exec/olap_scan_node.cpp
index 831304f..bcd6e0e 100644
--- a/be/src/exec/olap_scan_node.cpp
+++ b/be/src/exec/olap_scan_node.cpp
@@ -368,11 +368,11 @@ Status OlapScanNode::start_scan(RuntimeState* state) {
RETURN_IF_ERROR(build_olap_filters());
VLOG(1) << "BuildScanKey";
- // 4. Using `Key Column`'s ColumnValueRange to split ScanRange to several `Sub ScanRange`
+ // 3. Using `Key Column`'s ColumnValueRange to split ScanRange to several `Sub ScanRange`
RETURN_IF_ERROR(build_scan_key());
VLOG(1) << "StartScanThread";
- // 6. Start multi thread to read several `Sub Sub ScanRange`
+ // 4. Start multi thread to read several `Sub Sub ScanRange`
RETURN_IF_ERROR(start_scan_thread(state));
return Status::OK();
@@ -502,7 +502,7 @@ Status OlapScanNode::normalize_conjuncts() {
Status OlapScanNode::build_olap_filters() {
_olap_filter.clear();
- for (auto iter : _column_value_ranges) {
+ for (auto& iter : _column_value_ranges) {
ToOlapFilterVisitor visitor;
boost::variant<std::list<TCondition>> filters;
boost::apply_visitor(visitor, iter.second, filters);
@@ -512,7 +512,7 @@ Status OlapScanNode::build_olap_filters() {
continue;
}
- for (auto filter : new_filters) {
+ for (const auto& filter : new_filters) {
_olap_filter.push_back(filter);
}
}
@@ -526,13 +526,10 @@ Status OlapScanNode::build_scan_key() {
DCHECK(column_types.size() == column_names.size());
// 1. construct scan key except last olap engine short key
- int column_index = 0;
_scan_keys.set_is_convertible(limit() == -1);
- for (; column_index < column_names.size() && !_scan_keys.has_range_value(); ++column_index) {
- std::map<std::string, ColumnValueRangeType>::iterator column_range_iter
- = _column_value_ranges.find(column_names[column_index]);
-
+ for (int column_index = 0; column_index < column_names.size() && !_scan_keys.has_range_value(); ++column_index) {
+ auto column_range_iter = _column_value_ranges.find(column_names[column_index]);
if (_column_value_ranges.end() == column_range_iter) {
break;
}
@@ -956,7 +953,7 @@ Status OlapScanNode::normalize_in_and_eq_predicate(SlotDescriptor* slot, ColumnV
return Status::OK();
}
-void OlapScanNode::construct_is_null_pred_in_where_pred(Expr* expr, SlotDescriptor* slot, std::string is_null_str) {
+void OlapScanNode::construct_is_null_pred_in_where_pred(Expr* expr, SlotDescriptor* slot, const std::string& is_null_str) {
if (expr->node_type() != TExprNodeType::SLOT_REF) {
return;
}
diff --git a/be/src/exec/olap_scan_node.h b/be/src/exec/olap_scan_node.h
index f15217d..fd5f904 100644
--- a/be/src/exec/olap_scan_node.h
+++ b/be/src/exec/olap_scan_node.h
@@ -95,11 +95,11 @@ protected:
typedef boost::variant<std::list<std::string>> string_list;
- class ToOlapFilterVisitor : public boost::static_visitor<std::string> {
+ class ToOlapFilterVisitor : public boost::static_visitor<void> {
public:
template<class T, class P>
- std::string operator()(T& v, P& v2) const {
- return v.to_olap_filter(v2);
+ void operator()(T& v, P& v2) const {
+ v.to_olap_filter(v2);
}
};
@@ -159,7 +159,7 @@ protected:
private:
void _init_counter(RuntimeState* state);
- void construct_is_null_pred_in_where_pred(Expr* expr, SlotDescriptor* slot, std::string is_null_str);
+ void construct_is_null_pred_in_where_pred(Expr* expr, SlotDescriptor* slot, const std::string& is_null_str);
friend class OlapScanner;
diff --git a/be/src/exec/olap_scanner.cpp b/be/src/exec/olap_scanner.cpp
index 6044c92..68062e6 100644
--- a/be/src/exec/olap_scanner.cpp
+++ b/be/src/exec/olap_scanner.cpp
@@ -34,11 +34,6 @@
namespace doris {
-static const std::string SCANNER_THREAD_TOTAL_WALLCLOCK_TIME =
- "ScannerThreadsTotalWallClockTime";
-static const std::string MATERIALIZE_TUPLE_TIMER =
- "MaterializeTupleTime(*)";
-
OlapScanner::OlapScanner(
RuntimeState* runtime_state,
OlapScanNode* parent,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org