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

Method searchFrameValue

bolt/exec/WindowPartition.cpp:214–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212// show good locality this could give good results.
213template <typename BoundTest>
214vector_size_t WindowPartition::searchFrameValue(
215 const RangeSearchParams<BoundTest>& params,
216 vector_size_t start,
217 column_index_t orderByColumn,
218 column_index_t frameColumn) const {
219 auto startRow = partition_[start];
220 auto order = sortKeyInfo_[0].second;
221 for (vector_size_t i = start; i >= 0 && i < numRows(); i += params.step) {
222 auto compareResult = data_->compare(
223 partition_[i],
224 startRow,
225 orderByColumn,
226 frameColumn,
227 {order.isNullsFirst(), order.isAscending(), false});
228
229 // The bound value was found. Return if firstMatch required.
230 // If the last match is required, then we need to find the first row that
231 // crosses the bound and return the previous (or following, based on skip)
232 // row.
233 if (compareResult == 0) {
234 if (params.firstMatch) {
235 return i;
236 }
237 }
238
239 // Bound is crossed. Last match needs the previous row.
240 // But for first row matches, this is the first
241 // row that has crossed, but not equals boundary (The equal boundary case
242 // is covered by the condition above). So the bound matches this row itself.
243 if (params.boundTest(compareResult)) {
244 return params.firstMatch ? i : i - params.step;
245 }
246 }
247
248 // Return a row beyond the partition boundary. The logic to determine valid
249 // frames handles the out of bound and empty frames from this value.
250 return params.step == 1 ? numRows() + 1 : -1;
251}
252
253template <typename BoundTest>
254void WindowPartition::updateKRangeFrameBounds(

Callers

nothing calls this directly

Calls 7

isNullsFirstMethod · 0.80
isAscendingMethod · 0.80
columnTypesMethod · 0.80
CompareFlagsClass · 0.50
compareMethod · 0.45
kindMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected