From 2b584a9301f25bb1dc51e5abff01de425658dcf8 Mon Sep 17 00:00:00 2001 From: Chaos Zhai Date: Sat, 28 Oct 2023 03:04:42 -0400 Subject: [PATCH] Fix: update p3 files (#639) * Fix: update p3 files * Fix: test cmake, hjoin test case * Fix: terrier p4 --- CMakeLists.txt | 1 + src/include/concurrency/transaction_manager.h | 25 ++++++++++++++++--- test/CMakeLists.txt | 1 + test/sql/p3.14-hash-join.slt | 2 +- tools/terrier_bench/terrier.cpp | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af5bd5756..94f8fce0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -354,6 +354,7 @@ set(P3_FILES "src/common/bustub_ddl.cpp" "src/include/execution/plans/index_scan_plan.h" "src/include/execution/plans/topn_per_group_plan.h" + "src/include/execution/plans/seq_scan_plan.h" ${P2_FILES} ) diff --git a/src/include/concurrency/transaction_manager.h b/src/include/concurrency/transaction_manager.h index e148e9a24..6f540045f 100644 --- a/src/include/concurrency/transaction_manager.h +++ b/src/include/concurrency/transaction_manager.h @@ -1,3 +1,4 @@ +// :bustub-keep-private: //===----------------------------------------------------------------------===// // // BusTub @@ -23,6 +24,9 @@ #include "concurrency/transaction.h" #include "recovery/log_manager.h" +// If this is defined, project 4 related logic will be enabled. +// #define BUSTUB_REFSOL_HACK_TXN_MANAGER_IMPLEMENTED + namespace bustub { class LockManager; @@ -72,10 +76,11 @@ class TransactionManager { void Abort(Transaction *txn); /** - * The transaction map is a global list of all the running transactions in the system. + * Global list of running transactions */ + + /** The transaction map is a global list of all the running transactions in the system. */ std::unordered_map txn_map_; - /** Coordination for the transaction map */ std::shared_mutex txn_map_mutex_; /** @@ -97,7 +102,18 @@ class TransactionManager { /** Resumes all transactions, used for checkpointing. */ void ResumeTransactions(); - Catalog *catalog_{nullptr}; + Catalog *catalog_; + + /** + * Set we're in terrier bench mode + */ + inline void SetTerrier() { terrier_ = true; } + + /** + * Get if we're in terrier bench mode + * @return boolean indicating terrier mode + */ + inline auto GetTerrier() -> bool { return terrier_; } private: /** @@ -153,6 +169,9 @@ class TransactionManager { std::atomic next_txn_id_{0}; LockManager *lock_manager_ __attribute__((__unused__)); LogManager *log_manager_ __attribute__((__unused__)); + + /** Terrier Bench Hack */ + bool terrier_{false}; }; } // namespace bustub diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 402c42d2f..1fcad1cac 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -72,6 +72,7 @@ set(BUSTUB_SLT_SOURCES "${PROJECT_SOURCE_DIR}/test/sql/p3.17-topn.slt" "${PROJECT_SOURCE_DIR}/test/sql/p3.18-integration-1.slt" "${PROJECT_SOURCE_DIR}/test/sql/p3.19-integration-2.slt" + "${PROJECT_SOURCE_DIR}/test/sql/p3.20-window-function.slt" "${PROJECT_SOURCE_DIR}/test/sql/p3.leaderboard-q1.slt" "${PROJECT_SOURCE_DIR}/test/sql/p3.leaderboard-q2.slt" "${PROJECT_SOURCE_DIR}/test/sql/p3.leaderboard-q3.slt" diff --git a/test/sql/p3.14-hash-join.slt b/test/sql/p3.14-hash-join.slt index 7421ebbe5..c5aa5d3af 100644 --- a/test/sql/p3.14-hash-join.slt +++ b/test/sql/p3.14-hash-join.slt @@ -550,7 +550,7 @@ select * from temp_1 t1 inner join temp_2 t2 on t1.colC = t2.colB and t1.colB = 6 2 170 92798 6 170 2 query rowsort +ensure:hash_join_no_filter -select * from test_1 t1, test_2 t2 WHERE t1.colA = t2.colA and t1.colB = t2.colC and t1.colA = t2.colC; +select * from temp_1 t1, temp_2 t2 WHERE t1.colA = t2.colA and t1.colB = t2.colC and t1.colA = t2.colC; ---- 8 8 3074 56174 8 194 8 diff --git a/tools/terrier_bench/terrier.cpp b/tools/terrier_bench/terrier.cpp index efcd22516..37a2039b9 100644 --- a/tools/terrier_bench/terrier.cpp +++ b/tools/terrier_bench/terrier.cpp @@ -153,6 +153,7 @@ auto main(int argc, char **argv) -> int { } auto bustub = std::make_unique(); + bustub->txn_manager_->SetTerrier(); auto writer = bustub::SimpleStreamWriter(std::cerr); // create schema