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

Method computePeerAndFrameBuffers

bolt/exec/Window.cpp:744–809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}; // namespace
743
744void Window::computePeerAndFrameBuffers(
745 vector_size_t startRow,
746 vector_size_t endRow) {
747 vector_size_t numRows = endRow - startRow;
748 vector_size_t numFuncs = windowFunctions_.size();
749
750 // Size buffers for the call to WindowFunction::apply.
751 auto bufferSize = numRows * sizeof(vector_size_t);
752 peerStartBuffer_->setSize(bufferSize);
753 peerEndBuffer_->setSize(bufferSize);
754 auto rawPeerStarts = peerStartBuffer_->asMutable<vector_size_t>();
755 auto rawPeerEnds = peerEndBuffer_->asMutable<vector_size_t>();
756
757 std::vector<vector_size_t*> rawFrameStarts;
758 std::vector<vector_size_t*> rawFrameEnds;
759 rawFrameStarts.reserve(numFuncs);
760 rawFrameEnds.reserve(numFuncs);
761 for (auto w = 0; w < numFuncs; w++) {
762 frameStartBuffers_[w]->setSize(bufferSize);
763 frameEndBuffers_[w]->setSize(bufferSize);
764
765 auto rawFrameStart = frameStartBuffers_[w]->asMutable<vector_size_t>();
766 auto rawFrameEnd = frameEndBuffers_[w]->asMutable<vector_size_t>();
767 rawFrameStarts.push_back(rawFrameStart);
768 rawFrameEnds.push_back(rawFrameEnd);
769 }
770
771 std::tie(peerStartRow_, peerEndRow_) = currentPartition_->computePeerBuffers(
772 startRow, endRow, peerStartRow_, peerEndRow_, rawPeerStarts, rawPeerEnds);
773 for (auto i = 0; i < numFuncs; i++) {
774 const auto& windowFrame = windowFrames_[i];
775 // Default all rows to have validFrames. The invalidity of frames is only
776 // computed for k rows/range frames at a later point.
777 validFrames_[i].resizeFill(numRows, true);
778 updateFrameBounds(
779 windowFrame,
780 true,
781 startRow,
782 numRows,
783 rawPeerStarts,
784 rawPeerEnds,
785 rawFrameStarts[i]);
786 updateFrameBounds(
787 windowFrame,
788 false,
789 startRow,
790 numRows,
791 rawPeerStarts,
792 rawPeerEnds,
793 rawFrameEnds[i]);
794 if (windowFrames_[i].start || windowFrames_[i].end) {
795 // k preceding and k following bounds can be problematic. They can
796 // go over the partition limits or result in empty frames. Fix the
797 // frame boundaries and compute the validFrames SelectivityVector
798 // for these cases. Not all functions care about validFrames viz.
799 // Ranking functions do not care about frames. So the function decides
800 // further what to do with empty frames.
801 computeValidFrames(

Callers

nothing calls this directly

Calls 8

computeValidFramesFunction · 0.85
computePeerBuffersMethod · 0.80
resizeFillMethod · 0.80
sizeMethod · 0.45
setSizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
numRowsMethod · 0.45

Tested by

no test coverage detected