JingsongLi commented on code in PR #3461:
URL: https://github.com/apache/paimon/pull/3461#discussion_r1627082105
##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -145,64 +135,69 @@ private void updateNonNullFields(KeyValue kv) {
private void updateWithSequenceGroup(KeyValue kv) {
for (int i = 0; i < getters.length; i++) {
Object field = getters[i].getFieldOrNull(kv.value());
- SequenceGenerator sequenceGen = fieldSequences.get(i);
+ UserDefinedSeqComparator seqComparator =
fieldSeqComparators.get(i);
FieldAggregator aggregator = fieldAggregators.get(i);
Object accumulator = getters[i].getFieldOrNull(row);
- if (sequenceGen == null) {
+ if (seqComparator == null) {
if (aggregator != null) {
row.setField(i, aggregator.agg(accumulator, field));
} else if (field != null) {
row.setField(i, field);
}
} else {
- Long currentSeq = sequenceGen.generate(kv.value());
- if (currentSeq != null) {
- Long previousSeq = sequenceGen.generate(row);
- if (previousSeq == null || currentSeq >= previousSeq) {
- row.setField(
- i, aggregator == null ? field :
aggregator.agg(accumulator, field));
- } else if (aggregator != null) {
- row.setField(i, aggregator.agg(field, accumulator));
+ if (seqComparator.compare(kv.value(), row) >= 0) {
+ int index = i;
+
+ // Multiple sequence fields should be updated at once.
+ if (Arrays.stream(seqComparator.compareFields())
+ .anyMatch(seqIndex -> seqIndex == index)) {
+ for (int fieldIndex : seqComparator.compareFields()) {
+ row.setField(
+ fieldIndex,
getters[fieldIndex].getFieldOrNull(kv.value()));
+ }
}
+ row.setField(
+ i, aggregator == null ? field :
aggregator.agg(accumulator, field));
+ } else if (aggregator != null) {
+ row.setField(i, aggregator.agg(field, accumulator));
Review Comment:
If the sequence field is null, here should not retract it?
--
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]