Skip to content

Commit a573d3d

Browse files
committed
update task3 and task4
Signed-off-by: Yuchen Liang <yuchenl3@andrew.cmu.edu>
1 parent f881307 commit a573d3d

11 files changed

+45
-36
lines changed

src/execution/executor_factory.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ namespace bustub {
5353
* @param plan The plan node that needs to be executed
5454
* @return An executor for the given plan in the provided context
5555
*/
56-
auto ExecutorFactory::CreateExecutor(ExecutorContext *exec_ctx,
57-
const AbstractPlanNodeRef &plan) -> std::unique_ptr<AbstractExecutor> {
56+
auto ExecutorFactory::CreateExecutor(ExecutorContext *exec_ctx, const AbstractPlanNodeRef &plan)
57+
-> std::unique_ptr<AbstractExecutor> {
5858
auto check_options_set = exec_ctx->GetCheckOptions()->check_options_set_;
5959
switch (plan->GetType()) {
6060
// Create a new sequential scan 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/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/seq_scan_executor.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ SeqScanExecutor::SeqScanExecutor(ExecutorContext *exec_ctx, const SeqScanPlanNod
2525
}
2626

2727
/** Initialize the sequential scan */
28-
void SeqScanExecutor::Init() {
29-
UNIMPLEMENTED("TODO(P3): Add implementation.");
30-
;
31-
}
28+
void SeqScanExecutor::Init() { UNIMPLEMENTED("TODO(P3): Add implementation."); }
3229

3330
/**
3431
* Yield the next tuple from the sequential scan.

src/include/execution/executors/hash_join_executor.h

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#pragma once
1414

1515
#include <memory>
16-
#include <utility>
1716

1817
#include "execution/executor_context.h"
1918
#include "execution/executors/abstract_executor.h"

src/include/execution/expressions/abstract_expression.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
#include "storage/table/tuple.h"
2424
#include "type/type.h"
2525

26-
#define BUSTUB_EXPR_CLONE_WITH_CHILDREN(cname) \
27-
auto CloneWithChildren(std::vector<AbstractExpressionRef> children) const->std::unique_ptr<AbstractExpression> \
28-
override { \
29-
auto expr = cname(*this); \
30-
expr.children_ = children; \
31-
return std::make_unique<cname>(std::move(expr)); \
26+
#define BUSTUB_EXPR_CLONE_WITH_CHILDREN(cname) \
27+
auto CloneWithChildren(std::vector<AbstractExpressionRef> children) const -> std::unique_ptr<AbstractExpression> \
28+
override { \
29+
auto expr = cname(*this); \
30+
expr.children_ = children; \
31+
return std::make_unique<cname>(std::move(expr)); \
3232
}
3333

3434
namespace bustub {

src/include/execution/plans/abstract_plan.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
namespace bustub {
2424

25-
#define BUSTUB_PLAN_NODE_CLONE_WITH_CHILDREN(cname) \
26-
auto CloneWithChildren(std::vector<AbstractPlanNodeRef> children) const->std::unique_ptr<AbstractPlanNode> \
27-
override { \
28-
auto plan_node = cname(*this); \
29-
plan_node.children_ = children; \
30-
return std::make_unique<cname>(std::move(plan_node)); \
25+
#define BUSTUB_PLAN_NODE_CLONE_WITH_CHILDREN(cname) \
26+
auto CloneWithChildren(std::vector<AbstractPlanNodeRef> children) const -> std::unique_ptr<AbstractPlanNode> \
27+
override { \
28+
auto plan_node = cname(*this); \
29+
plan_node.children_ = children; \
30+
return std::make_unique<cname>(std::move(plan_node)); \
3131
}
3232

3333
/** PlanType represents the types of plans that we have in our system. */

src/optimizer/nlj_as_hash_join.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace bustub {
3636
*/
3737
auto Optimizer::OptimizeNLJAsHashJoin(const AbstractPlanNodeRef &plan) -> AbstractPlanNodeRef {
3838
// TODO(student): implement NestedLoopJoin -> HashJoin optimizer rule
39-
// Note for 2023 Fall: You should support join keys of any number of conjunction of equi-conditions:
39+
// Note for Spring 2025: You should support join keys of any number of conjunction of equi-conditions:
4040
// E.g. <column expr> = <column expr> AND <column expr> = <column expr> AND ...
4141
return plan;
4242
}

test/storage/page_guard_test.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ TEST(PageGuardTest, DISABLED_MoveTest) {
164164
ASSERT_EQ(1, bpm->GetPinCount(pid3));
165165

166166
// This will hang if page 2 was not unlatched correctly.
167-
{ const auto temp_guard2 = bpm->WritePage(pid2); }
167+
{
168+
const auto temp_guard2 = bpm->WritePage(pid2);
169+
}
168170

169171
auto guard4 = bpm->WritePage(pid4);
170172
auto guard5 = bpm->WritePage(pid5);
@@ -187,7 +189,9 @@ TEST(PageGuardTest, DISABLED_MoveTest) {
187189
ASSERT_EQ(1, bpm->GetPinCount(pid5));
188190

189191
// This will hang if page 4 was not unlatched correctly.
190-
{ const auto temp_guard4 = bpm->ReadPage(pid4); }
192+
{
193+
const auto temp_guard4 = bpm->ReadPage(pid4);
194+
}
191195

192196
// Test move constructor with invalid that
193197
{

test/txn/txn_scan_test.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,12 @@ TEST(TxnScanTest, DISABLED_CollectUndoLogTest) { // NOLINT
281281
ASSERT_TRUE(tuple.has_value());
282282
VerifyTuple(schema.get(), *tuple, {Int(2), Double(2.0), BoolNull()});
283283
}
284-
{ ASSERT_FALSE(undo_logs_3_for_txn_to_inspect.has_value()); }
285-
{ ASSERT_FALSE(undo_logs_4_for_txn_to_inspect.has_value()); }
284+
{
285+
ASSERT_FALSE(undo_logs_3_for_txn_to_inspect.has_value());
286+
}
287+
{
288+
ASSERT_FALSE(undo_logs_4_for_txn_to_inspect.has_value());
289+
}
286290
{
287291
ASSERT_TRUE(undo_logs_5_for_txn_to_inspect.has_value());
288292
auto tuple = ReconstructTuple(schema.get(), tuple_res_5.second, tuple_res_5.first, *undo_logs_5_for_txn_to_inspect);

0 commit comments

Comments
 (0)