[CodeFormat] Clang-format cpp sources (#4965)
Clang-format all c++ source files.
This commit is contained in:
@ -26,29 +26,26 @@
|
||||
#include "exec/es/es_scan_reader.h"
|
||||
#include "exec/es/es_scroll_query.h"
|
||||
#include "exprs/expr.h"
|
||||
#include "runtime/runtime_state.h"
|
||||
#include "runtime/row_batch.h"
|
||||
#include "runtime/dpp_sink_internal.h"
|
||||
#include "runtime/row_batch.h"
|
||||
#include "runtime/runtime_state.h"
|
||||
#include "service/backend_options.h"
|
||||
#include "util/runtime_profile.h"
|
||||
|
||||
namespace doris {
|
||||
|
||||
EsHttpScanNode::EsHttpScanNode(
|
||||
ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs) :
|
||||
ScanNode(pool, tnode, descs),
|
||||
_tuple_id(tnode.es_scan_node.tuple_id),
|
||||
_runtime_state(nullptr),
|
||||
_tuple_desc(nullptr),
|
||||
_num_running_scanners(0),
|
||||
_scan_finished(false),
|
||||
_eos(false),
|
||||
_max_buffered_batches(1024),
|
||||
_wait_scanner_timer(nullptr) {
|
||||
}
|
||||
EsHttpScanNode::EsHttpScanNode(ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs)
|
||||
: ScanNode(pool, tnode, descs),
|
||||
_tuple_id(tnode.es_scan_node.tuple_id),
|
||||
_runtime_state(nullptr),
|
||||
_tuple_desc(nullptr),
|
||||
_num_running_scanners(0),
|
||||
_scan_finished(false),
|
||||
_eos(false),
|
||||
_max_buffered_batches(1024),
|
||||
_wait_scanner_timer(nullptr) {}
|
||||
|
||||
EsHttpScanNode::~EsHttpScanNode() {
|
||||
}
|
||||
EsHttpScanNode::~EsHttpScanNode() {}
|
||||
|
||||
Status EsHttpScanNode::init(const TPlanNode& tnode, RuntimeState* state) {
|
||||
RETURN_IF_ERROR(ScanNode::init(tnode));
|
||||
@ -91,12 +88,11 @@ Status EsHttpScanNode::prepare(RuntimeState* state) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
// build predicate
|
||||
// build predicate
|
||||
Status EsHttpScanNode::build_conjuncts_list() {
|
||||
Status status = Status::OK();
|
||||
for (int i = 0; i < _conjunct_ctxs.size(); ++i) {
|
||||
EsPredicate* predicate = _pool->add(
|
||||
new EsPredicate(_conjunct_ctxs[i], _tuple_desc, _pool));
|
||||
EsPredicate* predicate = _pool->add(new EsPredicate(_conjunct_ctxs[i], _tuple_desc, _pool));
|
||||
predicate->set_field_context(_fields_context);
|
||||
status = predicate->build_disjuncts_list();
|
||||
if (status.ok()) {
|
||||
@ -137,8 +133,8 @@ Status EsHttpScanNode::open(RuntimeState* state) {
|
||||
std::vector<bool> list;
|
||||
BooleanQueryBuilder::validate(_predicates, &list);
|
||||
DCHECK(list.size() == _predicate_to_conjunct.size());
|
||||
for(int i = list.size() - 1; i >= 0; i--) {
|
||||
if(!list[i]) {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (!list[i]) {
|
||||
_predicate_to_conjunct.erase(_predicate_to_conjunct.begin() + i);
|
||||
_predicates.erase(_predicates.begin() + i);
|
||||
}
|
||||
@ -164,15 +160,15 @@ Status EsHttpScanNode::start_scanners() {
|
||||
|
||||
_scanners_status.resize(_scan_ranges.size());
|
||||
for (int i = 0; i < _scan_ranges.size(); i++) {
|
||||
_scanner_threads.emplace_back(&EsHttpScanNode::scanner_worker, this, i,
|
||||
_scan_ranges.size(), std::ref(_scanners_status[i]));
|
||||
_scanner_threads.emplace_back(&EsHttpScanNode::scanner_worker, this, i, _scan_ranges.size(),
|
||||
std::ref(_scanners_status[i]));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status EsHttpScanNode::collect_scanners_status() {
|
||||
// NOTE. if open() was called, but set_range() was NOT called for some reason.
|
||||
// then close() was called.
|
||||
// then close() was called.
|
||||
// there would cause a core because _scanners_status's iterator was in [0, _scan_ranges) other than [0, _scanners_status)
|
||||
// it is said that the fragment-call-frame is calling scan-node in this way....
|
||||
// in my options, it's better fixed in fragment-call-frame. e.g. call close() according the return value of open()
|
||||
@ -183,8 +179,7 @@ Status EsHttpScanNode::collect_scanners_status() {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status EsHttpScanNode::get_next(RuntimeState* state, RowBatch* row_batch,
|
||||
bool* eos) {
|
||||
Status EsHttpScanNode::get_next(RuntimeState* state, RowBatch* row_batch, bool* eos) {
|
||||
SCOPED_TIMER(_runtime_profile->total_time_counter());
|
||||
if (state->is_cancelled()) {
|
||||
std::unique_lock<std::mutex> l(_batch_queue_lock);
|
||||
@ -206,10 +201,8 @@ Status EsHttpScanNode::get_next(RuntimeState* state, RowBatch* row_batch,
|
||||
std::shared_ptr<RowBatch> scanner_batch;
|
||||
{
|
||||
std::unique_lock<std::mutex> l(_batch_queue_lock);
|
||||
while (_process_status.ok() &&
|
||||
!_runtime_state->is_cancelled() &&
|
||||
_num_running_scanners > 0 &&
|
||||
_batch_queue.empty()) {
|
||||
while (_process_status.ok() && !_runtime_state->is_cancelled() &&
|
||||
_num_running_scanners > 0 && _batch_queue.empty()) {
|
||||
SCOPED_TIMER(_wait_scanner_timer);
|
||||
_queue_reader_cond.wait_for(l, std::chrono::seconds(1));
|
||||
}
|
||||
@ -263,7 +256,7 @@ Status EsHttpScanNode::get_next(RuntimeState* state, RowBatch* row_batch,
|
||||
for (int i = 0; i < row_batch->num_rows(); ++i) {
|
||||
TupleRow* row = row_batch->get_row(i);
|
||||
VLOG_ROW << "EsHttpScanNode output row: "
|
||||
<< Tuple::to_string(row->get_tuple(0), *_tuple_desc);
|
||||
<< Tuple::to_string(row->get_tuple(0), *_tuple_desc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,8 +264,6 @@ Status EsHttpScanNode::get_next(RuntimeState* state, RowBatch* row_batch,
|
||||
}
|
||||
|
||||
Status EsHttpScanNode::close(RuntimeState* state) {
|
||||
|
||||
|
||||
if (is_closed()) {
|
||||
return Status::OK();
|
||||
}
|
||||
@ -307,17 +298,16 @@ void EsHttpScanNode::debug_string(int ident_level, std::stringstream* out) const
|
||||
(*out) << "EsHttpScanNode";
|
||||
}
|
||||
|
||||
Status EsHttpScanNode::scanner_scan(
|
||||
std::unique_ptr<EsHttpScanner> scanner,
|
||||
const std::vector<ExprContext*>& conjunct_ctxs,
|
||||
EsScanCounter* counter) {
|
||||
Status EsHttpScanNode::scanner_scan(std::unique_ptr<EsHttpScanner> scanner,
|
||||
const std::vector<ExprContext*>& conjunct_ctxs,
|
||||
EsScanCounter* counter) {
|
||||
RETURN_IF_ERROR(scanner->open());
|
||||
bool scanner_eof = false;
|
||||
|
||||
|
||||
while (!scanner_eof) {
|
||||
// Fill one row batch
|
||||
std::shared_ptr<RowBatch> row_batch(
|
||||
new RowBatch(row_desc(), _runtime_state->batch_size(), mem_tracker().get()));
|
||||
new RowBatch(row_desc(), _runtime_state->batch_size(), mem_tracker().get()));
|
||||
|
||||
// create new tuple buffer for row_batch
|
||||
MemPool* tuple_pool = row_batch->tuple_data_pool();
|
||||
@ -367,8 +357,7 @@ Status EsHttpScanNode::scanner_scan(
|
||||
// Row batch has been filled, push this to the queue
|
||||
if (row_batch->num_rows() > 0) {
|
||||
std::unique_lock<std::mutex> l(_batch_queue_lock);
|
||||
while (_process_status.ok() &&
|
||||
!_scan_finished.load() &&
|
||||
while (_process_status.ok() && !_scan_finished.load() &&
|
||||
!_runtime_state->is_cancelled() &&
|
||||
_batch_queue.size() >= _max_buffered_batches) {
|
||||
_queue_writer_cond.wait_for(l, std::chrono::seconds(1));
|
||||
@ -388,7 +377,7 @@ Status EsHttpScanNode::scanner_scan(
|
||||
// Queue size Must be smaller than _max_buffered_batches
|
||||
_batch_queue.push_back(row_batch);
|
||||
|
||||
// Notify reader to
|
||||
// Notify reader to
|
||||
_queue_reader_cond.notify_one();
|
||||
}
|
||||
}
|
||||
@ -398,19 +387,18 @@ Status EsHttpScanNode::scanner_scan(
|
||||
|
||||
// Prefer to the local host
|
||||
static std::string get_host_port(const std::vector<TNetworkAddress>& es_hosts) {
|
||||
|
||||
std::string host_port;
|
||||
std::string localhost = BackendOptions::get_localhost();
|
||||
|
||||
TNetworkAddress host = es_hosts[0];
|
||||
for (auto& es_host : es_hosts) {
|
||||
if (es_host.hostname == localhost) {
|
||||
host = es_host;
|
||||
break;
|
||||
host = es_host;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
host_port = host.hostname;
|
||||
host_port = host.hostname;
|
||||
host_port += ":";
|
||||
host_port += std::to_string(host.port);
|
||||
return host_port;
|
||||
@ -420,15 +408,13 @@ void EsHttpScanNode::scanner_worker(int start_idx, int length, std::promise<Stat
|
||||
// Clone expr context
|
||||
std::vector<ExprContext*> scanner_expr_ctxs;
|
||||
DCHECK(start_idx < length);
|
||||
auto status = Expr::clone_if_not_exists(_conjunct_ctxs, _runtime_state,
|
||||
&scanner_expr_ctxs);
|
||||
auto status = Expr::clone_if_not_exists(_conjunct_ctxs, _runtime_state, &scanner_expr_ctxs);
|
||||
if (!status.ok()) {
|
||||
LOG(WARNING) << "Clone conjuncts failed.";
|
||||
}
|
||||
|
||||
EsScanCounter counter;
|
||||
const TEsScanRange& es_scan_range =
|
||||
_scan_ranges[start_idx].scan_range.es_scan_range;
|
||||
const TEsScanRange& es_scan_range = _scan_ranges[start_idx].scan_range.es_scan_range;
|
||||
|
||||
// Collect the information from scan range to properties
|
||||
std::map<std::string, std::string> properties(_properties);
|
||||
@ -446,22 +432,20 @@ void EsHttpScanNode::scanner_worker(int start_idx, int length, std::promise<Stat
|
||||
}
|
||||
|
||||
bool doc_value_mode = false;
|
||||
properties[ESScanReader::KEY_QUERY]
|
||||
= ESScrollQueryBuilder::build(properties, _column_names, _predicates, _docvalue_context, &doc_value_mode);
|
||||
|
||||
properties[ESScanReader::KEY_QUERY] = ESScrollQueryBuilder::build(
|
||||
properties, _column_names, _predicates, _docvalue_context, &doc_value_mode);
|
||||
|
||||
// start scanner to scan
|
||||
std::unique_ptr<EsHttpScanner> scanner(new EsHttpScanner(
|
||||
_runtime_state, runtime_profile(), _tuple_id,
|
||||
properties, scanner_expr_ctxs, &counter, doc_value_mode));
|
||||
std::unique_ptr<EsHttpScanner> scanner(
|
||||
new EsHttpScanner(_runtime_state, runtime_profile(), _tuple_id, properties,
|
||||
scanner_expr_ctxs, &counter, doc_value_mode));
|
||||
status = scanner_scan(std::move(scanner), scanner_expr_ctxs, &counter);
|
||||
if (!status.ok()) {
|
||||
LOG(WARNING) << "Scanner[" << start_idx << "] process failed. status="
|
||||
<< status.get_error_msg();
|
||||
LOG(WARNING) << "Scanner[" << start_idx
|
||||
<< "] process failed. status=" << status.get_error_msg();
|
||||
}
|
||||
|
||||
|
||||
// scanner is going to finish
|
||||
// scanner is going to finish
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_batch_queue_lock);
|
||||
if (!status.ok()) {
|
||||
@ -478,4 +462,4 @@ void EsHttpScanNode::scanner_worker(int start_idx, int length, std::promise<Stat
|
||||
|
||||
p_status.set_value(status);
|
||||
}
|
||||
}
|
||||
} // namespace doris
|
||||
|
||||
Reference in New Issue
Block a user