| 537 | } |
| 538 | |
| 539 | bool PhjBuilder::AppendRowStreamFull( |
| 540 | BufferedTupleStream* stream, TupleRow* row, Status* status) noexcept { |
| 541 | while (true) { |
| 542 | // We ran out of memory. Pick a partition to spill. If we ran out of unspilled |
| 543 | // partitions, SpillPartition() will return an error status. |
| 544 | *status = SpillPartition(BufferedTupleStream::UNPIN_ALL_EXCEPT_CURRENT); |
| 545 | if (!status->ok()) return false; |
| 546 | if (stream->AddRow(row, status)) return true; |
| 547 | if (!status->ok()) return false; |
| 548 | // Spilling one partition does not guarantee we can append a row. Keep |
| 549 | // spilling until we can append this row. |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | // TODO: can we do better with a different spilling heuristic? |
| 554 | Status PhjBuilder::SpillPartition(BufferedTupleStream::UnpinMode mode, |