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

s25-p3: starter code clean up #806

Merged
merged 5 commits into from
Mar 10, 2025
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
11 changes: 7 additions & 4 deletions src/execution/aggregation_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

#include <memory>
#include <vector>
#include "common/macros.h"

#include "execution/executors/aggregation_executor.h"

Expand All @@ -25,18 +25,21 @@ namespace bustub {
*/
AggregationExecutor::AggregationExecutor(ExecutorContext *exec_ctx, const AggregationPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx) {}
: AbstractExecutor(exec_ctx) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the aggregation */
void AggregationExecutor::Init() {}
void AggregationExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/**
* Yield the next tuple from the insert.
* @param[out] tuple The next tuple produced by the aggregation
* @param[out] rid The next tuple RID produced by the aggregation
* @return `true` if a tuple was produced, `false` if there are no more tuples
*/
auto AggregationExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }

auto AggregationExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/** Do not use or remove this function, otherwise you will get zero points. */
auto AggregationExecutor::GetChildExecutor() const -> const AbstractExecutor * { return child_executor_.get(); }
Expand Down
11 changes: 8 additions & 3 deletions src/execution/delete_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include <memory>
#include "common/macros.h"

#include "execution/executors/delete_executor.h"

Expand All @@ -24,10 +25,12 @@ namespace bustub {
*/
DeleteExecutor::DeleteExecutor(ExecutorContext *exec_ctx, const DeletePlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx) {}
: AbstractExecutor(exec_ctx) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the delete */
void DeleteExecutor::Init() { throw NotImplementedException("DeleteExecutor is not implemented"); }
void DeleteExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/**
* Yield the number of rows deleted from the table.
Expand All @@ -38,6 +41,8 @@ void DeleteExecutor::Init() { throw NotImplementedException("DeleteExecutor is n
* NOTE: DeleteExecutor::Next() does not use the `rid` out-parameter.
* NOTE: DeleteExecutor::Next() returns true with the number of deleted rows produced only once.
*/
auto DeleteExecutor::Next([[maybe_unused]] Tuple *tuple, RID *rid) -> bool { return false; }
auto DeleteExecutor::Next([[maybe_unused]] Tuple *tuple, RID *rid) -> bool {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

} // namespace bustub
4 changes: 1 addition & 3 deletions src/execution/executor_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "execution/executors/nested_loop_join_executor.h"
#include "execution/executors/projection_executor.h"
#include "execution/executors/seq_scan_executor.h"
#include "execution/executors/sort_executor.h"
#include "execution/executors/topn_check_executor.h"
#include "execution/executors/topn_executor.h"
#include "execution/executors/topn_per_group_executor.h"
Expand All @@ -45,7 +44,6 @@
#include "execution/plans/topn_plan.h"
#include "execution/plans/values_plan.h"
#include "execution/plans/window_plan.h"
#include "storage/index/generic_key.h"

namespace bustub {

Expand Down Expand Up @@ -132,7 +130,7 @@ auto ExecutorFactory::CreateExecutor(ExecutorContext *exec_ctx, const AbstractPl
case PlanType::NestedIndexJoin: {
auto nested_index_join_plan = dynamic_cast<const NestedIndexJoinPlanNode *>(plan.get());
auto left = ExecutorFactory::CreateExecutor(exec_ctx, nested_index_join_plan->GetChildPlan());
return std::make_unique<NestIndexJoinExecutor>(exec_ctx, nested_index_join_plan, std::move(left));
return std::make_unique<NestedIndexJoinExecutor>(exec_ctx, nested_index_join_plan, std::move(left));
}

// Create a new hash join executor
Expand Down
12 changes: 6 additions & 6 deletions src/execution/external_merge_sort_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
//===----------------------------------------------------------------------===//

#include "execution/executors/external_merge_sort_executor.h"
#include <iostream>
#include <optional>
#include <vector>
#include "common/config.h"
#include "common/macros.h"
#include "execution/plans/sort_plan.h"

namespace bustub {

template <size_t K>
ExternalMergeSortExecutor<K>::ExternalMergeSortExecutor(ExecutorContext *exec_ctx, const SortPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx), cmp_(plan->GetOrderBy()) {}
: AbstractExecutor(exec_ctx), cmp_(plan->GetOrderBy()) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the external merge sort */
template <size_t K>
void ExternalMergeSortExecutor<K>::Init() {
throw NotImplementedException("ExternalMergeSortExecutor is not implemented");
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/**
Expand All @@ -38,7 +38,7 @@ void ExternalMergeSortExecutor<K>::Init() {
*/
template <size_t K>
auto ExternalMergeSortExecutor<K>::Next(Tuple *tuple, RID *rid) -> bool {
return false;
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

template class ExternalMergeSortExecutor<2>;
Expand Down
8 changes: 5 additions & 3 deletions src/execution/hash_join_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "execution/executors/hash_join_executor.h"
#include "common/macros.h"

namespace bustub {

Expand All @@ -26,20 +27,21 @@ HashJoinExecutor::HashJoinExecutor(ExecutorContext *exec_ctx, const HashJoinPlan
std::unique_ptr<AbstractExecutor> &&right_child)
: AbstractExecutor(exec_ctx) {
if (!(plan->GetJoinType() == JoinType::LEFT || plan->GetJoinType() == JoinType::INNER)) {
// Note for Fall 2024: You ONLY need to implement left join and inner join.
// Note for Spring 2025: You ONLY need to implement left join and inner join.
throw bustub::NotImplementedException(fmt::format("join type {} not supported", plan->GetJoinType()));
}
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the join */
void HashJoinExecutor::Init() { throw NotImplementedException("HashJoinExecutor is not implemented"); }
void HashJoinExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/**
* Yield the next tuple from the join.
* @param[out] tuple The next tuple produced by the join.
* @param[out] rid The next tuple RID, not used by hash join.
* @return `true` if a tuple was produced, `false` if there are no more tuples.
*/
auto HashJoinExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }
auto HashJoinExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }

} // namespace bustub
9 changes: 6 additions & 3 deletions src/execution/index_scan_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "execution/executors/index_scan_executor.h"
#include "common/macros.h"

namespace bustub {

Expand All @@ -20,10 +21,12 @@ namespace bustub {
* @param plan the index scan plan to be executed
*/
IndexScanExecutor::IndexScanExecutor(ExecutorContext *exec_ctx, const IndexScanPlanNode *plan)
: AbstractExecutor(exec_ctx) {}
: AbstractExecutor(exec_ctx) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

void IndexScanExecutor::Init() { throw NotImplementedException("IndexScanExecutor is not implemented"); }
void IndexScanExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

auto IndexScanExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }
auto IndexScanExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }

} // namespace bustub
11 changes: 8 additions & 3 deletions src/execution/insert_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include <memory>
#include "common/macros.h"

#include "execution/executors/insert_executor.h"

Expand All @@ -24,10 +25,12 @@ namespace bustub {
*/
InsertExecutor::InsertExecutor(ExecutorContext *exec_ctx, const InsertPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx) {}
: AbstractExecutor(exec_ctx) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the insert */
void InsertExecutor::Init() { throw NotImplementedException("InsertExecutor is not implemented"); }
void InsertExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/**
* Yield the number of rows inserted into the table.
Expand All @@ -38,6 +41,8 @@ void InsertExecutor::Init() { throw NotImplementedException("InsertExecutor is n
* NOTE: InsertExecutor::Next() does not use the `rid` out-parameter.
* NOTE: InsertExecutor::Next() returns true with number of inserted rows produced only once.
*/
auto InsertExecutor::Next([[maybe_unused]] Tuple *tuple, RID *rid) -> bool { return false; }
auto InsertExecutor::Next([[maybe_unused]] Tuple *tuple, RID *rid) -> bool {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

} // namespace bustub
9 changes: 6 additions & 3 deletions src/execution/limit_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "execution/executors/limit_executor.h"
#include "common/macros.h"

namespace bustub {

Expand All @@ -22,17 +23,19 @@ namespace bustub {
*/
LimitExecutor::LimitExecutor(ExecutorContext *exec_ctx, const LimitPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx) {}
: AbstractExecutor(exec_ctx) {
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

/** Initialize the limit */
void LimitExecutor::Init() { throw NotImplementedException("LimitExecutor is not implemented"); }
void LimitExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

/**
* Yield the next tuple from the limit.
* @param[out] tuple The next tuple produced by the limit
* @param[out] rid The next tuple RID produced by the limit
* @return `true` if a tuple was produced, `false` if there are no more tuples
*/
auto LimitExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }
auto LimitExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }

} // namespace bustub
50 changes: 36 additions & 14 deletions src/execution/mock_scan_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "common/exception.h"
#include "common/util/string_util.h"
#include "execution/expressions/column_value_expression.h"
#include "type/type_id.h"
#include "type/value_factory.h"

Expand All @@ -39,6 +38,9 @@ static const char *ta_list_2024[] = {"AlSchlo", "walkingcabbages", "averyqi115
static const char *ta_list_2024_fall[] = {"17zhangw", "connortsui20", "J-HowHuang", "lanlou1554",
"prashanthduvvada", "unw9527", "xx01cyx", "yashkothari42"};

static const char *ta_list_2025_spring[] = {"AlSchlo", "carpecodeum", "ChrisLaspias", "hyoungjook",
"joesunil123", "mrwhitezz", "rmboyce", "yliang412"};

static const char *ta_oh_2022[] = {"Tuesday", "Wednesday", "Monday", "Wednesday", "Thursday", "Friday",
"Wednesday", "Randomly", "Tuesday", "Monday", "Tuesday"};

Expand All @@ -54,21 +56,24 @@ static const char *ta_oh_2024[] = {"Friday", "Thursday", "Friday", "Wednesda
static const char *ta_oh_2024_fall[] = {"Wednesday", "Thursday", "Tuesday", "Monday",
"Friday", "Thursday", "Tuesday", "Friday"};

static const char *ta_oh_2025_spring[] = {"Friday", "Monday", "Wednesday", "Tuesday",
"Friday", "Thursday", "Monday", "Tuesday"};

static const char *course_on_date[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

const char *mock_table_list[] = {"__mock_table_1", "__mock_table_2", "__mock_table_3", "__mock_table_tas_2022",
"__mock_table_tas_2023", "__mock_table_tas_2023_fall", "__mock_table_tas_2024",
"__mock_table_tas_2024_fall", "__mock_agg_input_small", "__mock_agg_input_big",
"__mock_external_merge_sort_input", "__mock_table_schedule_2022",
"__mock_table_schedule", "__mock_table_123", "__mock_graph",
// For leaderboard Q1
"__mock_t1",
// For leaderboard Q2
"__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m",
// For leaderboard Q3
"__mock_t7", "__mock_t8", "__mock_t9",
// For P3 leaderboard Q4
"__mock_t10", "__mock_t11", nullptr};
const char *mock_table_list[] = {
"__mock_table_1", "__mock_table_2", "__mock_table_3", "__mock_table_tas_2022", "__mock_table_tas_2023",
"__mock_table_tas_2023_fall", "__mock_table_tas_2024", "__mock_table_tas_2024_fall", "__mock_table_tas_2025_spring",
"__mock_agg_input_small", "__mock_agg_input_big", "__mock_external_merge_sort_input", "__mock_table_schedule_2022",
"__mock_table_schedule", "__mock_table_123", "__mock_graph",
// For leaderboard Q1
"__mock_t1",
// For leaderboard Q2
"__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m",
// For leaderboard Q3
"__mock_t7", "__mock_t8", "__mock_t9",
// For P3 leaderboard Q4
"__mock_t10", "__mock_t11", nullptr};

static const int GRAPH_NODE_CNT = 10;

Expand Down Expand Up @@ -105,6 +110,10 @@ auto GetMockTableSchemaOf(const std::string &table) -> Schema {
return Schema{std::vector{Column{"github_id", TypeId::VARCHAR, 128}, Column{"office_hour", TypeId::VARCHAR, 128}}};
}

if (table == "__mock_table_tas_2025_spring") {
return Schema{std::vector{Column{"github_id", TypeId::VARCHAR, 128}, Column{"office_hour", TypeId::VARCHAR, 128}}};
}

if (table == "__mock_table_schedule_2022") {
return Schema{std::vector{Column{"day_of_week", TypeId::VARCHAR, 128}, Column{"has_lecture", TypeId::INTEGER}}};
}
Expand Down Expand Up @@ -205,6 +214,10 @@ auto GetSizeOf(const MockScanPlanNode *plan) -> size_t {
return sizeof(ta_list_2024_fall) / sizeof(ta_list_2024_fall[0]);
}

if (table == "__mock_table_tas_2025_spring") {
return sizeof(ta_list_2025_spring) / sizeof(ta_list_2025_spring[0]);
}

if (table == "__mock_table_schedule_2022") {
return sizeof(course_on_date) / sizeof(course_on_date[0]);
}
Expand Down Expand Up @@ -365,6 +378,15 @@ auto GetFunctionOf(const MockScanPlanNode *plan) -> std::function<Tuple(size_t)>
};
}

if (table == "__mock_table_tas_2025_spring") {
return [plan](size_t cursor) {
std::vector<Value> values{};
values.push_back(ValueFactory::GetVarcharValue(ta_list_2025_spring[cursor]));
values.push_back(ValueFactory::GetVarcharValue(ta_oh_2025_spring[cursor]));
return Tuple{values, &plan->OutputSchema()};
};
}

if (table == "__mock_table_schedule_2022") {
return [plan](size_t cursor) {
std::vector<Value> values{};
Expand Down
12 changes: 7 additions & 5 deletions src/execution/nested_index_join_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "execution/executors/nested_index_join_executor.h"
#include "common/macros.h"

namespace bustub {

Expand All @@ -20,17 +21,18 @@ namespace bustub {
* @param plan the nested index join plan to be executed
* @param child_executor the outer table
*/
NestIndexJoinExecutor::NestIndexJoinExecutor(ExecutorContext *exec_ctx, const NestedIndexJoinPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
NestedIndexJoinExecutor::NestedIndexJoinExecutor(ExecutorContext *exec_ctx, const NestedIndexJoinPlanNode *plan,
std::unique_ptr<AbstractExecutor> &&child_executor)
: AbstractExecutor(exec_ctx) {
if (!(plan->GetJoinType() == JoinType::LEFT || plan->GetJoinType() == JoinType::INNER)) {
// Note for 2023 Spring: You ONLY need to implement left join and inner join.
// Note for Spring 2025: You ONLY need to implement left join and inner join.
throw bustub::NotImplementedException(fmt::format("join type {} not supported", plan->GetJoinType()));
}
UNIMPLEMENTED("TODO(P3): Add implementation.");
}

void NestIndexJoinExecutor::Init() { throw NotImplementedException("NestIndexJoinExecutor is not implemented"); }
void NestedIndexJoinExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }

auto NestIndexJoinExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }
auto NestedIndexJoinExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }

} // namespace bustub
Loading
Loading