Fix some sample logic.
This commit is contained in:
parent
664822467e
commit
deb429e32e
@ -175,6 +175,9 @@ 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_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))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Failed to alloc memory for index_row_id_handle and data_row_id_handle", K(ret), K(index_handle_max_cnt), K(data_handle_max_cnt));
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
count_ = std::floor(static_cast<double>((interval_id_ + 1) * interval_length_) * percent_ / 100)
|
||||
- std::floor(static_cast<double>(interval_id_ * interval_length_) * percent_ / 100);
|
||||
uint64_t hash_value = murmurhash(&interval_id_, sizeof(interval_id_), static_cast<uint64_t>(seed_));
|
||||
uint64_t offset = interval_length_ <= count_ ? 0 : hash_value % (interval_length_ - count_);
|
||||
uint64_t offset = interval_length_ <= count_ ? 0 : hash_value % (interval_length_ - count_ + 1);
|
||||
left_ = static_cast<int64_t>(interval_length_ * interval_id_ + offset) + start_;
|
||||
right_ = left_ + count_ - 1;
|
||||
}
|
||||
|
@ -67,10 +67,10 @@ public:
|
||||
|
||||
TEST_F(ObRowSampleFilterTest, test_filter_single_row)
|
||||
{
|
||||
bool result[20] = {0, 0, 1, 0,
|
||||
1, 1, 0, 0,
|
||||
bool result[20] = {0, 1, 0, 0,
|
||||
0, 0, 1, 1,
|
||||
0, 0, 1, 0,
|
||||
1, 1, 0, 0,
|
||||
0, 1, 1, 0,
|
||||
1, 1, 0, 0};
|
||||
bool filtered = false;
|
||||
for(int row_num = 0; row_num < 20; row_num++) {
|
||||
@ -82,18 +82,18 @@ TEST_F(ObRowSampleFilterTest, test_filter_single_row)
|
||||
TEST_F(ObRowSampleFilterTest, test_filter_range)
|
||||
{
|
||||
ObMicroIndexInfo index_info;
|
||||
check_sample_range(0, 1, index_info, true);
|
||||
check_sample_range(3, 3, index_info, true);
|
||||
check_sample_range(6, 9, index_info, true);
|
||||
check_sample_range(11, 11, index_info, true);
|
||||
check_sample_range(14, 15, index_info, true);
|
||||
check_sample_range(0, 0, index_info, true);
|
||||
check_sample_range(2, 5, index_info, true);
|
||||
check_sample_range(8, 9, index_info, true);
|
||||
check_sample_range(11, 12, index_info, true);
|
||||
check_sample_range(15, 15, index_info, true);
|
||||
check_sample_range(18, 19, index_info, true);
|
||||
|
||||
check_sample_range(0, 2, index_info, false);
|
||||
check_sample_range(0, 4, index_info, false);
|
||||
check_sample_range(4, 4, index_info, false);
|
||||
check_sample_range(5, 6, index_info, false);
|
||||
check_sample_range(5, 9, index_info, false);
|
||||
check_sample_range(6, 10, index_info, false);
|
||||
check_sample_range(7, 9, index_info, false);
|
||||
check_sample_range(12, 13, index_info, false);
|
||||
check_sample_range(15, 16, index_info, false);
|
||||
check_sample_range(17, 17, index_info, false);
|
||||
@ -102,10 +102,10 @@ TEST_F(ObRowSampleFilterTest, test_filter_range)
|
||||
|
||||
TEST_F(ObRowSampleFilterTest, test_set_sample_bitmap)
|
||||
{
|
||||
bool result[20] = {0, 0, 1, 0,
|
||||
1, 1, 0, 0,
|
||||
bool result[20] = {0, 1, 0, 0,
|
||||
0, 0, 1, 1,
|
||||
0, 0, 1, 0,
|
||||
1, 1, 0, 0,
|
||||
0, 1, 1, 0,
|
||||
1, 1, 0, 0};
|
||||
ObBitmap *result_bitmap = nullptr;
|
||||
ASSERT_EQ(OB_SUCCESS, sample_executor_->init_bitmap(20, result_bitmap));
|
||||
|
Loading…
x
Reference in New Issue
Block a user