| 596 | |
| 597 | template <bool AGGREGATED_ROWS> |
| 598 | Status GroupingAggregator::AppendSpilledRow( |
| 599 | Partition* __restrict__ partition, TupleRow* __restrict__ row) { |
| 600 | DCHECK(!is_streaming_preagg_); |
| 601 | DCHECK(partition->is_spilled()); |
| 602 | BufferedTupleStream* stream = AGGREGATED_ROWS ? |
| 603 | partition->aggregated_row_stream.get() : |
| 604 | partition->unaggregated_row_stream.get(); |
| 605 | DCHECK(!stream->is_pinned()); |
| 606 | Status status; |
| 607 | if (LIKELY(AddRowToSpilledStream(stream, row, &status))) return Status::OK(); |
| 608 | RETURN_IF_ERROR(status); |
| 609 | |
| 610 | // Keep trying to free memory by spilling and retry AddRow() until we run out of |
| 611 | // partitions or hit an error. |
| 612 | for (int n = GetNumPinnedPartitions(); n > 0; --n) { |
| 613 | RETURN_IF_ERROR(SpillPartition(AGGREGATED_ROWS)); |
| 614 | if (LIKELY(AddRowToSpilledStream(stream, row, &status))) return Status::OK(); |
| 615 | RETURN_IF_ERROR(status); |
| 616 | } |
| 617 | // If we have spilled all partitions, we should be able to add the row use the large |
| 618 | // write page reservation. This indicates a bug that we can't work in min reservation. |
| 619 | return Status(TErrorCode::INTERNAL_ERROR, Substitute("Internal error: No reservation " |
| 620 | "for writing a large page even after all partitions are spilled in $0:\n$1", |
| 621 | DebugString(), buffer_pool_client()->DebugString())); |
| 622 | } |
| 623 | |
| 624 | void GroupingAggregator::SetDebugOptions(const TDebugOptions& debug_options) { |
| 625 | debug_options_ = debug_options; |
nothing calls this directly
no test coverage detected