Skip to content

Commit 84a0823

Browse files
yliang412AlSchlo
andauthored
s25-p3: starter code clean up (#806)
* update task1 Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> * update task2 Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> * fix format Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> * Update tables with TAs Co-authored-by: Alexis Schlomer <aschlome@andrew.cmu.edu> Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> * update mock executor again Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> --------- Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu> Co-authored-by: Alexis Schlomer <aschlome@andrew.cmu.edu>
1 parent 4078d4b commit 84a0823

31 files changed

+151
-132
lines changed

src/execution/aggregation_executor.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include <memory>
14-
#include <vector>
14+
#include "common/macros.h"
1515

1616
#include "execution/executors/aggregation_executor.h"
1717

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

3032
/** Initialize the aggregation */
31-
void AggregationExecutor::Init() {}
33+
void AggregationExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }
3234

3335
/**
3436
* Yield the next tuple from the insert.
3537
* @param[out] tuple The next tuple produced by the aggregation
3638
* @param[out] rid The next tuple RID produced by the aggregation
3739
* @return `true` if a tuple was produced, `false` if there are no more tuples
3840
*/
39-
auto AggregationExecutor::Next(Tuple *tuple, RID *rid) -> bool { return false; }
41+
42+
auto AggregationExecutor::Next(Tuple *tuple, RID *rid) -> bool { UNIMPLEMENTED("TODO(P3): Add implementation."); }
4043

4144
/** Do not use or remove this function, otherwise you will get zero points. */
4245
auto AggregationExecutor::GetChildExecutor() const -> const AbstractExecutor * { return child_executor_.get(); }

src/execution/delete_executor.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include <memory>
14+
#include "common/macros.h"
1415

1516
#include "execution/executors/delete_executor.h"
1617

@@ -24,10 +25,12 @@ namespace bustub {
2425
*/
2526
DeleteExecutor::DeleteExecutor(ExecutorContext *exec_ctx, const DeletePlanNode *plan,
2627
std::unique_ptr<AbstractExecutor> &&child_executor)
27-
: AbstractExecutor(exec_ctx) {}
28+
: AbstractExecutor(exec_ctx) {
29+
UNIMPLEMENTED("TODO(P3): Add implementation.");
30+
}
2831

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

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

4348
} // namespace bustub

src/execution/executor_factory.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "execution/executors/nested_loop_join_executor.h"
3131
#include "execution/executors/projection_executor.h"
3232
#include "execution/executors/seq_scan_executor.h"
33-
#include "execution/executors/sort_executor.h"
3433
#include "execution/executors/topn_check_executor.h"
3534
#include "execution/executors/topn_executor.h"
3635
#include "execution/executors/topn_per_group_executor.h"
@@ -45,7 +44,6 @@
4544
#include "execution/plans/topn_plan.h"
4645
#include "execution/plans/values_plan.h"
4746
#include "execution/plans/window_plan.h"
48-
#include "storage/index/generic_key.h"
4947

