PHILO-HE commented on code in PR #10591:
URL: 
https://github.com/apache/incubator-gluten/pull/10591#discussion_r2317697490


##########
gluten-celeborn/src/main/java/org/apache/spark/shuffle/gluten/celeborn/CelebornShuffleManager.java:
##########
@@ -68,46 +67,37 @@ public class CelebornShuffleManager
   private static final CelebornColumnarBatchSerializerFactory 
columnarBatchSerializerFactory;
 
   static {
+    final String backendName = BackendsApiManager.getBackendName();
     final ServiceLoader<CelebornShuffleWriterFactory> loader =
         ServiceLoader.load(CelebornShuffleWriterFactory.class);
     final List<CelebornShuffleWriterFactory> factoryList =
         Arrays.stream(Iterators.toArray(loader.iterator(), 
CelebornShuffleWriterFactory.class))
+            .filter(f -> f.backendName().equalsIgnoreCase(backendName))
             .collect(Collectors.toList());
     Preconditions.checkState(
-        !factoryList.isEmpty(), "No factory found for Celeborn shuffle 
writer");
-    final Map<String, CelebornShuffleWriterFactory> factoryMap =
-        factoryList.stream()
-            
.collect(Collectors.toMap(CelebornShuffleWriterFactory::backendName, f -> f));
-
-    final String backendName = BackendsApiManager.getBackendName();
-    if (!factoryMap.containsKey(backendName)) {
-      throw new UnsupportedOperationException(
-          "No Celeborn shuffle writer factory found for backend " + 
backendName);
-    }
-    writerFactory = factoryMap.get(backendName);
+        !factoryList.isEmpty(),
+        "No Celeborn shuffle writer factory found for backend " + backendName);
+    Preconditions.checkState(
+        factoryList.size() == 1,
+        "Multiple factory found for Celeborn shuffle writer for backend " + 
backendName);
+    writerFactory = factoryList.get(0);
 
-    final ServiceLoader<CelebornColumnarBatchSerializerFactory>
-        celebornColumnarBatchSerializerFactoriesLoader =
-            ServiceLoader.load(CelebornColumnarBatchSerializerFactory.class);
-    final List<CelebornColumnarBatchSerializerFactory> 
columnarBatchSerializerFactoryList =
+    final ServiceLoader<CelebornColumnarBatchSerializerFactory> 
serializerLoader =
+        ServiceLoader.load(CelebornColumnarBatchSerializerFactory.class);
+    final List<CelebornColumnarBatchSerializerFactory> serializerFactoryList =
         Arrays.stream(
                 Iterators.toArray(
-                    celebornColumnarBatchSerializerFactoriesLoader.iterator(),
-                    CelebornColumnarBatchSerializerFactory.class))
+                    serializerLoader.iterator(), 
CelebornColumnarBatchSerializerFactory.class))
+            .filter(f -> f.backendName().equalsIgnoreCase(backendName))

Review Comment:
   The implementation class for `CelebornColumnarBatchSerializerFactory` is 
exclusive, isolated in either Velox module or CH module. For instance, CH 
backend's implementaion cannot be loaded at Velox backend's runtime. Therefore, 
I think we don't need to check the backend name and there seems to be no need 
to maintain `backendName` in `CelebornColumnarBatchSerializerFactory`. Please 
confirm if it makes sense.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to