Skip to content

Commit

Permalink
fix wrong conditions for high/low keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kuron99 committed Dec 18, 2024
1 parent e498937 commit 8844023
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jogasaki/dist/uniform_key_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ std::vector<uniform_key_distribution::pivot_type> uniform_key_distribution::comp
std::string high{};
std::string low{};
if(auto res = lowkey(low); res != status::ok) {
if(res != status::not_found) {
if(res == status::not_found) {
// empty index or failing to get low key somehow
return {};
}
Expand All @@ -171,7 +171,7 @@ std::vector<uniform_key_distribution::pivot_type> uniform_key_distribution::comp
low = range.begin_key();
}
if(auto res = highkey(high); res != status::ok) {
if(res != status::not_found) {
if(res == status::not_found) {
// empty index or failing to get high key somehow
return {};
}
Expand Down
25 changes: 25 additions & 0 deletions test/jogasaki/api/parallel_scan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ TEST_F(parallel_scan_test, simple) {
std::vector<mock::basic_record> result{};
execute_query("SELECT * FROM t", *tx, result);
ASSERT_EQ(3, result.size());
EXPECT_EQ((create_nullable_record<kind::int4>(100)), result[0]);

Check failure on line 101 in test/jogasaki/api/parallel_scan_test.cpp

View workflow job for this annotation

GitHub Actions / CTest (ubuntu-24.04, shirakami)

parallel_scan_test.simple

Expected equality of these values: (create_nullable_record<kind::int4>(100)) Which is: (0:int4*)[100] result[0] Which is: (0:int4*)[200]
EXPECT_EQ((create_nullable_record<kind::int4>(200)), result[1]);

Check failure on line 102 in test/jogasaki/api/parallel_scan_test.cpp

View workflow job for this annotation

GitHub Actions / CTest (ubuntu-24.04, shirakami)

parallel_scan_test.simple

Expected equality of these values: (create_nullable_record<kind::int4>(200)) Which is: (0:int4*)[200] result[1] Which is: (0:int4*)[100]
EXPECT_EQ((create_nullable_record<kind::int4>(300)), result[2]);
}

TEST_F(parallel_scan_test, empty_table) {
Expand Down Expand Up @@ -129,4 +132,26 @@ TEST_F(parallel_scan_test, various_types) {
execute_query("SELECT * FROM t", *tx, result);
ASSERT_EQ(2, result.size());
}

TEST_F(parallel_scan_test, multiple_pivots) {
// manually check 10 records are picked by different scan strand
execute_statement("CREATE TABLE t (c0 int primary key)");
execute_statement("INSERT INTO t VALUES (10),(20),(30),(40),(50),(60),(70),(80),(90),(100)");
auto tx = utils::create_transaction(*db_, true, false);
std::vector<mock::basic_record> result{};
execute_query("SELECT * FROM t", *tx, result);
ASSERT_EQ(10, result.size());
std::sort(result.begin(), result.end());
EXPECT_EQ((create_nullable_record<kind::int4>(10)), result[0]);
EXPECT_EQ((create_nullable_record<kind::int4>(20)), result[1]);
EXPECT_EQ((create_nullable_record<kind::int4>(30)), result[2]);
EXPECT_EQ((create_nullable_record<kind::int4>(40)), result[3]);
EXPECT_EQ((create_nullable_record<kind::int4>(50)), result[4]);
EXPECT_EQ((create_nullable_record<kind::int4>(60)), result[5]);
EXPECT_EQ((create_nullable_record<kind::int4>(70)), result[6]);
EXPECT_EQ((create_nullable_record<kind::int4>(80)), result[7]);
EXPECT_EQ((create_nullable_record<kind::int4>(90)), result[8]);
EXPECT_EQ((create_nullable_record<kind::int4>(100)), result[9]);
}

}

0 comments on commit 8844023

Please sign in to comment.