Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bustub to BusTub - Naming consistency #725

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/common/bustub_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

namespace bustub {

void BustubInstance::HandleCreateStatement(Transaction *txn, const CreateStatement &stmt, ResultWriter &writer) {
void BusTubInstance::HandleCreateStatement(Transaction *txn, const CreateStatement &stmt, ResultWriter &writer) {
std::unique_lock<std::shared_mutex> l(catalog_lock_);
auto info = catalog_->CreateTable(txn, stmt.table_, Schema(stmt.columns_));
IndexInfo *index = nullptr;
Expand Down Expand Up @@ -85,7 +85,7 @@ void BustubInstance::HandleCreateStatement(Transaction *txn, const CreateStateme
}
}

void BustubInstance::HandleIndexStatement(Transaction *txn, const IndexStatement &stmt, ResultWriter &writer) {
void BusTubInstance::HandleIndexStatement(Transaction *txn, const IndexStatement &stmt, ResultWriter &writer) {
std::vector<uint32_t> col_ids;
for (const auto &col : stmt.cols_) {
auto idx = stmt.table_->schema_.GetColIdx(col->col_name_.back());
Expand Down Expand Up @@ -139,7 +139,7 @@ void BustubInstance::HandleIndexStatement(Transaction *txn, const IndexStatement
WriteOneCell(fmt::format("Index created with id = {} with type = {}", info->index_oid_, info->index_type_), writer);
}

void BustubInstance::HandleExplainStatement(Transaction *txn, const ExplainStatement &stmt, ResultWriter &writer) {
void BusTubInstance::HandleExplainStatement(Transaction *txn, const ExplainStatement &stmt, ResultWriter &writer) {
std::string output;

// Print binder result.
Expand Down Expand Up @@ -181,18 +181,18 @@ void BustubInstance::HandleExplainStatement(Transaction *txn, const ExplainState
WriteOneCell(output, writer);
}

void BustubInstance::HandleVariableShowStatement(Transaction *txn, const VariableShowStatement &stmt,
void BusTubInstance::HandleVariableShowStatement(Transaction *txn, const VariableShowStatement &stmt,
ResultWriter &writer) {
auto content = GetSessionVariable(stmt.variable_);
WriteOneCell(fmt::format("{}={}", stmt.variable_, content), writer);
}

void BustubInstance::HandleVariableSetStatement(Transaction *txn, const VariableSetStatement &stmt,
void BusTubInstance::HandleVariableSetStatement(Transaction *txn, const VariableSetStatement &stmt,
ResultWriter &writer) {
session_variables_[stmt.variable_] = stmt.value_;
}

void BustubInstance::HandleTxnStatement(Transaction *txn, const TransactionStatement &stmt, ResultWriter &writer) {
void BusTubInstance::HandleTxnStatement(Transaction *txn, const TransactionStatement &stmt, ResultWriter &writer) {
if (managed_txn_mode_ && current_txn_ != nullptr) {
BUSTUB_ASSERT(current_txn_ == txn, "txn mismatched??");
}
Expand Down
32 changes: 16 additions & 16 deletions src/common/bustub_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@

namespace bustub {

auto BustubInstance::MakeExecutorContext(Transaction *txn, bool is_modify) -> std::unique_ptr<ExecutorContext> {
auto BusTubInstance::MakeExecutorContext(Transaction *txn, bool is_modify) -> std::unique_ptr<ExecutorContext> {
return std::make_unique<ExecutorContext>(txn, catalog_.get(), buffer_pool_manager_.get(), txn_manager_.get(),
lock_manager_.get(), is_modify);
}

BustubInstance::BustubInstance(const std::string &db_file_name, size_t bpm_size) {
BusTubInstance::BusTubInstance(const std::string &db_file_name, size_t bpm_size) {
enable_logging = false;

// Storage related.
Expand Down Expand Up @@ -98,7 +98,7 @@ BustubInstance::BustubInstance(const std::string &db_file_name, size_t bpm_size)
execution_engine_ = std::make_unique<ExecutionEngine>(buffer_pool_manager_.get(), txn_manager_.get(), catalog_.get());
}

BustubInstance::BustubInstance(size_t bpm_size) {
BusTubInstance::BusTubInstance(size_t bpm_size) {
enable_logging = false;

// Storage related.
Expand Down Expand Up @@ -149,7 +149,7 @@ BustubInstance::BustubInstance(size_t bpm_size) {
execution_engine_ = std::make_unique<ExecutionEngine>(buffer_pool_manager_.get(), txn_manager_.get(), catalog_.get());
}

void BustubInstance::CmdDbgMvcc(const std::vector<std::string> &params, ResultWriter &writer) {
void BusTubInstance::CmdDbgMvcc(const std::vector<std::string> &params, ResultWriter &writer) {
if (params.size() != 2) {
writer.OneCell("please provide a table name");
return;
Expand All @@ -165,7 +165,7 @@ void BustubInstance::CmdDbgMvcc(const std::vector<std::string> &params, ResultWr
TxnMgrDbg("\\dbgmvcc", txn_manager_.get(), table_info, table_info->table_.get());
}

void BustubInstance::CmdDisplayTables(ResultWriter &writer) {
void BusTubInstance::CmdDisplayTables(ResultWriter &writer) {
auto table_names = catalog_->GetTableNames();
writer.BeginTable(false);
writer.BeginHeader();
Expand All @@ -184,7 +184,7 @@ void BustubInstance::CmdDisplayTables(ResultWriter &writer) {
writer.EndTable();
}

void BustubInstance::CmdDisplayIndices(ResultWriter &writer) {
void BusTubInstance::CmdDisplayIndices(ResultWriter &writer) {
auto table_names = catalog_->GetTableNames();
writer.BeginTable(false);
writer.BeginHeader();
Expand All @@ -206,9 +206,9 @@ void BustubInstance::CmdDisplayIndices(ResultWriter &writer) {
writer.EndTable();
}

void BustubInstance::WriteOneCell(const std::string &cell, ResultWriter &writer) { writer.OneCell(cell); }
void BusTubInstance::WriteOneCell(const std::string &cell, ResultWriter &writer) { writer.OneCell(cell); }

void BustubInstance::CmdDisplayHelp(ResultWriter &writer) {
void BusTubInstance::CmdDisplayHelp(ResultWriter &writer) {
std::string help = R"(Welcome to the BusTub shell!

\dt: show all tables
Expand All @@ -231,7 +231,7 @@ see the execution plan of your query.
WriteOneCell(help, writer);
}

auto BustubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer,
auto BusTubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer,
std::shared_ptr<CheckOptions> check_options) -> bool {
bool is_local_txn = current_txn_ != nullptr;
auto *txn = is_local_txn ? current_txn_ : txn_manager_->Begin();
Expand All @@ -251,7 +251,7 @@ auto BustubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer,
}
}

auto BustubInstance::ExecuteSqlTxn(const std::string &sql, ResultWriter &writer, Transaction *txn,
auto BusTubInstance::ExecuteSqlTxn(const std::string &sql, ResultWriter &writer, Transaction *txn,
std::shared_ptr<CheckOptions> check_options) -> bool {
if (!sql.empty() && sql[0] == '\\') {
// Internal meta-commands, like in `psql`.
Expand Down Expand Up @@ -380,7 +380,7 @@ auto BustubInstance::ExecuteSqlTxn(const std::string &sql, ResultWriter &writer,
* It's used in the shell to predefine some tables, as we don't support
* create / drop table and insert for now. Should remove it in the future.
*/
void BustubInstance::GenerateTestTable() {
void BusTubInstance::GenerateTestTable() {
auto *txn = txn_manager_->Begin();
auto exec_ctx = MakeExecutorContext(txn, false);
TableGenerator gen{exec_ctx.get()};
Expand All @@ -397,7 +397,7 @@ void BustubInstance::GenerateTestTable() {
* It's used in the shell to predefine some tables, as we don't support
* create / drop table and insert for now. Should remove it in the future.
*/
void BustubInstance::GenerateMockTable() {
void BusTubInstance::GenerateMockTable() {
// The actual content generated by mock scan executors are described in `mock_scan_executor.cpp`.
auto txn = txn_manager_->Begin();

Expand All @@ -410,19 +410,19 @@ void BustubInstance::GenerateMockTable() {
txn_manager_->Commit(txn);
}

BustubInstance::~BustubInstance() {
BusTubInstance::~BusTubInstance() {
if (enable_logging) {
log_manager_->StopFlushThread();
}
}

/** Enable managed txn mode on this BusTub instance, allowing statements like `BEGIN`. */
void BustubInstance::EnableManagedTxn() { managed_txn_mode_ = true; }
void BusTubInstance::EnableManagedTxn() { managed_txn_mode_ = true; }

/** Get the current transaction. */
auto BustubInstance::CurrentManagedTxn() -> Transaction * { return current_txn_; }
auto BusTubInstance::CurrentManagedTxn() -> Transaction * { return current_txn_; }

void BustubInstance::CmdTxn(const std::vector<std::string> &params, ResultWriter &writer) {
void BusTubInstance::CmdTxn(const std::vector<std::string> &params, ResultWriter &writer) {
if (!managed_txn_mode_) {
writer.OneCell("only supported in managed mode, please use bustub-shell");
return;
Expand Down
8 changes: 4 additions & 4 deletions src/include/common/bustub_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,19 @@ class FortTableWriter : public ResultWriter {
std::vector<std::string> tables_;
};

class BustubInstance {
class BusTubInstance {
private:
/**
* Get the executor context from the BusTub instance.
*/
auto MakeExecutorContext(Transaction *txn, bool is_modify) -> std::unique_ptr<ExecutorContext>;

public:
explicit BustubInstance(const std::string &db_file_name, size_t bpm_size = 128);
explicit BusTubInstance(const std::string &db_file_name, size_t bpm_size = 128);

explicit BustubInstance(size_t bpm_size = 128);
explicit BusTubInstance(size_t bpm_size = 128);

~BustubInstance();
~BusTubInstance();

/**
* Execute a SQL query in the BusTub instance.
Expand Down
2 changes: 1 addition & 1 deletion src/planner/plan_window_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ auto Planner::PlanSelectWindow(const SelectStatement &statement, AbstractPlanNod
if (window_call.start_ != WindowBoundary::UNBOUNDED_PRECEDING ||
(window_call.end_ != WindowBoundary::CURRENT_ROW_ROWS &&
window_call.end_ != WindowBoundary::CURRENT_ROW_RANGE)) {
throw Exception("Bustub currently only support window function with default window frame settings");
throw Exception("BusTub currently only support window function with default window frame settings");
}
std::vector<AbstractExpressionRef> partition_by;
for (auto &item : window_call.partition_by_) {
Expand Down
34 changes: 17 additions & 17 deletions test/concurrency/common_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace bustub {

auto Insert(Transaction *txn, BustubInstance &instance, int v1) -> void {
auto Insert(Transaction *txn, BusTubInstance &instance, int v1) -> void {
std::stringstream ss;
auto writer = bustub::SimpleStreamWriter(ss, true, ",");
fmt::print(stderr, "insert data with v1 = {} in txn {} {}\n", v1, txn->GetTransactionId(), txn->GetIsolationLevel());
Expand All @@ -38,7 +38,7 @@ auto Insert(Transaction *txn, BustubInstance &instance, int v1) -> void {
/// This overloaded function will then bound each pair from @v1_vec & @v2_vec as a insert value
/// If flag is set to `true`, v1_vec should contain exactly one element,
/// The insert pair will be {v1_vec[0], v2_vec[0]}, {v1_vec[0], v2_vec[1]} ...
auto Insert(Transaction *txn, BustubInstance &instance, const std::vector<int> &v1_vec, const std::vector<int> &v2_vec,
auto Insert(Transaction *txn, BusTubInstance &instance, const std::vector<int> &v1_vec, const std::vector<int> &v2_vec,
bool flag = false) -> void {
// Check if the input vectors have the same size.
if (!flag) {
Expand Down Expand Up @@ -95,7 +95,7 @@ auto Insert(Transaction *txn, BustubInstance &instance, const std::vector<int> &
ASSERT_EQ(ss.str(), fmt::format("{},\n", v2_vec.size()));
}

auto Delete(Transaction *txn, BustubInstance &instance, int v1) -> void {
auto Delete(Transaction *txn, BusTubInstance &instance, int v1) -> void {
std::stringstream ss;
auto writer = bustub::SimpleStreamWriter(ss, true, ",");
fmt::print(stderr, "delete data with v1 = {} in txn {} {}\n", v1, txn->GetTransactionId(), txn->GetIsolationLevel());
Expand All @@ -109,7 +109,7 @@ auto Delete(Transaction *txn, BustubInstance &instance, int v1) -> void {
/// @param d_size The size you expect to be deleted from t1, will be used as sanity check, default value is 3
/// This overloaded function performs a vectorized self-constructed deletion to better test the implementation
/// You should calculate the number of elements that logically should be deleted, and pass it in as @d_size.
auto Delete(Transaction *txn, BustubInstance &instance, const std::vector<int> &d_vec, int d_size = 3) -> void {
auto Delete(Transaction *txn, BusTubInstance &instance, const std::vector<int> &d_vec, int d_size = 3) -> void {
if (d_vec.empty()) {
fmt::print(stderr, "Input vec must not be empty\n");
return;
Expand Down Expand Up @@ -148,7 +148,7 @@ auto ExpectResult(const std::string &actual_result, const std::string &expected_
return actual_result_rows == expected_result_rows;
}

auto Scan(Transaction *txn, BustubInstance &instance, const std::vector<int> &v1) -> void {
auto Scan(Transaction *txn, BusTubInstance &instance, const std::vector<int> &v1) -> void {
std::stringstream ss;
auto writer = bustub::SimpleStreamWriter(ss, true, ",");
fmt::print(stderr, "scan data expect v1 in range {} in txn {} {}\n", v1, txn->GetTransactionId(),
Expand All @@ -166,28 +166,28 @@ auto Scan(Transaction *txn, BustubInstance &instance, const std::vector<int> &v1
}
}

void Commit(BustubInstance &instance, Transaction *&txn) {
void Commit(BusTubInstance &instance, Transaction *&txn) {
fmt::print(stderr, "commit txn {} in {}\n", txn->GetTransactionId(), txn->GetIsolationLevel());
instance.txn_manager_->Commit(txn);
delete txn;
txn = nullptr;
}

void Abort(BustubInstance &instance, Transaction *&txn) {
void Abort(BusTubInstance &instance, Transaction *&txn) {
fmt::print(stderr, "abort txn {} in {}\n", txn->GetTransactionId(), txn->GetIsolationLevel());
instance.txn_manager_->Abort(txn);
delete txn;
txn = nullptr;
}

auto Begin(BustubInstance &instance, IsolationLevel level) -> Transaction * {
auto Begin(BusTubInstance &instance, IsolationLevel level) -> Transaction * {
auto txn = instance.txn_manager_->Begin(nullptr, level);
fmt::print(stderr, "start txn {} in {}\n", txn->GetTransactionId(), txn->GetIsolationLevel());
return txn;
}

auto GetDbForVisibilityTest(const std::string &name) -> std::shared_ptr<BustubInstance> {
auto instance = std::make_unique<BustubInstance>();
auto GetDbForVisibilityTest(const std::string &name) -> std::shared_ptr<BusTubInstance> {
auto instance = std::make_unique<BusTubInstance>();
auto writer = bustub::SimpleStreamWriter(std::cout, true);
fmt::print(stderr, "--- TEST CASE {} ---\n", name);
fmt::print(stderr, "prepare\n");
Expand All @@ -196,8 +196,8 @@ auto GetDbForVisibilityTest(const std::string &name) -> std::shared_ptr<BustubIn
return instance;
}

auto GetDbForCommitAbortTest(const std::string &name) -> std::shared_ptr<BustubInstance> {
auto instance = std::make_unique<BustubInstance>();
auto GetDbForCommitAbortTest(const std::string &name) -> std::shared_ptr<BusTubInstance> {
auto instance = std::make_unique<BusTubInstance>();
auto writer = bustub::SimpleStreamWriter(std::cout, true);
fmt::print(stderr, "--- TEST CASE {} ---\n", name);
fmt::print(stderr, "prepare\n");
Expand All @@ -213,8 +213,8 @@ enum class ExpectedOutcome {
BlockOnWrite,
};

auto GetDbForIsolationTest() -> std::shared_ptr<BustubInstance> {
auto instance = std::make_unique<BustubInstance>();
auto GetDbForIsolationTest() -> std::shared_ptr<BusTubInstance> {
auto instance = std::make_unique<BusTubInstance>();
auto writer = bustub::SimpleStreamWriter(std::cout, true);
fmt::print(stderr, "0: prepare\n");
// in case you implemented scan filter pushdown... disable it by forcing starter rule!
Expand All @@ -226,7 +226,7 @@ auto GetDbForIsolationTest() -> std::shared_ptr<BustubInstance> {
return instance;
}

auto StartReadTxn(IsolationLevel read_txn_level, BustubInstance &instance, bool read_before_write) -> Transaction * {
auto StartReadTxn(IsolationLevel read_txn_level, BusTubInstance &instance, bool read_before_write) -> Transaction * {
fmt::print(stderr, "1: read txn: {}\n", read_txn_level);
auto txn_r = instance.txn_manager_->Begin(nullptr, read_txn_level);
if (read_before_write) {
Expand All @@ -253,7 +253,7 @@ auto StartReadTxn(IsolationLevel read_txn_level, BustubInstance &instance, bool
return txn_r;
}

auto StartWriteTxn(IsolationLevel write_txn_level, BustubInstance &instance, bool is_delete) -> Transaction * {
auto StartWriteTxn(IsolationLevel write_txn_level, BusTubInstance &instance, bool is_delete) -> Transaction * {
auto writer = bustub::SimpleStreamWriter(std::cout, true);
fmt::print(stderr, "2: write txn: {}\n", write_txn_level);
auto txn_w = instance.txn_manager_->Begin(nullptr, write_txn_level);
Expand All @@ -273,7 +273,7 @@ auto StartWriteTxn(IsolationLevel write_txn_level, BustubInstance &instance, boo
return txn_w;
}

auto TryRead(Transaction *txn_r, BustubInstance &instance, ExpectedOutcome o, bool is_delete,
auto TryRead(Transaction *txn_r, BusTubInstance &instance, ExpectedOutcome o, bool is_delete,
std::atomic<bool> &check_done) -> bool {
bool ret = false;
std::stringstream result;
Expand Down
10 changes: 5 additions & 5 deletions test/recovery/recovery_test.cpp.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RecoveryTest : public ::testing::Test {

// NOLINTNEXTLINE
TEST_F(RecoveryTest, DISABLED_RedoTest) {
auto *bustub_instance = new BustubInstance("test.bustub");
auto *bustub_instance = new BusTubInstance("test.bustub");

ASSERT_FALSE(enable_logging);
LOG_INFO("Skip system recovering...");
Expand Down Expand Up @@ -92,7 +92,7 @@ TEST_F(RecoveryTest, DISABLED_RedoTest) {
delete bustub_instance;

LOG_INFO("System restart...");
bustub_instance = new BustubInstance("test.bustub");
bustub_instance = new BusTubInstance("test.bustub");

ASSERT_FALSE(enable_logging);
LOG_INFO("Check if tuple is not in table before recovery");
Expand Down Expand Up @@ -139,7 +139,7 @@ TEST_F(RecoveryTest, DISABLED_RedoTest) {

// NOLINTNEXTLINE
TEST_F(RecoveryTest, DISABLED_UndoTest) {
auto *bustub_instance = new BustubInstance("test.bustub");
auto *bustub_instance = new BusTubInstance("test.bustub");

ASSERT_FALSE(enable_logging);
LOG_INFO("Skip system recovering...");
Expand Down Expand Up @@ -176,7 +176,7 @@ TEST_F(RecoveryTest, DISABLED_UndoTest) {
delete bustub_instance;

LOG_INFO("System restarted..");
bustub_instance = new BustubInstance("test.bustub");
bustub_instance = new BusTubInstance("test.bustub");

LOG_INFO("Check if tuple exists before recovery");
Tuple old_tuple;
Expand Down Expand Up @@ -218,7 +218,7 @@ TEST_F(RecoveryTest, DISABLED_UndoTest) {

// NOLINTNEXTLINE
TEST_F(RecoveryTest, DISABLED_CheckpointTest) {
auto *bustub_instance = new BustubInstance("test.bustub");
auto *bustub_instance = new BusTubInstance("test.bustub");

EXPECT_FALSE(enable_logging);
LOG_INFO("Skip system recovering...");
Expand Down
Loading
Loading