| 180 | }; |
| 181 | |
| 182 | TEST_P(HashJoinBridgeTest, withoutSpill) { |
| 183 | // Test both when morsel-driven is disabled and enabled. |
| 184 | for (const bool isMorselDriven : {false, true}) { |
| 185 | for (const bool hasNullKeys : {false, true}) { |
| 186 | SCOPED_TRACE(fmt::format("hasNullKeys: {}", hasNullKeys)); |
| 187 | auto futures = createEmptyFutures(numProbers_); |
| 188 | |
| 189 | auto joinBridge = createJoinBridge(isMorselDriven); |
| 190 | // Can't call any other APIs except addBuilder() before start a join |
| 191 | // bridge first. |
| 192 | ASSERT_ANY_THROW( |
| 193 | joinBridge->setHashTable(createFakeHashTable(), {}, false)); |
| 194 | ASSERT_ANY_THROW(joinBridge->setAntiJoinHasNullKeys()); |
| 195 | ASSERT_ANY_THROW(joinBridge->probeFinished()); |
| 196 | ASSERT_ANY_THROW(joinBridge->tableOrFuture(&futures[0])); |
| 197 | ASSERT_ANY_THROW(joinBridge->spillInputOrFuture(&futures[0])); |
| 198 | |
| 199 | // Can't start a bridge without any builders if morsel-driven is disabled. |
| 200 | // When morsel-driven is enabled, joinBridge should not throw any error |
| 201 | // when there is no builder. |
| 202 | if (!isMorselDriven) { |
| 203 | ASSERT_ANY_THROW(joinBridge->start()); |
| 204 | } |
| 205 | |
| 206 | joinBridge = createJoinBridge(isMorselDriven); |
| 207 | |
| 208 | for (int32_t i = 0; i < numBuilders_; ++i) { |
| 209 | joinBridge->addBuilder(); |
| 210 | } |
| 211 | joinBridge->start(); |
| 212 | |
| 213 | for (int32_t i = 0; i < numProbers_; ++i) { |
| 214 | auto tableOr = joinBridge->tableOrFuture(&futures[i]); |
| 215 | ASSERT_FALSE(tableOr.has_value()); |
| 216 | ASSERT_TRUE(futures[i].valid()); |
| 217 | } |
| 218 | |
| 219 | BaseHashTable* rawTable = nullptr; |
| 220 | if (hasNullKeys) { |
| 221 | joinBridge->setAntiJoinHasNullKeys(); |
| 222 | ASSERT_ANY_THROW(joinBridge->setAntiJoinHasNullKeys()); |
| 223 | } else { |
| 224 | auto table = createFakeHashTable(); |
| 225 | rawTable = table.get(); |
| 226 | joinBridge->setHashTable(std::move(table), {}, false); |
| 227 | ASSERT_ANY_THROW( |
| 228 | joinBridge->setHashTable(createFakeHashTable(), {}, false)); |
| 229 | } |
| 230 | |
| 231 | for (int32_t i = 0; i < numProbers_; ++i) { |
| 232 | futures[i].wait(); |
| 233 | } |
| 234 | |
| 235 | // Check build results. |
| 236 | futures = createEmptyFutures(numProbers_ * 2); |
| 237 | for (int32_t i = 0; i < numProbers_ * 2; ++i) { |
| 238 | auto tableOr = joinBridge->tableOrFuture(&futures[i]); |
| 239 | ASSERT_TRUE(tableOr.has_value()); |
nothing calls this directly
no test coverage detected