rkhachatryan commented on code in PR #27282:
URL: https://github.com/apache/flink/pull/27282#discussion_r2582756034
##########
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:
Do we also need to move the above line
`minSliceEnd = Math.min(sliceEnd, minSliceEnd);`
inside the loop?
In `flush()`, it might be reset to `Long.MAX_VALUE`, so we'll end up with
the wrong `minSliceEnd` field
##########
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:
Is `getNumKeys` correct and sufficient?
Or should `getNumElements` be used instead or in addition?
In `append()`, I see that `numKeys` is not incremented if `lookupInfo.found`.
I guess there's an implicit invariant that numKeys > 0 in this case, but I'm
not sure.
--
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]