Add tracepoint of random batch_size/skip_bits for table scan
This commit is contained in:
1
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
1
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
@ -809,6 +809,7 @@ class EventTable
|
|||||||
EN_DISABLE_SORTKEY_SEPARATELY = 2208,
|
EN_DISABLE_SORTKEY_SEPARATELY = 2208,
|
||||||
EN_ENABLE_VECTOR_IN = 2209,
|
EN_ENABLE_VECTOR_IN = 2209,
|
||||||
EN_SQL_MEMORY_MRG_OPTION = 2210,
|
EN_SQL_MEMORY_MRG_OPTION = 2210,
|
||||||
|
EN_ENABLE_RANDOM_TSC = 2211,
|
||||||
// WR && ASH
|
// WR && ASH
|
||||||
EN_CLOSE_ASH = 2301,
|
EN_CLOSE_ASH = 2301,
|
||||||
EN_DISABLE_HASH_BASE_DISTINCT = 2302,
|
EN_DISABLE_HASH_BASE_DISTINCT = 2302,
|
||||||
|
|||||||
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
#define USING_LOG_PREFIX SQL_ENG
|
#define USING_LOG_PREFIX SQL_ENG
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "ob_table_scan_op.h"
|
#include "ob_table_scan_op.h"
|
||||||
#include "sql/engine/ob_exec_context.h"
|
#include "sql/engine/ob_exec_context.h"
|
||||||
#include "sql/executor/ob_task_spliter.h"
|
#include "sql/executor/ob_task_spliter.h"
|
||||||
@ -2071,6 +2074,14 @@ int ObTableScanOp::inner_get_next_row_for_tsc()
|
|||||||
int ObTableScanOp::inner_get_next_batch(const int64_t max_row_cnt)
|
int ObTableScanOp::inner_get_next_batch(const int64_t max_row_cnt)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
int tmp_ret = OB_E(EventTable::EN_ENABLE_RANDOM_TSC) OB_SUCCESS;
|
||||||
|
bool enable_random_output = (tmp_ret != OB_SUCCESS);
|
||||||
|
|
||||||
|
int64_t rand_row_cnt = max_row_cnt;
|
||||||
|
int64_t rand_append_bits = 0;
|
||||||
|
if (enable_random_output && max_row_cnt > 1) {
|
||||||
|
gen_rand_size_and_skip_bits(max_row_cnt, rand_row_cnt, rand_append_bits);
|
||||||
|
}
|
||||||
if (OB_SUCC(ret) && MY_SPEC.is_global_index_back()) {
|
if (OB_SUCC(ret) && MY_SPEC.is_global_index_back()) {
|
||||||
int64_t count = 0;
|
int64_t count = 0;
|
||||||
if (OB_ISNULL(global_index_lookup_op_)) {
|
if (OB_ISNULL(global_index_lookup_op_)) {
|
||||||
@ -2079,18 +2090,23 @@ int ObTableScanOp::inner_get_next_batch(const int64_t max_row_cnt)
|
|||||||
} else {
|
} else {
|
||||||
global_index_lookup_op_->get_brs().size_ = brs_.size_ ;
|
global_index_lookup_op_->get_brs().size_ = brs_.size_ ;
|
||||||
global_index_lookup_op_->get_brs().end_ = brs_.end_;
|
global_index_lookup_op_->get_brs().end_ = brs_.end_;
|
||||||
if (OB_FAIL(global_index_lookup_op_->get_next_rows(count, max_row_cnt))) {
|
if (OB_FAIL(global_index_lookup_op_->get_next_rows(count, rand_row_cnt))) {
|
||||||
LOG_WARN("failed to get next rows",K(ret), K(max_row_cnt));
|
LOG_WARN("failed to get next rows",K(ret), K(rand_row_cnt));
|
||||||
} else {
|
} else {
|
||||||
brs_.size_ = global_index_lookup_op_->get_brs().size_;
|
brs_.size_ = global_index_lookup_op_->get_brs().size_;
|
||||||
brs_.end_ = global_index_lookup_op_->get_brs().end_;
|
brs_.end_ = global_index_lookup_op_->get_brs().end_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (OB_FAIL(inner_get_next_batch_for_tsc(max_row_cnt))) {
|
if (OB_FAIL(inner_get_next_batch_for_tsc(rand_row_cnt))) {
|
||||||
LOG_WARN("failed to get next row",K(ret));
|
LOG_WARN("failed to get next row",K(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret) && enable_random_output && !brs_.end_
|
||||||
|
&& brs_.skip_->accumulate_bit_cnt(brs_.size_) == 0) {
|
||||||
|
adjust_rand_output_brs(rand_append_bits);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int ObTableScanOp::inner_get_next_batch_for_tsc(const int64_t max_row_cnt)
|
int ObTableScanOp::inner_get_next_batch_for_tsc(const int64_t max_row_cnt)
|
||||||
@ -3094,12 +3110,38 @@ int ObTableScanOp::fill_generated_cellid_mbr(const ObObj &cellid, const ObObj &m
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObGlobalIndexLookupOpImpl::ObGlobalIndexLookupOpImpl(ObTableScanOp *table_scan_op)
|
void ObTableScanOp::gen_rand_size_and_skip_bits(const int64_t batch_size, int64_t &rand_size,
|
||||||
: ObIndexLookupOpImpl(GLOBAL_INDEX, 10000 /*default_batch_row_count*/),
|
int64_t &skip_bits)
|
||||||
table_scan_op_(table_scan_op),
|
{
|
||||||
das_ref_(table_scan_op_->get_eval_ctx(), table_scan_op_->get_exec_ctx()),
|
rand_size = batch_size;
|
||||||
lookup_result_(),
|
skip_bits = 0;
|
||||||
lookup_memctx_()
|
if (batch_size > 1) {
|
||||||
|
std::default_random_engine rd;
|
||||||
|
rd.seed(std::random_device()());
|
||||||
|
std::uniform_int_distribution<int64_t> irand(0, batch_size/2);
|
||||||
|
skip_bits = irand(rd);
|
||||||
|
if (skip_bits <= 0) {
|
||||||
|
skip_bits = 1;
|
||||||
|
}
|
||||||
|
rand_size = batch_size - skip_bits;
|
||||||
|
LOG_TRACE("random batch size", K(rand_size), K(skip_bits));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableScanOp::adjust_rand_output_brs(const int64_t rand_append_bits)
|
||||||
|
{
|
||||||
|
LOG_TRACE("random output", K(brs_.size_), K(rand_append_bits));
|
||||||
|
int64_t output_size = brs_.size_ + rand_append_bits;
|
||||||
|
brs_.skip_->set_all(brs_.size_, output_size);
|
||||||
|
brs_.size_ = output_size;
|
||||||
|
brs_.all_rows_active_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObGlobalIndexLookupOpImpl::ObGlobalIndexLookupOpImpl(ObTableScanOp *table_scan_op) :
|
||||||
|
ObIndexLookupOpImpl(GLOBAL_INDEX, 10000 /*default_batch_row_count*/),
|
||||||
|
table_scan_op_(table_scan_op),
|
||||||
|
das_ref_(table_scan_op_->get_eval_ctx(), table_scan_op_->get_exec_ctx()), lookup_result_(),
|
||||||
|
lookup_memctx_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -596,6 +596,10 @@ private:
|
|||||||
int inner_get_next_row_for_tsc();
|
int inner_get_next_row_for_tsc();
|
||||||
int inner_get_next_batch_for_tsc(const int64_t max_row_cnt);
|
int inner_get_next_batch_for_tsc(const int64_t max_row_cnt);
|
||||||
int inner_rescan_for_tsc();
|
int inner_rescan_for_tsc();
|
||||||
|
|
||||||
|
void gen_rand_size_and_skip_bits(const int64_t batch_size, int64_t &rand_size, int64_t &skip_bits);
|
||||||
|
|
||||||
|
void adjust_rand_output_brs(const int64_t rand_skip_bits);
|
||||||
protected:
|
protected:
|
||||||
ObDASRef das_ref_;
|
ObDASRef das_ref_;
|
||||||
DASOpResultIter scan_result_;
|
DASOpResultIter scan_result_;
|
||||||
|
|||||||
Reference in New Issue
Block a user