| 742 | }; // namespace |
| 743 | |
| 744 | void 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( |
nothing calls this directly
no test coverage detected