-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Add support of sequence field in first row
- Loading branch information
Showing
23 changed files
with
554 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
paimon-core/src/main/java/org/apache/paimon/mergetree/UnOrderedFirstRowMergeFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.paimon.mergetree; | ||
|
||
import org.apache.paimon.KeyValue; | ||
import org.apache.paimon.mergetree.compact.FirstRowMergeFunction; | ||
import org.apache.paimon.mergetree.compact.MergeFunction; | ||
import org.apache.paimon.mergetree.compact.MergeFunctionFactory; | ||
import org.apache.paimon.types.RowType; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is the same as FirstRowMergeFunction, but it is specifically for merging unordered | ||
* input. | ||
*/ | ||
public class UnOrderedFirstRowMergeFunction extends FirstRowMergeFunction { | ||
protected UnOrderedFirstRowMergeFunction(RowType keyType, RowType valueType) { | ||
super(keyType, valueType); | ||
} | ||
|
||
public static MergeFunctionFactory<KeyValue> factory(RowType keyType, RowType valueType) { | ||
return new UnOrderedFirstRowMergeFunction.Factory(keyType, valueType); | ||
} | ||
|
||
private static class Factory implements MergeFunctionFactory<KeyValue> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
private final RowType keyType; | ||
private final RowType valueType; | ||
|
||
public Factory(RowType keyType, RowType valueType) { | ||
this.keyType = keyType; | ||
this.valueType = valueType; | ||
} | ||
|
||
@Override | ||
public MergeFunction<KeyValue> create(@Nullable int[][] projection) { | ||
return new UnOrderedFirstRowMergeFunction(keyType, valueType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../main/java/org/apache/paimon/mergetree/compact/UnOrderedFirstRowMergeFunctionWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.paimon.mergetree.compact; | ||
|
||
import org.apache.paimon.KeyValue; | ||
import org.apache.paimon.codegen.RecordEqualiser; | ||
import org.apache.paimon.data.InternalRow; | ||
import org.apache.paimon.deletionvectors.DeletionVectorsMaintainer; | ||
import org.apache.paimon.lookup.LookupStrategy; | ||
import org.apache.paimon.types.RowKind; | ||
import org.apache.paimon.utils.UserDefinedSeqComparator; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import java.util.function.Function; | ||
|
||
/** Wrapper for {@link MergeFunction}s to produce changelog by lookup for first row. */ | ||
public class UnOrderedFirstRowMergeFunctionWrapper<T> | ||
extends LookupChangelogMergeFunctionWrapper<T> { | ||
|
||
private final KeyValue reusedBefore = new KeyValue(); | ||
private final KeyValue reusedAfter = new KeyValue(); | ||
|
||
public UnOrderedFirstRowMergeFunctionWrapper( | ||
MergeFunctionFactory<KeyValue> mergeFunctionFactory, | ||
Function<InternalRow, T> lookup, | ||
RecordEqualiser valueEqualiser, | ||
boolean changelogRowDeduplicate, | ||
LookupStrategy lookupStrategy, | ||
@Nullable DeletionVectorsMaintainer deletionVectorsMaintainer, | ||
@Nullable UserDefinedSeqComparator userDefinedSeqComparator) { | ||
super( | ||
mergeFunctionFactory, | ||
lookup, | ||
valueEqualiser, | ||
changelogRowDeduplicate, | ||
lookupStrategy, | ||
deletionVectorsMaintainer, | ||
userDefinedSeqComparator); | ||
} | ||
|
||
@Override | ||
protected void setChangelog( | ||
@Nullable KeyValue before, KeyValue after, ChangelogResult reusedResult) { | ||
if (after.level() == 0) { | ||
if (before == null) { | ||
reusedResult.addChangelog(after); | ||
} else { | ||
reusedResult | ||
.addChangelog(replace(reusedBefore, RowKind.UPDATE_BEFORE, before)) | ||
.addChangelog(replace(reusedAfter, RowKind.UPDATE_AFTER, after)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.