Skip to content

Commit fd8b159

Browse files
committed
[spark] Remove useless Factories for bitmap and lucene
1 parent d4c3ba2 commit fd8b159

File tree

8 files changed

+22
-178
lines changed

8 files changed

+22
-178
lines changed

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilder.java renamed to paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/DefaultGlobalIndexBuilder.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
package org.apache.paimon.spark.globalindex.bitmap;
19+
package org.apache.paimon.spark.globalindex;
2020

21-
import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
22-
import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
23-
24-
/**
25-
* Builder for creating bitmap-based global indexes.
26-
*
27-
* <p>This implementation does not apply any custom transformations to the input dataset, allowing
28-
* the data to be processed as-is for bitmap index creation.
29-
*/
30-
public class BitmapGlobalIndexBuilder extends GlobalIndexBuilder {
31-
32-
protected BitmapGlobalIndexBuilder(GlobalIndexBuilderContext context) {
21+
/** Default {@link GlobalIndexBuilder}. */
22+
public class DefaultGlobalIndexBuilder extends GlobalIndexBuilder {
23+
public DefaultGlobalIndexBuilder(GlobalIndexBuilderContext context) {
3324
super(context);
3425
}
3526
}

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface GlobalIndexBuilderFactory {
2525

2626
GlobalIndexBuilder create(GlobalIndexBuilderContext context);
2727

28-
default GlobalIndexTopoBuilder createTopoBulder() {
28+
default GlobalIndexTopoBuilder createTopoBuilder() {
2929
return null;
3030
}
3131
}

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/GlobalIndexBuilderFactoryUtils.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
2323

24+
import javax.annotation.Nullable;
25+
2426
import java.util.HashMap;
2527
import java.util.Map;
2628
import java.util.ServiceLoader;
@@ -52,22 +54,20 @@ public class GlobalIndexBuilderFactoryUtils {
5254
}
5355
}
5456

55-
/**
56-
* Loads the global index builder factory for the specified type.
57-
*
58-
* @param indexType The type of index (e.g., "bitmap")
59-
* @return The corresponding factory
60-
* @throws IllegalArgumentException If no factory is found for the specified type
61-
*/
62-
public static GlobalIndexBuilderFactory load(String indexType) {
57+
public static GlobalIndexBuilder createIndexBuilder(GlobalIndexBuilderContext context) {
58+
GlobalIndexBuilderFactory factory = FACTORIES.get(context.indexType());
59+
if (factory == null) {
60+
return new DefaultGlobalIndexBuilder(context);
61+
}
62+
return factory.create(context);
63+
}
64+
65+
@Nullable
66+
public static GlobalIndexTopoBuilder createTopoBuilder(String indexType) {
6367
GlobalIndexBuilderFactory factory = FACTORIES.get(indexType);
6468
if (factory == null) {
65-
throw new IllegalArgumentException(
66-
String.format(
67-
"No GlobalIndexBuilderFactory found for index type '%s'. "
68-
+ "Available types: %s",
69-
indexType, FACTORIES.keySet()));
69+
return null;
7070
}
71-
return factory;
71+
return factory.createTopoBuilder();
7272
}
7373
}

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/bitmap/BitmapGlobalIndexBuilderFactory.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilder.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/globalindex/lucene/LuceneGlobalIndexBuilderFactory.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/CreateGlobalIndexProcedure.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.paimon.partition.PartitionPredicate;
2828
import org.apache.paimon.spark.globalindex.GlobalIndexBuilder;
2929
import org.apache.paimon.spark.globalindex.GlobalIndexBuilderContext;
30-
import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory;
3130
import org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactoryUtils;
3231
import org.apache.paimon.spark.globalindex.GlobalIndexTopoBuilder;
3332
import org.apache.paimon.spark.utils.SparkProcedureUtils;
@@ -127,10 +126,6 @@ public InternalRow[] call(InternalRow args) {
127126

128127
String finalWhere = partitions != null ? SparkProcedureUtils.toWhere(partitions) : null;
129128

130-
// Early validation: check if the index type is supported
131-
GlobalIndexBuilderFactory globalIndexBuilderFactory =
132-
GlobalIndexBuilderFactoryUtils.load(indexType);
133-
134129
LOG.info("Starting to build index for table " + tableIdent + " WHERE: " + finalWhere);
135130

136131
return modifyPaimonTable(
@@ -184,7 +179,7 @@ public InternalRow[] call(InternalRow args) {
184179
List<CommitMessage> indexResults;
185180
// Step 2: build index by certain index system
186181
GlobalIndexTopoBuilder topoBuildr =
187-
globalIndexBuilderFactory.createTopoBulder();
182+
GlobalIndexBuilderFactoryUtils.createTopoBuilder(indexType);
188183
if (topoBuildr != null) {
189184
indexResults =
190185
topoBuildr.buildIndex(
@@ -266,11 +261,9 @@ private List<CommitMessage> buildIndex(
266261
InstantiationUtil.deserializeObject(
267262
dataSplitBytes,
268263
GlobalIndexBuilder.class.getClassLoader());
269-
GlobalIndexBuilderFactory globalIndexBuilderFactory =
270-
GlobalIndexBuilderFactoryUtils.load(
271-
builderContext.indexType());
272264
GlobalIndexBuilder globalIndexBuilder =
273-
globalIndexBuilderFactory.create(builderContext);
265+
GlobalIndexBuilderFactoryUtils.createIndexBuilder(
266+
builderContext);
274267
return commitMessageSerializer.serialize(
275268
globalIndexBuilder.build(split));
276269
})

paimon-spark/paimon-spark-common/src/main/resources/META-INF/services/org.apache.paimon.spark.globalindex.GlobalIndexBuilderFactory

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)