257259 {
257260 auto &gpeer = sink.global_state.Cast<WindowPeerGlobalState>();
257261 auto &lpeer = sink.local_state.Cast<WindowPeerLocalState>();
257262 auto rdata = FlatVector::GetData<double>(result);
257263
257264 if (gpeer.use_framing) {
257265 auto frame_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[FRAME_BEGIN]);
257266 auto frame_end = FlatVector::GetData<const idx_t>(lpeer.bounds.data[FRAME_END]);
257267 if (gpeer.token_tree) {
257268 for (
idx_t i = 0; i < count; ++i, ++row_idx) {
257269 const auto rank = gpeer.token_tree->Rank(frame_begin[i], frame_end[i], row_idx);
257270 rdata[i] = PercentRank(frame_begin[i], frame_end[i], rank);
257271 }
257272 } else {
257273
257274 auto peer_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PEER_BEGIN]);
257275 for (
idx_t i = 0; i < count; ++i, ++row_idx) {
257276 const auto frame_peer_begin = MaxValue(frame_begin[i], peer_begin[i]);
257277 lpeer.rank = (frame_peer_begin - frame_begin[i]) + 1;
257278 rdata[i] = PercentRank(frame_begin[i], frame_end[i], lpeer.rank);
257279 }
257280 }
257281 return;
257282 }
257283
257284
257285 auto partition_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PARTITION_BEGIN]);
257286 auto partition_end = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PARTITION_END]);
257287 auto peer_begin = FlatVector::GetData<const idx_t>(lpeer.bounds.data[PEER_BEGIN]);
257288 lpeer.rank = (peer_begin[0] - partition_begin[0]) + 1;
257289 lpeer.rank_equal = (row_idx - peer_begin[0]);
257290
257291 for (
idx_t i = 0; i < count; ++i, ++row_idx) {
257292 lpeer.NextRank(partition_begin[i], peer_begin[i], row_idx);
257293 rdata[i] = PercentRank(partition_begin[i], partition_end[i], lpeer.rank);
257294 }
257295}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237