[CP] Fix blockscan border in multi-version sstable

This commit is contained in:
haitaoyang
2023-07-04 04:42:25 +00:00
committed by ob-robot
parent a44e6d2fc4
commit f71235f4e4
4 changed files with 11 additions and 9 deletions

View File

@ -1204,7 +1204,7 @@ public:
} else if (OB_UNLIKELY(!index_info.is_valid() || !rowkey.is_valid())) { } else if (OB_UNLIKELY(!index_info.is_valid() || !rowkey.is_valid())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("Invalid MicroIndexInfo", K(ret), K(index_info), K(rowkey)); LOG_WARN("Invalid MicroIndexInfo", K(ret), K(index_info), K(rowkey));
} else if (OB_FAIL(index_info.endkey_->compare(rowkey, datum_utils_, cmp_ret))) { } else if (OB_FAIL(index_info.endkey_->compare(rowkey, datum_utils_, cmp_ret, false))) {
LOG_WARN("fail to compare rowkey", K(ret), KPC(index_info.endkey_), K(rowkey)); LOG_WARN("fail to compare rowkey", K(ret), KPC(index_info.endkey_), K(rowkey));
} }
return cmp_ret; return cmp_ret;
@ -1268,7 +1268,7 @@ int ObIndexTreeMultiPassPrefetcher<DATA_PREFETCH_DEPTH, INDEX_PREFETCH_DEPTH>::c
int64_t start_idx = start_pos % max_micro_handle_cnt_; int64_t start_idx = start_pos % max_micro_handle_cnt_;
int64_t end_idx = end_pos % max_micro_handle_cnt_; int64_t end_idx = end_pos % max_micro_handle_cnt_;
if (!is_reverse) { if (!is_reverse) {
if (OB_FAIL(micro_data_infos_[end_idx].endkey_->compare(border_rowkey, datum_utils, cmp_ret))) { if (OB_FAIL(micro_data_infos_[end_idx].endkey_->compare(border_rowkey, datum_utils, cmp_ret, false))) {
LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[start_idx].endkey_)); LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[start_idx].endkey_));
} else if (cmp_ret < 0) { } else if (cmp_ret < 0) {
for (int64_t pos = start_pos; pos < end_pos; pos++) { for (int64_t pos = start_pos; pos < end_pos; pos++) {
@ -1286,7 +1286,7 @@ int ObIndexTreeMultiPassPrefetcher<DATA_PREFETCH_DEPTH, INDEX_PREFETCH_DEPTH>::c
} else { } else {
cmp_ret = 0; cmp_ret = 0;
// split to [start_idx, max_micro_handle_cnt_ - 1], [0, end_idx - 1] // split to [start_idx, max_micro_handle_cnt_ - 1], [0, end_idx - 1]
if (OB_FAIL(micro_data_infos_[max_micro_handle_cnt_ - 1].endkey_->compare(border_rowkey, datum_utils, cmp_ret))) { if (OB_FAIL(micro_data_infos_[max_micro_handle_cnt_ - 1].endkey_->compare(border_rowkey, datum_utils, cmp_ret, false))) {
LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[max_micro_handle_cnt_ - 1])); LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[max_micro_handle_cnt_ - 1]));
} else if (cmp_ret < 0) { } else if (cmp_ret < 0) {
for (int64_t idx = start_idx; idx < max_micro_handle_cnt_; idx++) { for (int64_t idx = start_idx; idx < max_micro_handle_cnt_; idx++) {
@ -1315,7 +1315,7 @@ int ObIndexTreeMultiPassPrefetcher<DATA_PREFETCH_DEPTH, INDEX_PREFETCH_DEPTH>::c
} else { } else {
cmp_ret = 0; cmp_ret = 0;
// split to [start_idx, max_micro_handle_cnt_ - 1], [0, end_idx] // split to [start_idx, max_micro_handle_cnt_ - 1], [0, end_idx]
if (OB_FAIL(micro_data_infos_[0].endkey_->compare(border_rowkey, datum_utils, cmp_ret))) { if (OB_FAIL(micro_data_infos_[0].endkey_->compare(border_rowkey, datum_utils, cmp_ret, false))) {
LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[0])); LOG_WARN("Fail to compare endkey", K(ret), K(border_rowkey), K(micro_data_infos_[0]));
} else if (cmp_ret > 0) { } else if (cmp_ret > 0) {
for (int64_t idx = start_idx; idx < max_micro_handle_cnt_; idx++) { for (int64_t idx = start_idx; idx < max_micro_handle_cnt_; idx++) {

View File

@ -94,7 +94,8 @@ int ObDatumRowkey::equal(const ObDatumRowkey &rhs, const ObStorageDatumUtils &da
return ret; return ret;
} }
int ObDatumRowkey::compare(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, int &cmp_ret) const int ObDatumRowkey::compare(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, int &cmp_ret,
const bool compare_datum_cnt) const
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -114,7 +115,7 @@ int ObDatumRowkey::compare(const ObDatumRowkey &rhs, const ObStorageDatumUtils &
STORAGE_LOG(WARN, "Failed to compare datum rowkey", K(ret), K(i), K(*this), K(rhs)); STORAGE_LOG(WARN, "Failed to compare datum rowkey", K(ret), K(i), K(*this), K(rhs));
} }
} }
if (0 == cmp_ret) { if (0 == cmp_ret && compare_datum_cnt) {
cmp_ret = datum_cnt_ - rhs.datum_cnt_; cmp_ret = datum_cnt_ - rhs.datum_cnt_;
} }
} }

