-
Notifications
You must be signed in to change notification settings - Fork 492
[lake/paimon] Support paimon tiering factory #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
fluss-common/src/main/java/com/alibaba/fluss/lakehouse/committer/CommitterInitContext.java
This file contains hidden or 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,37 @@ | ||
| /* | ||
| * Copyright (c) 2025 Alibaba Group Holding Ltd. | ||
| * | ||
| * Licensed 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 com.alibaba.fluss.lakehouse.committer; | ||
|
|
||
| import com.alibaba.fluss.annotation.PublicEvolving; | ||
| import com.alibaba.fluss.metadata.TablePath; | ||
|
|
||
| /** | ||
| * The CommitterInitContext interface provides the context needed to create a LakeCommitter. It | ||
| * includes methods to obtain the table path. | ||
| * | ||
| * @since 0.7 | ||
| */ | ||
| @PublicEvolving | ||
| public interface CommitterInitContext { | ||
|
|
||
| /** | ||
| * Returns the table path. | ||
| * | ||
| * @return the table path | ||
| */ | ||
| TablePath tablePath(); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
176 changes: 176 additions & 0 deletions
176
...ke-paimon/src/main/java/com/alibaba/fluss/lake/paimon/tiering/FlussRecordAsPaimonRow.java
This file contains hidden or 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,176 @@ | ||
| /* | ||
| * Copyright (c) 2025 Alibaba Group Holding Ltd. | ||
| * | ||
| * Licensed 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 com.alibaba.fluss.lake.paimon.tiering; | ||
|
|
||
| import com.alibaba.fluss.record.LogRecord; | ||
| import com.alibaba.fluss.row.TimestampLtz; | ||
|
|
||
| import org.apache.paimon.data.BinaryString; | ||
| import org.apache.paimon.data.Decimal; | ||
| import org.apache.paimon.data.InternalArray; | ||
| import org.apache.paimon.data.InternalMap; | ||
| import org.apache.paimon.data.InternalRow; | ||
| import org.apache.paimon.data.Timestamp; | ||
| import org.apache.paimon.types.RowKind; | ||
|
|
||
| import static com.alibaba.fluss.lake.paimon.utils.PaimonConversions.toRowKind; | ||
|
|
||
| /** To wrap Fluss {@link LogRecord} as paimon {@link InternalRow}. */ | ||
| public class FlussRecordAsPaimonRow implements InternalRow { | ||
|
|
||
| private final int bucket; | ||
| private LogRecord logRecord; | ||
| private int originRowFieldCount; | ||
| private com.alibaba.fluss.row.InternalRow internalRow; | ||
|
|
||
| public FlussRecordAsPaimonRow(int bucket) { | ||
| this.bucket = bucket; | ||
| } | ||
|
|
||
| public void setFlussRecord(LogRecord logRecord) { | ||
| this.logRecord = logRecord; | ||
| this.internalRow = logRecord.getRow(); | ||
| this.originRowFieldCount = internalRow.getFieldCount(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getFieldCount() { | ||
| return | ||
| // three system fields: bucket, offset, timestamp | ||
| originRowFieldCount + 3; | ||
| } | ||
|
|
||
| @Override | ||
| public RowKind getRowKind() { | ||
| return toRowKind(logRecord.getChangeType()); | ||
| } | ||
|
|
||
| @Override | ||
| public void setRowKind(RowKind rowKind) { | ||
| // do nothing | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int pos) { | ||
| if (pos < originRowFieldCount) { | ||
| return internalRow.isNullAt(pos); | ||
| } | ||
| // is the last three system fields: bucket, offset, timestamp which are never null | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getBoolean(int pos) { | ||
| return internalRow.getBoolean(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public byte getByte(int pos) { | ||
| return internalRow.getByte(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public short getShort(int pos) { | ||
| return internalRow.getShort(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public int getInt(int pos) { | ||
| if (pos == originRowFieldCount) { | ||
| // bucket system column | ||
| return bucket; | ||
| } | ||
| return internalRow.getInt(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public long getLong(int pos) { | ||
| if (pos == originRowFieldCount + 1) { | ||
| // offset system column | ||
| return logRecord.logOffset(); | ||
| } else if (pos == originRowFieldCount + 2) { | ||
| // timestamp system column | ||
| return logRecord.timestamp(); | ||
| } | ||
| // the origin RowData | ||
| return internalRow.getLong(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public float getFloat(int pos) { | ||
| return internalRow.getFloat(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public double getDouble(int pos) { | ||
| return internalRow.getDouble(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public BinaryString getString(int pos) { | ||
| return BinaryString.fromBytes(internalRow.getString(pos).toBytes()); | ||
| } | ||
|
|
||
| @Override | ||
| public Decimal getDecimal(int pos, int precision, int scale) { | ||
| com.alibaba.fluss.row.Decimal flussDecimal = internalRow.getDecimal(pos, precision, scale); | ||
| if (flussDecimal.isCompact()) { | ||
| return Decimal.fromUnscaledLong(flussDecimal.toUnscaledLong(), precision, scale); | ||
| } else { | ||
| return Decimal.fromBigDecimal(flussDecimal.toBigDecimal(), precision, scale); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Timestamp getTimestamp(int pos, int precision) { | ||
| // it's timestamp system column | ||
| if (pos == originRowFieldCount + 2) { | ||
| return Timestamp.fromEpochMillis(logRecord.timestamp()); | ||
| } | ||
| if (TimestampLtz.isCompact(precision)) { | ||
| return Timestamp.fromEpochMillis( | ||
| internalRow.getTimestampLtz(pos, precision).getEpochMillisecond()); | ||
| } else { | ||
| TimestampLtz timestampLtz = internalRow.getTimestampLtz(pos, precision); | ||
| return Timestamp.fromEpochMillis( | ||
| timestampLtz.getEpochMillisecond(), timestampLtz.getNanoOfMillisecond()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public byte[] getBinary(int pos) { | ||
| return internalRow.getBytes(pos); | ||
| } | ||
|
|
||
| @Override | ||
| public InternalArray getArray(int pos) { | ||
| throw new UnsupportedOperationException( | ||
| "getArray is not support for Fluss record currently."); | ||
| } | ||
|
|
||
| @Override | ||
| public InternalMap getMap(int pos) { | ||
| throw new UnsupportedOperationException( | ||
| "getMap is not support for Fluss record currently."); | ||
| } | ||
|
|
||
| @Override | ||
| public InternalRow getRow(int pos, int pos1) { | ||
| throw new UnsupportedOperationException( | ||
| "getRow is not support for Fluss record currently."); | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
...ake-paimon/src/main/java/com/alibaba/fluss/lake/paimon/tiering/PaimonCatalogProvider.java
This file contains hidden or 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,43 @@ | ||
| /* | ||
| * Copyright (c) 2025 Alibaba Group Holding Ltd. | ||
| * | ||
| * Licensed 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 com.alibaba.fluss.lake.paimon.tiering; | ||
|
|
||
| import com.alibaba.fluss.config.Configuration; | ||
|
|
||
| import org.apache.paimon.catalog.Catalog; | ||
| import org.apache.paimon.catalog.CatalogContext; | ||
| import org.apache.paimon.catalog.CatalogFactory; | ||
| import org.apache.paimon.options.Options; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| /** A provider for Paimon catalog. */ | ||
| public class PaimonCatalogProvider implements Serializable { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private final Configuration paimonConfig; | ||
|
|
||
| public PaimonCatalogProvider(Configuration paimonConfig) { | ||
| this.paimonConfig = paimonConfig; | ||
| } | ||
|
|
||
| public Catalog get() { | ||
| return CatalogFactory.createCatalog( | ||
| CatalogContext.create(Options.fromMap(paimonConfig.toMap()))); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
...ss-lake-paimon/src/main/java/com/alibaba/fluss/lake/paimon/tiering/PaimonCommittable.java
This file contains hidden or 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,33 @@ | ||
| /* | ||
| * Copyright (c) 2025 Alibaba Group Holding Ltd. | ||
| * | ||
| * Licensed 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 com.alibaba.fluss.lake.paimon.tiering; | ||
|
|
||
| import org.apache.paimon.manifest.ManifestCommittable; | ||
|
|
||
| /** The committable that derived from {@link PaimonWriteResult} to commit to Paimon. */ | ||
| public class PaimonCommittable { | ||
|
|
||
| private final ManifestCommittable manifestCommittable; | ||
|
|
||
| public PaimonCommittable(ManifestCommittable manifestCommittable) { | ||
| this.manifestCommittable = manifestCommittable; | ||
| } | ||
|
|
||
| public ManifestCommittable manifestCommittable() { | ||
| return manifestCommittable; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all lake formats' snapshot id use long type? otherwise generic type is recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in the previous investigation, all known lake formats, paimon, iceberg, delta, hudi can use long type to represent snapshot or other simliar concept, like timeline in hudi.