From fd6d136053e350b273cd11d1a8821686405b6a78 Mon Sep 17 00:00:00 2001 From: jinhelin Date: Wed, 7 Dec 2022 22:15:31 +0800 Subject: [PATCH] test --- .../DeltaMerge/tests/gtest_segment_bitmap.cpp | 43 +++++++++++++++++++ ...pp => gtest_segment_test_basic_bitmap.cpp} | 0 2 files changed, 43 insertions(+) rename dbms/src/Storages/DeltaMerge/tests/{gtest_segment_test_bitmap.cpp => gtest_segment_test_basic_bitmap.cpp} (100%) diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_bitmap.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_bitmap.cpp index 972fa923c0c..b8d65782d12 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_bitmap.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_bitmap.cpp @@ -456,12 +456,55 @@ CATCH TEST_F(SegmentBitmapFilterTest, Ranges) try +{ + read_ranges.emplace_back(buildRowKeyRange(222, 244)); + read_ranges.emplace_back(buildRowKeyRange(300, 303)); + read_ranges.emplace_back(buildRowKeyRange(555, 666)); + runTestCase(TestCase{ + "s:[0, 1024)|d_dr:[128, 256)|d_tiny_del:[300, 310)|d_tiny:[200, 255)|d_mem:[298, 305)", + 136, + "[1056, 1078)|[1091, 1094)|[555, 666)", + "[222, 244)|[300, 303)|[555, 666)"}); +} +CATCH + +TEST_F(SegmentBitmapFilterTest, LogicalSplit) +try { runTestCase(TestCase{ "s:[0, 1024)|d_dr:[128, 256)|d_tiny_del:[300, 310)|d_tiny:[200, 255)|d_mem:[298, 305)", 946, "[0, 128)|[1034, 1089)|[256, 298)|[1089, 1096)|[310, 1024)", "[0, 128)|[200, 255)|[256, 305)|[310, 1024)"}); + + auto new_seg_id = splitSegmentAt(SEG_ID, 512, Segment::SplitMode::Logical); + + ASSERT_TRUE(new_seg_id.has_value()); + ASSERT_TRUE(areSegmentsSharingStable({SEG_ID, *new_seg_id})); + + auto left_handle = getSegmentHandle(SEG_ID, {}); + const auto * left_h = toColumnVectorDataPtr(left_handle); + auto expected_left_handle = genSequence("[0, 128)|[200, 255)|[256, 305)|[310, 512)"); + ASSERT_EQ(expected_left_handle.size(), left_h->size()); + ASSERT_TRUE(sequenceEqual(expected_left_handle.data(), left_h->data(), left_h->size())); + + auto left_row_id = getSegmentRowId(SEG_ID, {}); + const auto * left_r = toColumnVectorDataPtr(left_row_id); + auto expected_left_row_id = genSequence("[0, 128)|[1034, 1089)|[256, 298)|[1089, 1096)|[310, 512)"); + ASSERT_EQ(expected_left_row_id.size(), left_r->size()); + ASSERT_TRUE(sequenceEqual(expected_left_row_id.data(), left_r->data(), left_r->size())); + + auto right_handle = getSegmentHandle(*new_seg_id, {}); + const auto * right_h = toColumnVectorDataPtr(right_handle); + auto expected_right_handle = genSequence("[512, 1024)"); + ASSERT_EQ(expected_right_handle.size(), right_h->size()); + ASSERT_TRUE(sequenceEqual(expected_right_handle.data(), right_h->data(), right_h->size())); + + auto right_row_id = getSegmentRowId(*new_seg_id, {}); + const auto * right_r = toColumnVectorDataPtr(right_row_id); + auto expected_right_row_id = genSequence("[512, 1024)"); + ASSERT_EQ(expected_right_row_id.size(), right_r->size()); + ASSERT_TRUE(sequenceEqual(expected_right_row_id.data(), right_r->data(), right_r->size())); } CATCH diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_bitmap.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic_bitmap.cpp similarity index 100% rename from dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_bitmap.cpp rename to dbms/src/Storages/DeltaMerge/tests/gtest_segment_test_basic_bitmap.cpp