View File

@ -73,7 +73,8 @@ public:
#undef DEF_ROWKEY_TYPE_FUNCS #undef DEF_ROWKEY_TYPE_FUNCS
int equal(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, bool &is_equal) const; int equal(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, bool &is_equal) const;
int compare(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, int &cmp_ret) const; int compare(const ObDatumRowkey &rhs, const ObStorageDatumUtils &datum_utils, int &cmp_ret,
const bool compare_datum_cnt = true) const;
int from_rowkey(const ObRowkey &rowkey, common::ObIAllocator &allocator); int from_rowkey(const ObRowkey &rowkey, common::ObIAllocator &allocator);
int from_rowkey(const ObRowkey &rowkey, ObStorageDatumBuffer &datum_buffer); int from_rowkey(const ObRowkey &rowkey, ObStorageDatumBuffer &datum_buffer);
int to_store_rowkey(const common::ObIArray<share::schema::ObColDesc> &col_descs, int to_store_rowkey(const common::ObIArray<share::schema::ObColDesc> &col_descs,

View File

@ -414,10 +414,10 @@ int ObIndexBlockRowScanner::check_blockscan(
LOG_WARN("Fail to get last row of micro block", K(ret), K_(end)); LOG_WARN("Fail to get last row of micro block", K(ret), K_(end));
} else if (OB_FAIL(last_endkey.assign(tmp_datum_row.storage_datums_, datum_utils_->get_rowkey_count()))) { } else if (OB_FAIL(last_endkey.assign(tmp_datum_row.storage_datums_, datum_utils_->get_rowkey_count()))) {
LOG_WARN("Fail to assign storage datum to endkey", K(ret), K(tmp_datum_row)); LOG_WARN("Fail to assign storage datum to endkey", K(ret), K(tmp_datum_row));
} else if (OB_FAIL(last_endkey.compare(rowkey, *datum_utils_, cmp_ret))) { } else if (OB_FAIL(last_endkey.compare(rowkey, *datum_utils_, cmp_ret, false))) {
LOG_WARN("Fail to compare rowkey", K(ret), K(last_endkey), K(rowkey)); LOG_WARN("Fail to compare rowkey", K(ret), K(last_endkey), K(rowkey));
} }
} else if (OB_FAIL((idx_data_header_->rowkey_array_ + end_)->compare(rowkey, *datum_utils_, cmp_ret))) { } else if (OB_FAIL((idx_data_header_->rowkey_array_ + end_)->compare(rowkey, *datum_utils_, cmp_ret, false))) {
LOG_WARN("Fail to compare rowkey", K(ret), K(rowkey)); LOG_WARN("Fail to compare rowkey", K(ret), K(rowkey));
} }