Skip to content

Commit

Permalink
[auto-merge] branch-25.02 to branch-25.04 [skip ci] [bot] (#12090)
Browse files Browse the repository at this point in the history
auto-merge triggered by github actions on `branch-25.02` to create a PR
keeping `branch-25.04` up-to-date. If this PR is unable to be merged due
to conflicts, it will remain open until manually fix.
  • Loading branch information
nvauto authored Feb 8, 2025
2 parents 617aeba + 0e7096f commit 9122ab0
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions sql-plugin/src/main/scala/com/nvidia/spark/rapids/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.util.Properties
import java.util.concurrent.ConcurrentHashMap

import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.sys.process._
import scala.util.Try

Expand Down Expand Up @@ -353,20 +354,29 @@ object RapidsPluginUtils extends Logging {
val resourceName = "spark-rapids-extra-plugins"
val classLoader = RapidsPluginUtils.getClass.getClassLoader
val resourceUrls = classLoader.getResources(resourceName)
val resourceUrlArray = resourceUrls.asScala.toArray
// Somehow, it is possible that the definition of same Plugin occurs multiple times in the
// resourceUrls. Therefore, deduplication work is essential in case of loading some plugins
// repeatedly.
val distinctResources = mutable.HashSet.empty[URL]
while (resourceUrls.hasMoreElements) {
val url = resourceUrls.nextElement()
if (distinctResources.contains(url)) {
logWarning(s"Found duplicated definition of ExtraPlugin: $url! Discarded it.")
} else {
distinctResources.add(url)
}
}

if (resourceUrlArray.isEmpty) {
if (distinctResources.isEmpty) {
logDebug(s"Could not find file $resourceName in the classpath, not loading extra plugins")
Seq.empty
} else {
val plugins = scala.collection.mutable.ListBuffer[SparkPlugin]()
for (resourceUrl <- resourceUrlArray) {
distinctResources.iterator.flatMap { resourceUrl =>
val source = scala.io.Source.fromURL(resourceUrl)
val pluginClasses = source.getLines().toList
source.close()
plugins ++= loadExtensions(classOf[SparkPlugin], pluginClasses)
}
plugins.toSeq
loadExtensions(classOf[SparkPlugin], pluginClasses)
}.toList
}
}

Expand Down

0 comments on commit 9122ab0

Please sign in to comment.