Skip to content

Commit

Permalink
[GLUTEN-7031][CORE] Move JNI / Exception utilities to gluten-core
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer committed Sep 5, 2024
1 parent d289b54 commit adfab32
Show file tree
Hide file tree
Showing 19 changed files with 18 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import org.apache.gluten.execution.CHBroadcastBuildSideCache
import org.apache.gluten.execution.datasource.{GlutenOrcWriterInjects, GlutenParquetWriterInjects, GlutenRowSplitter}
import org.apache.gluten.expression.UDFMappings
import org.apache.gluten.extension.ExpressionExtensionTrait
import org.apache.gluten.vectorized.{CHNativeExpressionEvaluator, JniLibLoader}
import org.apache.gluten.jni.JniLibLoader
import org.apache.gluten.vectorized.CHNativeExpressionEvaluator

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.api.plugin.PluginContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.apache.spark.sql.execution.benchmarks

import org.apache.gluten.GlutenConfig
import org.apache.gluten.jni.JniLibLoader
import org.apache.gluten.utils.UTSystemParameters
import org.apache.gluten.vectorized.JniLibLoader

import org.apache.spark.SparkConf
import org.apache.spark.sql.delta.DeltaLog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import org.apache.gluten.backendsapi.ListenerApi
import org.apache.gluten.execution.datasource.{GlutenOrcWriterInjects, GlutenParquetWriterInjects, GlutenRowSplitter}
import org.apache.gluten.expression.UDFMappings
import org.apache.gluten.init.NativeBackendInitializer
import org.apache.gluten.jni.{JniLibLoader, JniWorkspace}
import org.apache.gluten.udf.UdfJniWrapper
import org.apache.gluten.utils._
import org.apache.gluten.vectorized.{JniLibLoader, JniWorkspace}

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.api.plugin.PluginContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.apache.gluten.utils

import org.apache.gluten.GlutenConfig
import org.apache.gluten.exception.GlutenException
import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

import org.apache.spark.SparkConf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderCentos7 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderCentos8 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderCentos9 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderDebian11 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderDebian12 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderUbuntu2004 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.gluten.utils

import org.apache.gluten.vectorized.JniLibLoader
import org.apache.gluten.jni.JniLibLoader

class SharedLibraryLoaderUbuntu2204 extends SharedLibraryLoader {
override def loadLib(loader: JniLibLoader): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.apache.spark.sql.expression
import org.apache.gluten.backendsapi.velox.VeloxBackendSettings
import org.apache.gluten.exception.{GlutenException, GlutenNotSupportException}
import org.apache.gluten.expression._
import org.apache.gluten.vectorized.JniWorkspace
import org.apache.gluten.jni.JniWorkspace

import org.apache.spark.{SparkConf, SparkFiles}
import org.apache.spark.deploy.SparkHadoopUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.gluten.vectorized;
package org.apache.gluten.jni;

import org.apache.gluten.exception.GlutenException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.gluten.vectorized;
package org.apache.gluten.jni;

import org.apache.gluten.exception.GlutenException;

Expand Down Expand Up @@ -46,7 +46,6 @@ public class JniWorkspace {

private final String workDir;
private final JniLibLoader jniLibLoader;
private final JniResourceHelper jniResourceHelper;

private JniWorkspace(String rootDir) {
try {
Expand All @@ -55,7 +54,6 @@ private JniWorkspace(String rootDir) {
Path created = Files.createTempDirectory(root, "gluten-");
this.workDir = created.toAbsolutePath().toString();
this.jniLibLoader = new JniLibLoader(workDir);
this.jniResourceHelper = new JniResourceHelper(workDir);
LOG.info("JNI workspace {} created in root directory {}", workDir, rootDir);
} catch (Exception e) {
throw new GlutenException(e);
Expand Down Expand Up @@ -101,22 +99,6 @@ public static void enableDebug(String debugDir) {
}
}

// For testing
private static boolean isDebugEnabled() {
synchronized (DEFAULT_INSTANCE_INIT_LOCK) {
return DEFAULT_INSTANCE != null
&& DEBUG_INSTANCE != null
&& DEFAULT_INSTANCE == DEBUG_INSTANCE;
}
}

// For testing
private static void resetDefaultInstance() {
synchronized (DEFAULT_INSTANCE_INIT_LOCK) {
DEFAULT_INSTANCE = null;
}
}

public static JniWorkspace getDefault() {
synchronized (DEFAULT_INSTANCE_INIT_LOCK) {
if (DEFAULT_INSTANCE == null) {
Expand All @@ -138,8 +120,4 @@ public String getWorkDir() {
public JniLibLoader libLoader() {
return jniLibLoader;
}

public JniResourceHelper resourceHelper() {
return jniResourceHelper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/
package org.apache.spark.util

import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging

import _root_.org.apache.gluten.exception.GlutenException
import org.apache.commons.io.FileUtils
import org.apache.commons.lang3.StringUtils
import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging

import java.io.{File, IOException}
import java.nio.file.Paths
Expand Down

This file was deleted.

Loading

0 comments on commit adfab32

Please sign in to comment.