257183 {
257184 auto &gpeer = sink.global_state.Cast<WindowPeerGlobalState>();
257185 auto &lpeer = sink.local_state.Cast<WindowPeerLocalState>();
257186
257187 auto &order_mask = gpeer.order_mask;
257188 auto partition_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PARTITION_BEGIN]);
257189 auto peer_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PEER_BEGIN]);
257190 auto rdata = FlatVector::GetData<int64_t>(result);
257191
257192
257193
257194
257195
257196
257197 if (lpeer.row_idx != row_idx) {
257198 lpeer.rank = (peer_begin[0] - partition_begin[0]) + 1;
257199 lpeer.rank_equal = (row_idx - peer_begin[0]);
257200
257201
257202 lpeer.dense_rank = 0;
257203
257204 auto order_begin = partition_begin[0];
257206 idx_t begin_offset;
257207 order_mask.GetEntryIndex(order_begin, begin_idx, begin_offset);
257208
257209 auto order_end = row_idx;
257212 order_mask.GetEntryIndex(order_end, end_idx, end_offset);
257213
257214
257215 if (begin_idx == end_idx) {
257216 const auto entry = order_mask.GetValidityEntry(begin_idx);
257217 for (; begin_offset < end_offset; ++begin_offset) {
257218 lpeer.dense_rank += order_mask.RowIsValid(entry, begin_offset);
257219 }
257220 } else {
257221
257222 if (begin_offset) {
257223 const auto entry = order_mask.GetValidityEntry(begin_idx);
257224 for (; begin_offset < order_mask.BITS_PER_VALUE; ++begin_offset) {
257225 lpeer.dense_rank += order_mask.RowIsValid(entry, begin_offset);
257226 ++order_begin;
257227 }
257228 ++begin_idx;
257229 }
257230
257231
257232 ValidityMask tail_mask(order_mask.GetData() + begin_idx, end_idx - begin_idx);
257233 lpeer.dense_rank += tail_mask.CountValid(order_end - order_begin);
257234 }
257235 }
257236
257237 for (
idx_t i = 0; i < count; ++i, ++row_idx) {
257238 lpeer.NextRank(partition_begin[i], peer_begin[i], row_idx);
257239 rdata[i] = NumericCast<int64_t>(lpeer.dense_rank);
257240 }
257241
257242
257243 lpeer.row_idx = row_idx;
257244}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237