| 1095 | } |
| 1096 | |
| 1097 | Status PhjBuilder::RepartitionBuildInput(PhjBuilderPartition* input_partition) { |
| 1098 | int new_level = input_partition->level() + 1; |
| 1099 | DCHECK_GE(new_level, 1); |
| 1100 | SCOPED_TIMER(repartition_timer_); |
| 1101 | COUNTER_ADD(num_repartitions_, 1); |
| 1102 | RuntimeState* state = runtime_state_; |
| 1103 | |
| 1104 | // Setup the read buffer and the new partitions. |
| 1105 | BufferedTupleStream* build_rows = input_partition->build_rows(); |
| 1106 | DCHECK(build_rows != nullptr); |
| 1107 | bool got_read_buffer; |
| 1108 | RETURN_IF_ERROR(build_rows->PrepareForRead(true, &got_read_buffer)); |
| 1109 | if (!got_read_buffer) { |
| 1110 | return mem_tracker()->MemLimitExceeded( |
| 1111 | state, Substitute(PREPARE_FOR_READ_FAILED_ERROR_MSG, join_node_id_)); |
| 1112 | } |
| 1113 | RETURN_IF_ERROR(CreateHashPartitions(new_level)); |
| 1114 | |
| 1115 | // Repartition 'input_stream' into 'hash_partitions_'. |
| 1116 | RowBatch build_batch(row_desc_, state->batch_size(), mem_tracker()); |
| 1117 | bool eos = false; |
| 1118 | while (!eos) { |
| 1119 | RETURN_IF_CANCELLED(state); |
| 1120 | RETURN_IF_ERROR(state->CheckQueryState()); |
| 1121 | |
| 1122 | RETURN_IF_ERROR(build_rows->GetNext(&build_batch, &eos)); |
| 1123 | RETURN_IF_ERROR(AddBatch(&build_batch)); |
| 1124 | build_batch.Reset(); |
| 1125 | } |
| 1126 | |
| 1127 | // Done reading the input, we can safely close it now to free memory. |
| 1128 | input_partition->Close(nullptr); |
| 1129 | RETURN_IF_ERROR(FinalizeBuild(state)); |
| 1130 | return Status::OK(); |
| 1131 | } |
| 1132 | |
| 1133 | int64_t PhjBuilder::LargestPartitionRows() const { |
| 1134 | int64_t max_rows = 0; |
nothing calls this directly
no test coverage detected