5048
namespace bustub {
5149

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

138136
// Create a new hash join executor

src/execution/external_merge_sort_executor.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "execution/executors/external_merge_sort_executor.h"
14-
#include <iostream>
15-
#include <optional>
1614
#include <vector>
17-
#include "common/config.h"
15+
#include "common/macros.h"
1816
#include "execution/plans/sort_plan.h"
1917

2018
namespace bustub {
2119

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

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

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

4444
template class ExternalMergeSortExecutor<2>;

src/execution/hash_join_executor.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "execution/executors/hash_join_executor.h"
14+
#include "common/macros.h"
1415

1516
namespace bustub {
1617

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

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

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

4547
} // namespace bustub

src/execution/index_scan_executor.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "execution/executors/index_scan_executor.h"
14+
#include "common/macros.h"
1415

1516
namespace bustub {
1617

@@ -20,10 +21,12 @@ namespace bustub {
2021
* @param plan the index scan plan to be executed
2122
*/
2223
IndexScanExecutor::IndexScanExecutor(ExecutorContext *exec_ctx, const IndexScanPlanNode *plan)
23-
: AbstractExecutor(exec_ctx) {}
24+
: AbstractExecutor(exec_ctx) {
25+
UNIMPLEMENTED("TODO(P3): Add implementation.");
26+
}
2427

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

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

2932
} // namespace bustub

src/execution/insert_executor.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include <memory>
14+
#include "common/macros.h"
1415

1516
#include "execution/executors/insert_executor.h"
1617

@@ -24,10 +25,12 @@ namespace bustub {
2425
*/
2526
InsertExecutor::InsertExecutor(ExecutorContext *exec_ctx, const InsertPlanNode *plan,
2627
std::unique_ptr<AbstractExecutor> &&child_executor)
27-
: AbstractExecutor(exec_ctx) {}
28+
: AbstractExecutor(exec_ctx) {
29+
UNIMPLEMENTED("TODO(P3): Add implementation.");
30+
}
2831

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

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

4348
} // namespace bustub

src/execution/limit_executor.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "execution/executors/limit_executor.h"
14+
#include "common/macros.h"
1415

1516
namespace bustub {
1617

@@ -22,17 +23,19 @@ namespace bustub {
2223
*/
2324
LimitExecutor::LimitExecutor(ExecutorContext *exec_ctx, const LimitPlanNode *plan,
2425
std::unique_ptr<AbstractExecutor> &&child_executor)
25-
: AbstractExecutor(exec_ctx) {}
26+
: AbstractExecutor(exec_ctx) {
27+
UNIMPLEMENTED("TODO(P3): Add implementation.");
28+
}
2629

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

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

3841
} // namespace bustub

src/execution/mock_scan_executor.cpp

+36-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "common/exception.h"
1818
#include "common/util/string_util.h"
19-
#include "execution/expressions/column_value_expression.h"
2019
#include "type/type_id.h"
2120
#include "type/value_factory.h"
2221

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

41+
static const char *ta_list_2025_spring[] = {"AlSchlo", "carpecodeum", "ChrisLaspias", "hyoungjook",
42+
"joesunil123", "mrwhitezz", "rmboyce", "yliang412"};
43+
4244
static const char *ta_oh_2022[] = {"Tuesday", "Wednesday", "Monday", "Wednesday", "Thursday", "Friday",
4345
"Wednesday", "Randomly", "Tuesday", "Monday", "Tuesday"};
4446

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

59+
static const char *ta_oh_2025_spring[] = {"Friday", "Monday", "Wednesday", "Tuesday",
60+
"Friday", "Thursday", "Monday", "Tuesday"};
61+
5762
static const char *course_on_date[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
5863

59-
const char *mock_table_list[] = {"__mock_table_1", "__mock_table_2", "__mock_table_3", "__mock_table_tas_2022",
60-
"__mock_table_tas_2023", "__mock_table_tas_2023_fall", "__mock_table_tas_2024",
61-
"__mock_table_tas_2024_fall", "__mock_agg_input_small", "__mock_agg_input_big",
62-
"__mock_external_merge_sort_input", "__mock_table_schedule_2022",
63-
"__mock_table_schedule", "__mock_table_123", "__mock_graph",
64-
// For leaderboard Q1
65-
"__mock_t1",
66-
// For leaderboard Q2
67-
"__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m",
68-
// For leaderboard Q3
69-
"__mock_t7", "__mock_t8", "__mock_t9",
70-
// For P3 leaderboard Q4
71-
"__mock_t10", "__mock_t11", nullptr};
64+
const char *mock_table_list[] = {
65+
"__mock_table_1", "__mock_table_2", "__mock_table_3", "__mock_table_tas_2022", "__mock_table_tas_2023",
66+
"__mock_table_tas_2023_fall", "__mock_table_tas_2024", "__mock_table_tas_2024_fall", "__mock_table_tas_2025_spring",
67+
"__mock_agg_input_small", "__mock_agg_input_big", "__mock_external_merge_sort_input", "__mock_table_schedule_2022",
68+
"__mock_table_schedule", "__mock_table_123", "__mock_graph",
69+
// For leaderboard Q1
70+
"__mock_t1",
71+
// For leaderboard Q2
72+
"__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m",
73+
// For leaderboard Q3
74+
"__mock_t7", "__mock_t8", "__mock_t9",
75+
// For P3 leaderboard Q4
76+
"__mock_t10", "__mock_t11", nullptr};
7277

7378
static const int GRAPH_NODE_CNT = 10;
7479

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

113+
if (table == "__mock_table_tas_2025_spring") {
114+
return Schema{std::vector{Column{"github_id", TypeId::VARCHAR, 128}, Column{"office_hour", TypeId::VARCHAR, 128}}};
115+
}
116+
108117
if (table == "__mock_table_schedule_2022") {
109118
return Schema{std::vector{Column{"day_of_week", TypeId::VARCHAR, 128}, Column{"has_lecture", TypeId::INTEGER}}};
110119
}
@@ -205,6 +214,10 @@ auto GetSizeOf(const MockScanPlanNode *plan) -> size_t {
205214
return sizeof(ta_list_2024_fall) / sizeof(ta_list_2024_fall[0]);
206215
}
207216

217+
if (table == "__mock_table_tas_2025_spring") {
218+
return sizeof(ta_list_2025_spring) / sizeof(ta_list_2025_spring[0]);
219+
}
220+
208221
if (table == "__mock_table_schedule_2022") {
209222
return sizeof(course_on_date) / sizeof(course_on_date[0]);
210223
}
@@ -365,6 +378,15 @@ auto GetFunctionOf(const MockScanPlanNode *plan) -> std::function<Tuple(size_t)>
365378
};
366379
}
367380

381+
if (table == "__mock_table_tas_2025_spring") {
382+
return [plan](size_t cursor) {
383+
std::vector<Value> values{};
384+
values.push_back(ValueFactory::GetVarcharValue(ta_list_2025_spring[cursor]));
385+
values.push_back(ValueFactory::GetVarcharValue(ta_oh_2025_spring[cursor]));
386+
return Tuple{values, &plan->OutputSchema()};
387+
};
388+
}
389+
368390
if (table == "__mock_table_schedule_2022") {
369391
return [plan](size_t cursor) {
370392
std::vector<Value> values{};

src/execution/nested_index_join_executor.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "execution/executors/nested_index_join_executor.h"
14+
#include "common/macros.h"
1415

1516
namespace bustub {
1617

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

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

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

3638
} // namespace bustub

0 commit comments

Comments
 (0)