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 fd8b159c08 [spark] Remove useless Factories for bitmap and lucene
fd8b159c08 is described below

commit fd8b159c08d43c35ca033b4074f5e185ddfca57b
Author: JingsongLi <[email protected]>
AuthorDate: Thu Dec 25 10:54:53 2025 +0800

    [spark] Remove useless Factories for bitmap and lucene
---
 ...Builder.java => DefaultGlobalIndexBuilder.java} | 17 ++-------
 .../globalindex/GlobalIndexBuilderFactory.java     |  2 +-
 .../GlobalIndexBuilderFactoryUtils.java            | 28 +++++++-------
 .../bitmap/BitmapGlobalIndexBuilderFactory.java    | 43 ----------------------
 .../lucene/LuceneGlobalIndexBuilder.java           | 35 ------------------
 .../lucene/LuceneGlobalIndexBuilderFactory.java    | 43 ----------------------
 .../procedure/CreateGlobalIndexProcedure.java      | 13 ++-----
 ...mon.spark.globalindex.GlobalIndexBuilderFactory | 19 ----------
 8 files changed, 22 insertions(+), 178 deletions(-)

diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilder.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/DefaultGlobalIndexBuilder.java
similarity index 60%
rename from 
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilder.java
rename to 
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/DefaultGlobalIndexBuilder.java
index affd6a363a..d2aa11b35c 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilder.java
+++ 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/DefaultGlobalIndexBuilder.java
@@ -16,20 +16,11 @@
  * limitations under the License.
  */
 
