MCPcopy Create free account
hub / github.com/bytedance/bolt / getOutput

Method getOutput

bolt/exec/PartitionedOutput.cpp:323–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323RowVectorPtr PartitionedOutput::getOutput() {
324 if (finished_) {
325 return nullptr;
326 }
327
328 blockingReason_ = BlockingReason::kNotBlocked;
329 detail::Destination* blockedDestination = nullptr;
330 auto bufferManager = bufferManager_.lock();
331 BOLT_CHECK_NOT_NULL(
332 bufferManager, "OutputBufferManager was already destructed");
333
334 // Limit serialized pages to 1MB.
335 static const uint64_t kMaxPageSize = 1 << 20;
336 const uint64_t maxPageSize = std::max<uint64_t>(
337 kMinDestinationSize,
338 std::min<uint64_t>(kMaxPageSize, maxBufferedBytes_ / numDestinations_));
339
340 bool workLeft;
341 do {
342 workLeft = false;
343 for (auto& destination : destinations_) {
344 bool atEnd = false;
345 blockingReason_ = destination->advance(
346 maxPageSize,
347 rowSize_,
348 output_,
349 *bufferManager,
350 bufferReleaseFn_,
351 &atEnd,
352 &future_,
353 scratch_);
354 if (blockingReason_ != BlockingReason::kNotBlocked) {
355 blockedDestination = destination.get();
356 workLeft = false;
357 // We stop on first blocked. Adding data to unflushed targets
358 // would be possible but could allocate memory. We wait for
359 // free space in the outgoing queue.
360 break;
361 }
362 if (!atEnd) {
363 workLeft = true;
364 }
365 }
366 } while (workLeft);
367
368 if (blockedDestination) {
369 // If we are going off-thread, we may as well make the output in
370 // progress for other destinations available, unless it is too
371 // small to be worth transfer.
372 for (auto& destination : destinations_) {
373 if (destination.get() == blockedDestination ||
374 destination->serializedBytes() < kMinDestinationSize) {
375 continue;
376 }
377 destination->flush(*bufferManager, bufferReleaseFn_, nullptr);
378 }
379 return nullptr;
380 }

Callers

nothing calls this directly

Calls 9

lockMethod · 0.80
serializedBytesMethod · 0.80
setFinishedMethod · 0.80
taskMethod · 0.80
advanceMethod · 0.45
getMethod · 0.45
flushMethod · 0.45
isFinishedMethod · 0.45
noMoreDataMethod · 0.45

Tested by

no test coverage detected