From 88440235314b99f898c141aa5e53bc315b69dd05 Mon Sep 17 00:00:00 2001 From: Ryoji Kurosawa Date: Wed, 18 Dec 2024 12:16:42 +0900 Subject: [PATCH] fix wrong conditions for high/low keys --- .../dist/uniform_key_distribution.cpp | 4 +-- test/jogasaki/api/parallel_scan_test.cpp | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/jogasaki/dist/uniform_key_distribution.cpp b/src/jogasaki/dist/uniform_key_distribution.cpp index 599afc22..f33ae6c7 100644 --- a/src/jogasaki/dist/uniform_key_distribution.cpp +++ b/src/jogasaki/dist/uniform_key_distribution.cpp @@ -160,7 +160,7 @@ std::vector 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 {}; } @@ -171,7 +171,7 @@ std::vector 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 {}; } diff --git a/test/jogasaki/api/parallel_scan_test.cpp b/test/jogasaki/api/parallel_scan_test.cpp index 0fcf4ffc..011ede07 100644 --- a/test/jogasaki/api/parallel_scan_test.cpp +++ b/test/jogasaki/api/parallel_scan_test.cpp @@ -98,6 +98,9 @@ TEST_F(parallel_scan_test, simple) { std::vector result{}; execute_query("SELECT * FROM t", *tx, result); ASSERT_EQ(3, result.size()); + EXPECT_EQ((create_nullable_record(100)), result[0]); + EXPECT_EQ((create_nullable_record(200)), result[1]); + EXPECT_EQ((create_nullable_record(300)), result[2]); } TEST_F(parallel_scan_test, empty_table) { @@ -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 result{}; + execute_query("SELECT * FROM t", *tx, result); + ASSERT_EQ(10, result.size()); + std::sort(result.begin(), result.end()); + EXPECT_EQ((create_nullable_record(10)), result[0]); + EXPECT_EQ((create_nullable_record(20)), result[1]); + EXPECT_EQ((create_nullable_record(30)), result[2]); + EXPECT_EQ((create_nullable_record(40)), result[3]); + EXPECT_EQ((create_nullable_record(50)), result[4]); + EXPECT_EQ((create_nullable_record(60)), result[5]); + EXPECT_EQ((create_nullable_record(70)), result[6]); + EXPECT_EQ((create_nullable_record(80)), result[7]); + EXPECT_EQ((create_nullable_record(90)), result[8]); + EXPECT_EQ((create_nullable_record(100)), result[9]); +} + }