Skip to content

Commit

Permalink
Fix: update p3 files (#639)
Browse files Browse the repository at this point in the history
* Fix: update p3 files

* Fix: test cmake, hjoin test case

* Fix: terrier p4
  • Loading branch information
ChaosZhai authored Oct 28, 2023
1 parent 865905b commit 2b584a9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)

Expand Down
25 changes: 22 additions & 3 deletions src/include/concurrency/transaction_manager.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// :bustub-keep-private:
//===----------------------------------------------------------------------===//
//
// BusTub
Expand All @@ -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;

Expand Down Expand Up @@ -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_id_t, Transaction *> txn_map_;
/** Coordination for the transaction map */
std::shared_mutex txn_map_mutex_;

/**
Expand All @@ -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:
/**
Expand Down Expand Up @@ -153,6 +169,9 @@ class TransactionManager {
std::atomic<txn_id_t> next_txn_id_{0};
LockManager *lock_manager_ __attribute__((__unused__));
LogManager *log_manager_ __attribute__((__unused__));

/** Terrier Bench Hack */
bool terrier_{false};
};

} // namespace bustub
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/sql/p3.14-hash-join.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tools/terrier_bench/terrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ auto main(int argc, char **argv) -> int {
}

auto bustub = std::make_unique<bustub::BustubInstance>();
bustub->txn_manager_->SetTerrier();
auto writer = bustub::SimpleStreamWriter(std::cerr);

// create schema
Expand Down

0 comments on commit 2b584a9

Please sign in to comment.