MCPcopy Create free account
hub / github.com/apache/impala / MergeAndSpill

Method MergeAndSpill

be/src/runtime/sorter.cc:1226–1256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224}
1225
1226Status Sorter::MergeAndSpill() {
1227 // The last minirun might have been created just before we ran out of memory.
1228 // In this case it should not be sorted and merged.
1229 if (unsorted_run_->run_size() == 0){
1230 unsorted_run_ = nullptr;
1231 } else {
1232 RETURN_IF_ERROR(SortCurrentInputRun());
1233 sorted_inmem_runs_.push_back(unsorted_run_);
1234 }
1235
1236 // If only 1 run was created, do not merge.
1237 if (sorted_inmem_runs_.size() == 1) {
1238 sorted_runs_.push_back(sorted_inmem_runs_.back());
1239 sorted_inmem_runs_.clear();
1240 DCHECK_GT(sorted_runs_.back()->fixed_len_size(), 0);
1241 RETURN_IF_ERROR(sorted_runs_.back()->UnpinAllPages());
1242 // If 'merge_output_run_' was initialized but no merge was executed,
1243 // set it back to nullptr.
1244 if (merge_output_run_ != nullptr){
1245 merge_output_run_->CloseAllPages();
1246 merge_output_run_ = nullptr;
1247 }
1248 } else {
1249 DCHECK(merge_output_run_ != nullptr) << "Should have reserved memory for the merger.";
1250 RETURN_IF_ERROR(MergeInMemoryRuns());
1251 DCHECK(merge_output_run_ == nullptr) << "Should have finished previous merge.";
1252 }
1253
1254 DCHECK(sorted_inmem_runs_.empty());
1255 return Status::OK();
1256}
1257
1258bool Sorter::MustSortAndSpill(const int rows_added, const int batch_num_rows) {
1259 if (rows_added < batch_num_rows) {

Callers

nothing calls this directly

Calls 9

OKFunction · 0.85
run_sizeMethod · 0.80
push_backMethod · 0.80
fixed_len_sizeMethod · 0.80
UnpinAllPagesMethod · 0.80
CloseAllPagesMethod · 0.80
clearMethod · 0.65
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected