1996fanrui commented on code in PR #27282:
URL: https://github.com/apache/flink/pull/27282#discussion_r2585421585
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/aggregate/window/buffers/RecordsWindowBuffer.java:
##########
@@ -84,14 +85,22 @@ public void addElement(RowData key, long sliceEnd, RowData
element) throws Excep
minSliceEnd = Math.min(sliceEnd, minSliceEnd);
reuseWindowKey.replace(sliceEnd, key);
- LookupInfo<WindowKey, Iterator<RowData>> lookup =
recordsBuffer.lookup(reuseWindowKey);
- try {
- recordsBuffer.append(lookup,
recordSerializer.toBinaryRow(element));
- } catch (EOFException e) {
- // buffer is full, flush it to state
- flush();
- // remember to add the input element again
- addElement(key, sliceEnd, element);
+ while (true) {
+ LookupInfo<WindowKey, Iterator<RowData>> lookup =
recordsBuffer.lookup(reuseWindowKey);
+ try {
+ recordsBuffer.append(lookup,
recordSerializer.toBinaryRow(element));
+ break;
+ } catch (EOFException e) {
+ if (recordsBuffer.getNumKeys() == 0) {
+ // Buffer is empty, retry won't help (record is too large
for the buffer)
+ throw e;
+ }
Review Comment:
They are equivalent.
- One element must have one key
- Every key has at least one element
- `numKeys == 0` ⟺ `numElements == 0` ⟺ buffer is empty
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/aggregate/window/buffers/RecordsWindowBuffer.java:
##########
@@ -84,14 +85,22 @@ public void addElement(RowData key, long sliceEnd, RowData
element) throws Excep
minSliceEnd = Math.min(sliceEnd, minSliceEnd);
reuseWindowKey.replace(sliceEnd, key);
- LookupInfo<WindowKey, Iterator<RowData>> lookup =
recordsBuffer.lookup(reuseWindowKey);
- try {
- recordsBuffer.append(lookup,
recordSerializer.toBinaryRow(element));
- } catch (EOFException e) {
- // buffer is full, flush it to state
- flush();
- // remember to add the input element again
- addElement(key, sliceEnd, element);
+ while (true) {
Review Comment:
Good catch!
I have moved it between `append` and `break`, and introduced a new test to
cover this case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]