-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(over window): generalize WindowBuffer
and window function AggregateState
#14647
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
buffer_ref.curr_idx < buffer_ref.buffer.len() && { | ||
let start_off = self.frame_bounds.start.to_offset(); | ||
if let Some(start_off) = start_off { | ||
if start_off >= 0 { | ||
true // pure following frame, always preceding-saturated | ||
} else { | ||
// FIXME(rc): Clippy rule `clippy::nonminimal_bool` is misreporting that | ||
// the following can be simplified. | ||
#[allow(clippy::nonminimal_bool)] | ||
{ | ||
assert!(buffer_ref.curr_idx >= buffer_ref.left_idx); | ||
} | ||
buffer_ref.curr_idx - buffer_ref.left_idx >= start_off.unsigned_abs() | ||
} | ||
} else { | ||
false // unbounded frame start, never preceding-saturated | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Algorithm not changed, only moved
buffer_ref.curr_idx < buffer_ref.buffer.len() && { | ||
let end_off = self.frame_bounds.end.to_offset(); | ||
if let Some(end_off) = end_off { | ||
if end_off <= 0 { | ||
true // pure preceding frame, always following-saturated | ||
} else { | ||
// FIXME(rc): Ditto. | ||
#[allow(clippy::nonminimal_bool)] | ||
{ | ||
assert!(buffer_ref.right_excl_idx > 0); | ||
assert!(buffer_ref.right_excl_idx > buffer_ref.curr_idx); | ||
assert!(buffer_ref.right_excl_idx <= buffer_ref.buffer.len()); | ||
} | ||
buffer_ref.right_excl_idx - 1 - buffer_ref.curr_idx >= end_off as usize | ||
} | ||
} else { | ||
false // unbounded frame end, never following-saturated | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Algorithm not changed, only moved
if buffer_ref.buffer.is_empty() { | ||
*buffer_ref.left_idx = 0; | ||
*buffer_ref.right_excl_idx = 0; | ||
} | ||
|
||
let start_off = self.frame_bounds.start.to_offset(); | ||
let end_off = self.frame_bounds.end.to_offset(); | ||
if let Some(start_off) = start_off { | ||
let logical_left_idx = *buffer_ref.curr_idx as isize + start_off; | ||
if logical_left_idx >= 0 { | ||
*buffer_ref.left_idx = | ||
std::cmp::min(logical_left_idx as usize, buffer_ref.buffer.len()); | ||
} else { | ||
*buffer_ref.left_idx = 0; | ||
} | ||
} else { | ||
// unbounded start | ||
*buffer_ref.left_idx = 0; | ||
} | ||
if let Some(end_off) = end_off { | ||
let logical_right_excl_idx = *buffer_ref.curr_idx as isize + end_off + 1; | ||
if logical_right_excl_idx >= 0 { | ||
*buffer_ref.right_excl_idx = | ||
std::cmp::min(logical_right_excl_idx as usize, buffer_ref.buffer.len()); | ||
} else { | ||
*buffer_ref.right_excl_idx = 0; | ||
} | ||
} else { | ||
// unbounded end | ||
*buffer_ref.right_excl_idx = buffer_ref.buffer.len(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Algorithm not changed, only moved
3181b68
to
e2e4eb1
Compare
27c8004
to
980d29d
Compare
e2e4eb1
to
5bd2c0e
Compare
980d29d
to
dfe1a5b
Compare
5bd2c0e
to
56ad72f
Compare
c25c28f
to
8f5ed91
Compare
56ad72f
to
4b99ab1
Compare
8f5ed91
to
d3eba36
Compare
4b99ab1
to
6a55390
Compare
d3eba36
to
9933c72
Compare
6a55390
to
d7cf817
Compare
d23eeca
to
bd2ed75
Compare
15fd42d
to
9cd74ef
Compare
bd2ed75
to
16f5d06
Compare
9cd74ef
to
58054c8
Compare
16f5d06
to
58d9f5d
Compare
82b2728
to
b5f5a39
Compare
58d9f5d
to
8d89879
Compare
b5f5a39
to
9ae199f
Compare
8d89879
to
21e2a86
Compare
a148e1c
to
b2653b5
Compare
21e2a86
to
12760a7
Compare
c002f15
to
9e8731e
Compare
12760a7
to
c44e1fe
Compare
c44e1fe
to
622719f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest LGTM. Most changes are restructuring.
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
622719f
to
86795a0
Compare
type Value: Clone; | ||
|
||
/// Whether the preceding half of the current window is saturated. | ||
/// By "saturated" we mean that every row that is possible to be in the preceding half of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel confused from my understanding of the English word "saturated" 😕
How about "buffered", "loaded" or "cached"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can change the word later
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
This PR generalizes
WindowBuffer
andAggregateState
so that window aggregation for calls withRANGE
frames can be easily supported by just adding a newWindowImpl
implementation.Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.