JingsongLi commented on code in PR #1540: URL: https://github.com/apache/incubator-paimon/pull/1540#discussion_r1285408692
########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/ExpireAction.java: ########## @@ -0,0 +1,138 @@ +/* + * 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.flink.action; + +import org.apache.paimon.CoreOptions; +import org.apache.paimon.fs.FileIO; +import org.apache.paimon.fs.Path; +import org.apache.paimon.index.HashIndexFile; +import org.apache.paimon.index.IndexFileHandler; +import org.apache.paimon.manifest.IndexManifestFile; +import org.apache.paimon.manifest.ManifestFile; +import org.apache.paimon.manifest.ManifestList; +import org.apache.paimon.operation.FileStoreExpire; +import org.apache.paimon.operation.FileStoreExpireImpl; +import org.apache.paimon.operation.SnapshotDeletion; +import org.apache.paimon.schema.SchemaManager; +import org.apache.paimon.table.FileStoreTable; +import org.apache.paimon.types.RowType; +import org.apache.paimon.utils.FileStorePathFactory; +import org.apache.paimon.utils.SnapshotManager; +import org.apache.paimon.utils.TagManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + +/** Expire action which provides snapshots expire. */ +public class ExpireAction extends TableActionBase { + + private static final Logger LOG = LoggerFactory.getLogger(ExpireAction.class); + + private final int numRetainedMin; + private final int numRetainedMax; + private final long millisRetained; + private final SnapshotManager snapshotManager; + private final SnapshotDeletion snapshotDeletion; + private final TagManager tagManager; + private final FileStoreExpire fileStoreExpire; + + public ExpireAction( + String warehouse, + String databaseName, + String tableName, + int numRetainedMin, + int numRetainedMax, + long millisRetained, + Map<String, String> catalogConfig) { + super(warehouse, databaseName, tableName, catalogConfig); + this.numRetainedMin = numRetainedMin; + this.numRetainedMax = numRetainedMax; + this.millisRetained = millisRetained; + this.snapshotManager = + new SnapshotManager( + ((FileStoreTable) table).fileIO(), ((FileStoreTable) table).location()); + this.snapshotDeletion = newSnapshotDeletion(); + this.tagManager = newTagManager(); + + this.fileStoreExpire = + new FileStoreExpireImpl( + numRetainedMin, + numRetainedMax, + millisRetained, + snapshotManager, + snapshotDeletion, + tagManager); + } + + private SnapshotDeletion newSnapshotDeletion() { + Path location = ((FileStoreTable) table).location(); Review Comment: Use `FileStoreTable.store().newSnapshotDeletion()`? -- 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]
