Fix sample rescan wrong index tree height
This commit is contained in:
@ -1261,7 +1261,7 @@ int ObIndexTreeMultiPassPrefetcher<DATA_PREFETCH_DEPTH, INDEX_PREFETCH_DEPTH>::p
|
||||
} else if (nullptr != sample_executor
|
||||
&& OB_FAIL(sample_executor->check_sample_block(block_info, cur_level_ + 1, tree_handles_[cur_level_].fetch_idx_,
|
||||
micro_data_prefetch_idx_, iter_param_->has_lob_column_out()))) {
|
||||
LOG_WARN("Failed to check if can skip micro block in sample", K(ret), K_(cur_level), K(block_info));
|
||||
LOG_WARN("Failed to check if can skip micro block in sample", K(ret), K_(cur_level), K(block_info), KPC(sample_executor));
|
||||
} else if (nullptr != sstable_index_filter
|
||||
&& can_index_filter_skip(block_info, sample_executor)
|
||||
&& OB_FAIL(sstable_index_filter->check_range(iter_param_->read_info_,
|
||||
@ -1724,7 +1724,7 @@ int ObIndexTreeMultiPassPrefetcher<DATA_PREFETCH_DEPTH, INDEX_PREFETCH_DEPTH>::O
|
||||
} else if (nullptr != sample_executor
|
||||
&& OB_FAIL(sample_executor->check_sample_block(index_info, level, parent.fetch_idx_,
|
||||
prefetch_idx_ + 1, prefetcher.iter_param_->has_lob_column_out()))) {
|
||||
LOG_WARN("Failed to check if can skip perfetch micro block in sample", K(ret), K(level), K(index_info));
|
||||
LOG_WARN("Failed to check if can skip perfetch micro block in sample", K(ret), K(level), K(index_info), KPC(sample_executor));
|
||||
} else if (nullptr != sstable_index_filter
|
||||
&& prefetcher.can_index_filter_skip(index_info, sample_executor)
|
||||
&& OB_FAIL(sstable_index_filter->check_range(prefetcher.iter_param_->read_info_, index_info,
|
||||
|
@ -463,9 +463,9 @@ public:
|
||||
{
|
||||
return border_rowkey_;
|
||||
}
|
||||
OB_INLINE int16_t get_tree_handle_cap() const
|
||||
OB_INLINE int16_t get_index_tree_height() const
|
||||
{
|
||||
return tree_handle_cap_;
|
||||
return index_tree_height_;
|
||||
}
|
||||
OB_INLINE int32_t get_index_prefetch_depth() const
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ ObSampleFilterExecutor::ObSampleFilterExecutor(
|
||||
block_statistic_(),
|
||||
index_prefetch_depth_(0),
|
||||
data_prefetch_depth_(0),
|
||||
row_id_handle_cap_(0),
|
||||
index_tree_height_(0),
|
||||
filter_state_(false),
|
||||
is_reverse_scan_(false),
|
||||
is_inited_(false)
|
||||
@ -62,7 +62,7 @@ void ObSampleFilterExecutor::reset()
|
||||
boundary_point_ = -1;
|
||||
interval_infos_.reset();
|
||||
reset_row_id_handle();
|
||||
row_id_handle_cap_ = 0;
|
||||
index_tree_height_ = 0;
|
||||
index_prefetch_depth_ = 0;
|
||||
data_prefetch_depth_ = 0;
|
||||
allocator_ = nullptr;
|
||||
@ -125,7 +125,7 @@ int ObSampleFilterExecutor::init(
|
||||
reset_pushdown_ranges();
|
||||
filter_state_ = false;
|
||||
boundary_point_ = -1;
|
||||
row_id_handle_cap_ = 0;
|
||||
index_tree_height_ = 0;
|
||||
index_prefetch_depth_ = 0;
|
||||
data_prefetch_depth_ = 0;
|
||||
data_row_id_handle_ = nullptr;
|
||||
@ -175,7 +175,7 @@ int ObSampleFilterExecutor::build_row_id_handle(
|
||||
} else if (nullptr != index_row_id_handle_) {
|
||||
MEMSET(static_cast<void *>(index_row_id_handle_), 0, sizeof(ObIndexRowIdHandle) * index_handle_max_cnt);
|
||||
MEMSET(static_cast<void *>(data_row_id_handle_), 0, sizeof(int64_t) * data_handle_max_cnt);
|
||||
row_id_handle_cap_ = height;
|
||||
index_tree_height_ = height;
|
||||
index_prefetch_depth_ = index_handle_cnt;
|
||||
data_prefetch_depth_ = data_handle_cnt;
|
||||
} else if (OB_ISNULL(buf = allocator_->alloc(sizeof(ObIndexRowIdHandle) * index_handle_max_cnt + sizeof(int64_t) * data_handle_max_cnt))) {
|
||||
@ -186,10 +186,10 @@ int ObSampleFilterExecutor::build_row_id_handle(
|
||||
data_row_id_handle_ = reinterpret_cast<int64_t *>(index_row_id_handle_ + index_handle_max_cnt);
|
||||
MEMSET(static_cast<void *>(index_row_id_handle_), 0, sizeof(ObIndexRowIdHandle) * index_handle_max_cnt);
|
||||
MEMSET(static_cast<void *>(data_row_id_handle_), 0, sizeof(int64_t) * data_handle_max_cnt);
|
||||
row_id_handle_cap_ = height;
|
||||
index_tree_height_ = height;
|
||||
index_prefetch_depth_ = index_handle_cnt;
|
||||
data_prefetch_depth_ = data_handle_cnt;
|
||||
LOG_DEBUG("wenye debug, build row id handle", K_(row_id_handle_cap), K_(index_prefetch_depth), K_(data_prefetch_depth),
|
||||
LOG_DEBUG("wenye debug, build row id handle", K_(index_tree_height), K_(index_prefetch_depth), K_(data_prefetch_depth),
|
||||
K(index_handle_max_cnt), K(data_handle_max_cnt));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -314,7 +314,7 @@ int ObSampleFilterExecutor::check_sample_block(
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("The ObRowSampleFilter has not been inited", K(ret));
|
||||
} else if (OB_UNLIKELY(level < 0 || level > row_id_handle_cap_ || parent_fetch_idx < 0 || child_prefetch_idx < 0)) {
|
||||
} else if (OB_UNLIKELY(level < 0 || level > index_tree_height_ || parent_fetch_idx < 0 || child_prefetch_idx < 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid argument to check sample block", K(ret), K(level), K(parent_fetch_idx), K(child_prefetch_idx), K(has_lob_out));
|
||||
} else if (OB_FAIL(update_row_id_handle(level, parent_fetch_idx, child_prefetch_idx, index_info.get_row_count()))) {
|
||||
@ -322,7 +322,7 @@ int ObSampleFilterExecutor::check_sample_block(
|
||||
} else if (!index_info.can_blockscan(has_lob_out) || !pd_row_range_.is_valid()) {
|
||||
LOG_DEBUG("Can not filter micro block in sample", K_(pd_row_range), K(index_info), K(has_lob_out));
|
||||
} else {
|
||||
if (level == row_id_handle_cap_) {
|
||||
if (level == index_tree_height_) {
|
||||
start_row_id = data_row_id_handle_[child_prefetch_idx % data_prefetch_depth_];
|
||||
} else {
|
||||
start_row_id = index_row_id_handle_[level * index_prefetch_depth_ + child_prefetch_idx % index_prefetch_depth_].start_;
|
||||
@ -517,21 +517,21 @@ int ObSampleFilterExecutor::update_row_id_handle(
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("The ObRowSampleFilter has not been inited", K(ret));
|
||||
} else if (OB_UNLIKELY(level <= 0 || level > row_id_handle_cap_
|
||||
} else if (OB_UNLIKELY(level <= 0 || level > index_tree_height_
|
||||
|| parent_fetch_idx < 0 || child_prefetch_idx < 0
|
||||
|| row_count < 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid argument to update row id hanle", K(ret), K(level), K(parent_fetch_idx),
|
||||
K(child_prefetch_idx), K_(row_id_handle_cap), K(row_count));
|
||||
K(child_prefetch_idx), K_(index_tree_height), K(row_count));
|
||||
} else {
|
||||
parent_fetch_idx %= index_prefetch_depth_;
|
||||
parent_start = index_row_id_handle_[(level - 1) * index_prefetch_depth_ + parent_fetch_idx].start_;
|
||||
parent_offset = index_row_id_handle_[(level - 1) * index_prefetch_depth_ + parent_fetch_idx].offset_;
|
||||
if (level < row_id_handle_cap_) {
|
||||
if (level < index_tree_height_) {
|
||||
child_prefetch_idx %= index_prefetch_depth_;
|
||||
index_row_id_handle_[level * index_prefetch_depth_ + child_prefetch_idx].start_ = parent_start + parent_offset;
|
||||
index_row_id_handle_[level * index_prefetch_depth_ + child_prefetch_idx].offset_ = 0;
|
||||
} else { // level == row_id_handle_cap_ means prefetching micro data block
|
||||
} else { // level == index_tree_height_ means prefetching micro data block
|
||||
child_prefetch_idx %= data_prefetch_depth_;
|
||||
data_row_id_handle_[child_prefetch_idx] = parent_start + parent_offset;
|
||||
}
|
||||
@ -662,7 +662,7 @@ void ObRowSampleFilterFactory::destroy_sample_filter(ObRowSampleFilter *&sample_
|
||||
int ret = OB_SUCCESS;
|
||||
ObSampleFilterExecutor *sample_executor = static_cast<ObSampleFilterExecutor *>(sample_filter->get_sample_executor());
|
||||
if (OB_FAIL(sample_executor->update_row_num_after_blockscan())) {
|
||||
LOG_WARN("Failed to update row num when destroy sample filter", K(ret), K(sample_executor));
|
||||
LOG_WARN("Failed to update row num when destroy sample filter", K(ret), KPC(sample_executor));
|
||||
} else {
|
||||
int64_t row_num = sample_executor->get_row_num();
|
||||
LOG_TRACE("Total row num scanned in sample", K(ret), K(row_num));
|
||||
|
@ -237,7 +237,7 @@ public:
|
||||
OB_INLINE int init_evaluated_datums() { return OB_SUCCESS; }
|
||||
TO_STRING_KV(K_(is_inited), K_(is_reverse_scan), K_(row_num), K_(interval_infos),
|
||||
K_(percent), K_(seed), K_(pd_row_range), K_(block_row_range),
|
||||
K_(row_id_handle_cap), K_(index_prefetch_depth), K_(data_prefetch_depth),
|
||||
K_(index_tree_height), K_(index_prefetch_depth), K_(data_prefetch_depth),
|
||||
K_(boundary_point), K_(filter_state), K_(filter),
|
||||
KP_(data_row_id_handle), KP_(index_row_id_handle), KP_(allocator));
|
||||
private:
|
||||
@ -299,7 +299,7 @@ private:
|
||||
ObSampleBlockStatistic block_statistic_;
|
||||
int32_t index_prefetch_depth_;
|
||||
int32_t data_prefetch_depth_;
|
||||
int16_t row_id_handle_cap_;
|
||||
int16_t index_tree_height_;
|
||||
bool filter_state_; // fast to judge whether one single row should be filtered
|
||||
bool is_reverse_scan_;
|
||||
bool is_inited_;
|
||||
|
@ -131,10 +131,10 @@ int ObSSTableRowScanner<PrefetchType>::inner_open(
|
||||
if (nullptr != sample_executor
|
||||
&& sstable_->is_major_sstable()
|
||||
&& OB_FAIL(sample_executor->build_row_id_handle(
|
||||
prefetcher_.get_tree_handle_cap(),
|
||||
prefetcher_.get_index_tree_height(),
|
||||
prefetcher_.get_index_prefetch_depth(),
|
||||
prefetcher_.get_micro_data_pefetch_depth()))) {
|
||||
LOG_WARN("Failed to build row id handle", K(ret));
|
||||
LOG_WARN("Failed to build row id handle", K(ret), KPC(sample_executor));
|
||||
} else if (OB_FAIL(prefetcher_.prefetch())) {
|
||||
LOG_WARN("ObSSTableRowScanner prefetch failed", K(ret));
|
||||
} else {
|
||||
@ -253,7 +253,7 @@ int ObSSTableRowScanner<PrefetchType>::open_cur_data_block(ObSSTableReadHandle &
|
||||
} else if (OB_FAIL(sample_executor->increase_row_num(access_ctx_->query_flag_.is_reverse_scan() ?
|
||||
micro_scanner_->get_current_pos() - micro_scanner_->get_last_pos() + 1 :
|
||||
micro_scanner_->get_last_pos() - micro_scanner_->get_current_pos() + 1))) {
|
||||
LOG_WARN("Failed to increase row num in sample filter", K(micro_scanner_->get_last_pos()), K(micro_scanner_->get_current_pos()));
|
||||
LOG_WARN("Failed to increase row num in sample filter", K(micro_scanner_->get_last_pos()), K(micro_scanner_->get_current_pos()), KPC(sample_executor));
|
||||
}
|
||||
}
|
||||
EVENT_INC(ObStatEventIds::BLOCKSCAN_BLOCK_CNT);
|
||||
|
@ -262,8 +262,9 @@ int ObCOSSTableRowsFilter::apply_filter(
|
||||
LOG_WARN("Failed to prepare bitmap buffer", K(ret), K(range), K(depth), KP(filter));
|
||||
// Parent prepare_skip_filter can not be called here.
|
||||
} else if (filter->is_sample_node()) {
|
||||
if (OB_FAIL(static_cast<ObSampleFilterExecutor *>(filter)->apply_sample_filter(range, *result->get_inner_bitmap()))) {
|
||||
LOG_WARN("Failed to apply sample filter", K(ret), K(range), KP(result));
|
||||
ObSampleFilterExecutor *sample_executor = static_cast<ObSampleFilterExecutor *>(filter);
|
||||
if (OB_FAIL(sample_executor->apply_sample_filter(range, *result->get_inner_bitmap()))) {
|
||||
LOG_WARN("Failed to apply sample filter", K(ret), K(range), KP(result), KPC(sample_executor));
|
||||
}
|
||||
} else if (sql::ObPushdownFilterExecutor::INVALID_CG_ITER_IDX != iter_idx) {
|
||||
ObICGIterator *cg_iter = filter_iters_.at(iter_idx);
|
||||
|
Reference in New Issue
Block a user