fix granule op_ordering bug

This commit is contained in:
sdc
2023-05-30 08:17:54 +00:00
committed by ob-robot
parent 073ca1f40e
commit b74570f68e
2 changed files with 23 additions and 0 deletions

View File

@ -567,6 +567,22 @@ public:
};
class ObNewRangeCmp
{
public:
ObNewRangeCmp() {}
// caller ensures no intersection between any two ranges
OB_INLINE bool operator() (const ObNewRange *a, const ObNewRange *b) const
{
int cmp = 0;
if (OB_NOT_NULL(a) && OB_NOT_NULL(b)) {
cmp = a->compare_with_startkey2(*b);
}
return cmp < 0;
}
};
template <typename Allocator>
int ObNewRange::deserialize(Allocator &allocator, const char *buf, const int64_t data_len,
int64_t &pos)

View File

@ -865,6 +865,13 @@ int ObGranuleSplitter::get_query_range(ObExecContext &ctx,
LOG_WARN("failed to final extract index skip query range", K(ret));
} else {
has_extract_query_range = true;
/* Here is an improvement made:
1. By default, access to each partition is always in sequential ascending order.
Compared to not sorting, this is an enhancement that is not always 100% necessary
(some scenarios do not require order), but the logic is acceptable.
2. If reverse order is required outside, then the reverse sorting should be done outside on its own.
*/
std::sort(scan_ranges.begin(), scan_ranges.end(), ObNewRangeCmp());
}
}