Skip to content

Commit 230b4ec

Browse files
authored
fix(p3): nlj check should only consider number of actual tuples (#556)
* fix(p3): nlj check should only consider number of actual tuples Signed-off-by: Alex Chi <[email protected]> * fix Signed-off-by: Alex Chi <[email protected]> --------- Signed-off-by: Alex Chi <[email protected]>
1 parent cda2f2b commit 230b4ec

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/execution/init_check_executor.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ void InitCheckExecutor::Init() {
2929
}
3030

3131
auto InitCheckExecutor::Next(Tuple *tuple, RID *rid) -> bool {
32-
if (!child_executor_) {
33-
return EXECUTOR_EXHAUSTED;
34-
}
35-
3632
// Emit the next tuple
37-
n_next_++;
38-
return child_executor_->Next(tuple, rid);
33+
auto result = child_executor_->Next(tuple, rid);
34+
if (result) {
35+
n_next_++;
36+
}
37+
return result;
3938
}
4039

4140
} // namespace bustub

src/include/execution/execution_engine.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ class ExecutionEngine {
7979
for (const auto &[left_executor, right_executor] : exec_ctx->GetNLJCheckExecutorSet()) {
8080
auto casted_left_executor = dynamic_cast<const InitCheckExecutor *>(left_executor);
8181
auto casted_right_executor = dynamic_cast<const InitCheckExecutor *>(right_executor);
82-
BUSTUB_ASSERT(casted_left_executor->GetNextCount() == casted_right_executor->GetInitCount(),
83-
"nlj check failed, are you initialising the right executor correctly?");
82+
BUSTUB_ASSERT(casted_right_executor->GetInitCount() + 1 >= casted_left_executor->GetNextCount(),
83+
"nlj check failed, are you initialising the right executor every time when there is a left tuple? "
84+
"(off-by-one is okay)");
8485
}
8586
}
8687

0 commit comments

Comments
 (0)