-package org.apache.paimon.spark.globalindex.bitmap;
+package org.apache.paimon.spark.globalindex;
 
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
-
-/**
- * Builder for creating bitmap-based global indexes.
- *
- * <p>This implementation does not apply any custom transformations to the 
input dataset, allowing
- * the data to be processed as-is for bitmap index creation.
- */
-public class BitmapGlobalIndexBuilder extends GlobalIndexBuilder {
-
-    protected BitmapGlobalIndexBuilder(GlobalIndexBuilderContext context) {
+/** Default {@link GlobalIndexBuilder}. */
+public class DefaultGlobalIndexBuilder extends GlobalIndexBuilder {
+    public DefaultGlobalIndexBuilder(GlobalIndexBuilderContext context) {
         super(context);
     }
 }
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactory.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactory.java
index d3cd3b7052..a7740f8dc6 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactory.java
+++ 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactory.java
@@ -25,7 +25,7 @@ public interface GlobalIndexBuilderFactory {
 
     GlobalIndexBuilder create(GlobalIndexBuilderContext context);
 
-    default GlobalIndexTopoBuilder createTopoBulder() {
+    default GlobalIndexTopoBuilder createTopoBuilder() {
         return null;
     }
 }
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactoryUtils.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactoryUtils.java
index 23575e532a..18c8a45438 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactoryUtils.java
+++ 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactoryUtils.java
@@ -21,6 +21,8 @@ package org.apache.paimon.spark.globalindex;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.ServiceLoader;
@@ -52,22 +54,20 @@ public class GlobalIndexBuilderFactoryUtils {
         }
     }
 
-    /**
-     * Loads the global index builder factory for the specified type.
-     *
-     * @param indexType The type of index (e.g., "bitmap")
-     * @return The corresponding factory
-     * @throws IllegalArgumentException If no factory is found for the 
specified type
-     */
-    public static GlobalIndexBuilderFactory load(String indexType) {
+    public static GlobalIndexBuilder 
createIndexBuilder(GlobalIndexBuilderContext context) {
+        GlobalIndexBuilderFactory factory = FACTORIES.get(context.indexType());
+        if (factory == null) {
+            return new DefaultGlobalIndexBuilder(context);
+        }
+        return factory.create(context);
+    }
+
+    @Nullable
+    public static GlobalIndexTopoBuilder createTopoBuilder(String indexType) {
         GlobalIndexBuilderFactory factory = FACTORIES.get(indexType);
         if (factory == null) {
-            throw new IllegalArgumentException(
-                    String.format(
-                            "No GlobalIndexBuilderFactory found for index type 
'%s'. "
-                                    + "Available types: %s",
-                            indexType, FACTORIES.keySet()));
+            return null;
         }
-        return factory;
+        return factory.createTopoBuilder();
     }
 }
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilderFactory.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilderFactory.java
deleted file mode 100644
index 7881bce916..0000000000
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilderFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.spark.globalindex.bitmap;
-
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory;
-
-/**
- * Factory for creating bitmap-based global index builders.
- *
- * <p>This factory is automatically discovered via Java's ServiceLoader 
mechanism.
- */
-public class BitmapGlobalIndexBuilderFactory implements 
GlobalIndexBuilderFactory {
-
-    private static final String IDENTIFIER = "bitmap";
-
-    @Override
-    public String identifier() {
-        return IDENTIFIER;
-    }
-
-    @Override
-    public GlobalIndexBuilder create(GlobalIndexBuilderContext context) {
-        return new BitmapGlobalIndexBuilder(context);
-    }
-}
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilder.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilder.java
deleted file mode 100644
index 78ec1606e1..0000000000
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.spark.globalindex.lucene;
-
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
-
-/**
- * Builder for creating lucene-vector-knn global indexes.
- *
- * <p>This implementation does not apply any custom transformations to the 
input dataset, allowing
- * the data to be processed as-is for lucene index creation.
- */
-public class LuceneGlobalIndexBuilder extends GlobalIndexBuilder {
-
-    protected LuceneGlobalIndexBuilder(GlobalIndexBuilderContext context) {
-        super(context);
-    }
-}
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilderFactory.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilderFactory.java
deleted file mode 100644
index a7374be9b3..0000000000
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilderFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.spark.globalindex.lucene;
-
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory;
-
-/**
- * Factory for creating lucene-vector-knn global index builders.
- *
- * <p>This factory is automatically discovered via Java's ServiceLoader 
mechanism.
- */
-public class LuceneGlobalIndexBuilderFactory implements 
GlobalIndexBuilderFactory {
-
-    private static final String IDENTIFIER = "lucene-vector-knn";
-
-    @Override
-    public String identifier() {
-        return IDENTIFIER;
-    }
-
-    @Override
-    public GlobalIndexBuilder create(GlobalIndexBuilderContext context) {
-        return new LuceneGlobalIndexBuilder(context);
-    }
-}
diff --git 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateGlobalIndexProcedure.java
 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateGlobalIndexProcedure.java
index 8dfcb1772f..48a5b9d7b6 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateGlobalIndexProcedure.java
+++ 
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateGlobalIndexProcedure.java
@@ -27,7 +27,6 @@ import org.apache.paimon.options.Options;
 import org.apache.paimon.partition.PartitionPredicate;
 import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
 import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
-import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory;
 import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactoryUtils;
 import org.apache.paimon.spark.globalindex.GlobalIndexTopoBuilder;
 import org.apache.paimon.spark.utils.SparkProcedureUtils;
@@ -127,10 +126,6 @@ public class CreateGlobalIndexProcedure extends 
BaseProcedure {
 
         String finalWhere = partitions != null ? 
SparkProcedureUtils.toWhere(partitions) : null;
 
-        // Early validation: check if the index type is supported
-        GlobalIndexBuilderFactory globalIndexBuilderFactory =
-                GlobalIndexBuilderFactoryUtils.load(indexType);
-
         LOG.info("Starting to build index for table " + tableIdent + " WHERE: 
" + finalWhere);
 
         return modifyPaimonTable(
@@ -184,7 +179,7 @@ public class CreateGlobalIndexProcedure extends 
BaseProcedure {
                         List<CommitMessage> indexResults;
                         // Step 2: build index by certain index system
                         GlobalIndexTopoBuilder topoBuildr =
-                                globalIndexBuilderFactory.createTopoBulder();
+                                
GlobalIndexBuilderFactoryUtils.createTopoBuilder(indexType);
                         if (topoBuildr != null) {
                             indexResults =
                                     topoBuildr.buildIndex(
@@ -266,11 +261,9 @@ public class CreateGlobalIndexProcedure extends 
BaseProcedure {
                                             
InstantiationUtil.deserializeObject(
                                                     dataSplitBytes,
                                                     
GlobalIndexBuilder.class.getClassLoader());
-                                    GlobalIndexBuilderFactory 
globalIndexBuilderFactory =
-                                            
GlobalIndexBuilderFactoryUtils.load(
-                                                    
builderContext.indexType());
                                     GlobalIndexBuilder globalIndexBuilder =
-                                            
globalIndexBuilderFactory.create(builderContext);
+                                            
GlobalIndexBuilderFactoryUtils.createIndexBuilder(
+                                                    builderContext);
                                     return commitMessageSerializer.serialize(
                                             globalIndexBuilder.build(split));
                                 })
diff --git 
a/paimon-spark/paimon-spark-common/src/main/resources/META-INF/services/org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory
 
b/paimon-spark/paimon-spark-common/src/main/resources/META-INF/services/org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory
deleted file mode 100644
index ea4394add9..0000000000
--- 
a/paimon-spark/paimon-spark-common/src/main/resources/META-INF/services/org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-
-org.apache.paimon.spark.globalindex.bitmap.BitmapGlobalIndexBuilderFactory
-org.apache.paimon.spark.globalindex.lucene.LuceneGlobalIndexBuilderFactory

Reply via email to