This is an automated email from the ASF dual-hosted git repository.

hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 82c5a7edd3 [GLUTEN-7400][CORE] Scala code style clean up for 
Backend.scala
82c5a7edd3 is described below

commit 82c5a7edd363e7deb2edd1c404713ea83e32adcf
Author: Jiaan Geng <[email protected]>
AuthorDate: Wed Oct 9 10:05:46 2024 +0800

    [GLUTEN-7400][CORE] Scala code style clean up for Backend.scala
---
 .../scala/org/apache/gluten/backend/Backend.scala  | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gluten-core/src/main/scala/org/apache/gluten/backend/Backend.scala 
b/gluten-core/src/main/scala/org/apache/gluten/backend/Backend.scala
index 1b9175d6b0..ef22d97e77 100644
--- a/gluten-core/src/main/scala/org/apache/gluten/backend/Backend.scala
+++ b/gluten-core/src/main/scala/org/apache/gluten/backend/Backend.scala
@@ -55,23 +55,23 @@ trait Backend {
 }
 
 object Backend {
-  private val be: Backend = {
+  private val backend: Backend = {
     val discoveredBackends =
-      
JavaConverters.iterableAsScalaIterable(ServiceLoader.load(classOf[Backend])).toSeq
-    if (discoveredBackends.isEmpty) {
-      throw new IllegalStateException("Backend implementation not discovered 
from JVM classpath")
+      
JavaConverters.iterableAsScalaIterable(ServiceLoader.load(classOf[Backend])).toList
+    discoveredBackends match {
+      case Nil =>
+        throw new IllegalStateException("Backend implementation not discovered 
from JVM classpath")
+      case head :: Nil =>
+        head
+      case backends =>
+        val backendNames = backends.map(_.name())
+        throw new IllegalStateException(
+          s"More than one Backend implementation discovered from JVM 
classpath: $backendNames")
     }
-    if (discoveredBackends.size != 1) {
-      throw new IllegalStateException(
-        s"More than one Backend implementation discovered from JVM classpath: 
" +
-          s"${discoveredBackends.map(_.name()).toList}")
-    }
-    val backend = discoveredBackends.head
-    backend
   }
 
   def get(): Backend = {
-    be
+    backend
   }
 
   case class BuildInfo(name: String, branch: String, revision: String, 
revisionTime: String)


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

Reply via email to