This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 9aafa2a689 [core] refactor: delete snapshot commit factory (#5686)
9aafa2a689 is described below
commit 9aafa2a689554645baf6abbcf4b07e52279d8ce5
Author: jerry <[email protected]>
AuthorDate: Tue Jun 3 14:02:28 2025 +0800
[core] refactor: delete snapshot commit factory (#5686)
---
.../paimon/catalog/CatalogSnapshotCommit.java | 20 ----------
.../paimon/catalog/RenamingSnapshotCommit.java | 43 ----------------------
.../org/apache/paimon/catalog/SnapshotCommit.java | 7 ----
.../apache/paimon/table/CatalogEnvironment.java | 15 ++++++--
4 files changed, 11 insertions(+), 74 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogSnapshotCommit.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogSnapshotCommit.java
index c7d61a2f58..b49f1a12ef 100644
---
a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogSnapshotCommit.java
+++
b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogSnapshotCommit.java
@@ -20,7 +20,6 @@ package org.apache.paimon.catalog;
import org.apache.paimon.Snapshot;
import org.apache.paimon.partition.PartitionStatistics;
-import org.apache.paimon.utils.SnapshotManager;
import javax.annotation.Nullable;
@@ -51,23 +50,4 @@ public class CatalogSnapshotCommit implements SnapshotCommit
{
public void close() throws Exception {
catalog.close();
}
-
- /** Factory to create {@link CatalogSnapshotCommit}. */
- public static class Factory implements SnapshotCommit.Factory {
-
- private static final long serialVersionUID = 1L;
-
- private final CatalogLoader catalogLoader;
- @Nullable private final String uuid;
-
- public Factory(CatalogLoader catalogLoader, @Nullable String uuid) {
- this.catalogLoader = catalogLoader;
- this.uuid = uuid;
- }
-
- @Override
- public SnapshotCommit create(Identifier identifier, SnapshotManager
snapshotManager) {
- return new CatalogSnapshotCommit(catalogLoader.load(), identifier,
uuid);
- }
- }
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java
index 9c75e2d24b..5cc9d2a019 100644
---
a/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java
+++
b/paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java
@@ -19,17 +19,13 @@
package org.apache.paimon.catalog;
import org.apache.paimon.Snapshot;
-import org.apache.paimon.annotation.VisibleForTesting;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.operation.Lock;
import org.apache.paimon.partition.PartitionStatistics;
import org.apache.paimon.utils.SnapshotManager;
-import javax.annotation.Nullable;
-
import java.util.List;
-import java.util.Optional;
import java.util.concurrent.Callable;
/**
@@ -80,43 +76,4 @@ public class RenamingSnapshotCommit implements
SnapshotCommit {
public void close() throws Exception {
this.lock.close();
}
-
- /** Factory to create {@link RenamingSnapshotCommit}. */
- public static class Factory implements SnapshotCommit.Factory {
-
- private static final long serialVersionUID = 1L;
-
- @Nullable private final CatalogLockFactory lockFactory;
- @Nullable private final CatalogLockContext lockContext;
-
- public Factory(
- @Nullable CatalogLockFactory lockFactory,
- @Nullable CatalogLockContext lockContext) {
- this.lockFactory = lockFactory;
- this.lockContext = lockContext;
- }
-
- @Override
- public RenamingSnapshotCommit create(
- Identifier identifier, SnapshotManager snapshotManager) {
- Lock lock =
- Optional.ofNullable(lockFactory)
- .map(factory -> factory.createLock(lockContext))
- .map(l -> Lock.fromCatalog(l, identifier))
- .orElseGet(Lock::empty);
- return new RenamingSnapshotCommit(snapshotManager, lock);
- }
-
- @VisibleForTesting
- @Nullable
- public CatalogLockFactory lockFactory() {
- return lockFactory;
- }
-
- @VisibleForTesting
- @Nullable
- public CatalogLockContext lockContext() {
- return lockContext;
- }
- }
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/SnapshotCommit.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/SnapshotCommit.java
index 927952d172..43abacd7b6 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/SnapshotCommit.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/SnapshotCommit.java
@@ -20,9 +20,7 @@ package org.apache.paimon.catalog;
import org.apache.paimon.Snapshot;
import org.apache.paimon.partition.PartitionStatistics;
-import org.apache.paimon.utils.SnapshotManager;
-import java.io.Serializable;
import java.util.List;
/** Interface to commit snapshot atomically. */
@@ -30,9 +28,4 @@ public interface SnapshotCommit extends AutoCloseable {
boolean commit(Snapshot snapshot, String branch, List<PartitionStatistics>
statistics)
throws Exception;
-
- /** Factory to create {@link SnapshotCommit}. */
- interface Factory extends Serializable {
- SnapshotCommit create(Identifier identifier, SnapshotManager
snapshotManager);
- }
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
b/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
index aeb9575bf1..fd20d88951 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
@@ -27,6 +27,7 @@ import org.apache.paimon.catalog.CatalogSnapshotCommit;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.catalog.RenamingSnapshotCommit;
import org.apache.paimon.catalog.SnapshotCommit;
+import org.apache.paimon.operation.Lock;
import org.apache.paimon.table.source.TableQueryAuth;
import org.apache.paimon.tag.SnapshotLoaderImpl;
import org.apache.paimon.utils.SnapshotLoader;
@@ -36,6 +37,7 @@ import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.Collections;
+import java.util.Optional;
/** Catalog environment in table which contains log factory, metastore client
factory. */
public class CatalogEnvironment implements Serializable {
@@ -93,13 +95,18 @@ public class CatalogEnvironment implements Serializable {
@Nullable
public SnapshotCommit snapshotCommit(SnapshotManager snapshotManager) {
- SnapshotCommit.Factory factory;
+ SnapshotCommit snapshotCommit;
if (catalogLoader != null && supportsVersionManagement) {
- factory = new CatalogSnapshotCommit.Factory(catalogLoader, uuid);
+ snapshotCommit = new CatalogSnapshotCommit(catalogLoader.load(),
identifier, uuid);
} else {
- factory = new RenamingSnapshotCommit.Factory(lockFactory,
lockContext);
+ Lock lock =
+ Optional.ofNullable(lockFactory)
+ .map(factory -> factory.createLock(lockContext))
+ .map(l -> Lock.fromCatalog(l, identifier))
+ .orElseGet(Lock::empty);
+ snapshotCommit = new RenamingSnapshotCommit(snapshotManager, lock);
}
- return factory.create(identifier, snapshotManager);
+ return snapshotCommit;
}
@Nullable