Skip to content

Commit

Permalink
Add GDAL jni path to LD_LIBRARY_PATH.
Browse files Browse the repository at this point in the history
  • Loading branch information
milos.colic committed Oct 20, 2023
1 parent 58e6160 commit 3a66513
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/scala/com/databricks/labs/mosaic/gdal/MosaicGDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ object MosaicGDAL extends Logging {
val GDAL_ENABLED = "spark.mosaic.gdal.native.enabled"
var isEnabled = false

def wasEnabled(spark: SparkSession): Boolean = spark.conf.get(GDAL_ENABLED, "false").toBoolean || sys.env.getOrElse("GDAL_ENABLED", "false").toBoolean
def wasEnabled(spark: SparkSession): Boolean =
spark.conf.get(GDAL_ENABLED, "false").toBoolean || sys.env.getOrElse("GDAL_ENABLED", "false").toBoolean

def prepareEnvironment(spark: SparkSession, initScriptPath: String): Unit = {
if (!wasEnabled(spark) && !isEnabled) {
Try {
copyInitScript(initScriptPath)
//copySharedObjects()
copySharedObjects()
} match {
case scala.util.Success(_) => logInfo("GDAL environment prepared successfully.")
case scala.util.Failure(exception) => logWarning("GDAL environment preparation failed.", exception)
Expand All @@ -54,7 +55,7 @@ object MosaicGDAL extends Logging {
if (!wasEnabled(spark) && !isEnabled) {
Try {
isEnabled = true
//copySharedObjects()
copySharedObjects()
loadSharedObjects()
gdal.AllRegister()
configureGDAL()
Expand Down Expand Up @@ -120,7 +121,9 @@ object MosaicGDAL extends Logging {
try {
if (Files.exists(Paths.get(path))) System.load(path)
} catch {
case t: Throwable => logWarning(s"Failed to load $path", t)
case t: Throwable =>
println(s"Failed to load $path")
logWarning(s"Failed to load $path", t)
}
}

Expand Down

0 comments on commit 3a66513

Please sign in to comment.