JingsongLi commented on code in PR #104:
URL: https://github.com/apache/flink-table-store/pull/104#discussion_r859320053
##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/SortBufferMemTable.java:
##########
@@ -166,19 +169,31 @@ private void advanceIfNeeded() {
if (previousRow == null) {
return;
}
- mergeFunction.reset();
- mergeFunction.add(previous.getReusedKv().value());
+ boolean hasOne = true;
while (readOnce()) {
if (keyComparator.compare(
previous.getReusedKv().key(),
current.getReusedKv().key())
!= 0) {
break;
}
+ // avoid merging when there is only one record
+ if (hasOne) {
+ mergeFunction.reset();
+ mergeFunction.add(previous.getReusedKv().value());
+ hasOne = false;
+ }
mergeFunction.add(current.getReusedKv().value());
swapSerializers();
}
- result = mergeFunction.getValue();
+ RowData previousValue = previous.getReusedKv().value();
+ result =
+ hasOne
+ ? mergeFunction instanceof
ValueCountMergeFunction
Review Comment:
I think we can ignore that count is zero for `ValueCountMergeFunction`.
Because if there is no merge, the count should never be zero.
##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/mergetree/SortBufferMemTable.java:
##########
@@ -166,19 +169,31 @@ private void advanceIfNeeded() {
if (previousRow == null) {
return;
}
- mergeFunction.reset();
- mergeFunction.add(previous.getReusedKv().value());
+ boolean hasOne = true;
Review Comment:
`hasOne = true` -> `mergeFuncInitialized = false`?
--
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]