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

Method getOutput

bolt/exec/Window.cpp:917–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917RowVectorPtr Window::getOutput() {
918 MicrosecondTimer timer(&computeWindowFunctionTimeUs_);
919 if (needSort_ && !noMoreInput_) {
920 return nullptr;
921 }
922 if (isFinished()) {
923 recordWindowStats();
924 if (numRows_ == 0 || numRows_ - numProcessedRows_ == 0) {
925 windowBuild_->finish();
926 }
927 }
928
929 if (numRows_ == 0) {
930 return nullptr;
931 }
932
933 auto numRowsLeft = numRows_ - numProcessedRows_;
934 if (numRowsLeft == 0) {
935 return nullptr;
936 }
937
938 if (!currentPartition_) {
939 callResetPartition();
940 if (!currentPartition_) {
941 // WindowBuild doesn't have a partition to output.
942 if (isFinished()) {
943 windowBuild_->finish();
944 }
945 return nullptr;
946 }
947 }
948
949 if (isSpillableWindowBuild_ && currentPartition_->isSpilled()) {
950 return getOutputFromSpilledPartition();
951 }
952
953 if (currentPartition_->supportRowsStreaming() &&
954 partitionOffset_ == currentPartition_->numRows()) {
955 if (!currentPartition_->buildNextRows()) {
956 windowBuild_->loadNextPartialPartitionFromSpill();
957 return nullptr;
958 }
959 }
960
961 auto numOutputRows = std::min(numRowsPerOutput_, numRowsLeft);
962 auto usedBytes = operatorCtx_->pool()->currentBytes();
963 auto result = BaseVector::create<RowVector>(
964 outputType_, numOutputRows, operatorCtx_->pool());
965
966 // Compute the output values of window functions.
967 auto numResultRows = callApplyLoop(numOutputRows, result);
968 if (numRows_ == 0 || numRows_ - numProcessedRows_ == 0) {
969 windowBuild_->finish();
970 }
971
972 auto resultBytes = operatorCtx_->pool()->currentBytes() - usedBytes;
973 std::optional<uint64_t> resultRowSize = resultBytes / numResultRows;
974

Callers

nothing calls this directly

Calls 11

setNumRowsPerOutputMethod · 0.80
minFunction · 0.50
finishMethod · 0.45
isSpilledMethod · 0.45
supportRowsStreamingMethod · 0.45
numRowsMethod · 0.45
buildNextRowsMethod · 0.45
currentBytesMethod · 0.45
poolMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected