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 1 commit
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
6 changes: 3 additions & 3 deletions test/txn/txn_abort_serializable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace bustub {
TEST(TxnBonusTest, DISABLED_SerializableTest) { // NOLINT
fmt::println(stderr, "--- SerializableTest2: Serializable ---");
{
auto bustub = std::make_unique<BustubInstance>();
auto bustub = std::make_unique<BusTubInstance>();
EnsureIndexScan(*bustub);
Execute(*bustub, "CREATE TABLE maintable(a int, b int primary key)");
auto table_info = bustub->catalog_->GetTable("maintable");
Expand All @@ -37,7 +37,7 @@ TEST(TxnBonusTest, DISABLED_ConcurrentSerializableTest) { // NOLINT
fmt::println(stderr, "--- SerializableTest2: Concurrent Serializable ---");
{
for (int i = 0; i < 10; i++) {
auto bustub = std::make_unique<BustubInstance>();
auto bustub = std::make_unique<BusTubInstance>();
EnsureIndexScan(*bustub);
Execute(*bustub, "CREATE TABLE maintable(a int, b int primary key)");
auto table_info = bustub->catalog_->GetTable("maintable");
Expand Down Expand Up @@ -90,7 +90,7 @@ TEST(TxnBonusTest, DISABLED_ConcurrentSerializableTest) { // NOLINT
TEST(TxnBonusTest, DISABLED_AbortTest) { // NOLINT
fmt::println(stderr, "--- AbortTest1: Simple Abort ---");
{
auto bustub = std::make_unique<BustubInstance>();
auto bustub = std::make_unique<BusTubInstance>();
EnsureIndexScan(*bustub);
Execute(*bustub, "CREATE TABLE maintable(a int primary key, b int)");
auto table_info = bustub->catalog_->GetTable("maintable");
Expand Down
Loading
Loading