@@ -80,7 +80,7 @@ jint JNI_OnLoad(JavaVM* vm, void*) {
8080 getJniErrorState ()->ensureInitialized (env);
8181 initVeloxJniFileSystem (env);
8282 initVeloxJniUDF (env);
83- initVeloxJniHashTable (env);
83+ initVeloxJniHashTable (env, vm );
8484
8585 infoCls = createGlobalClassReferenceOrError (env, " Lorg/apache/gluten/validate/NativePlanValidationInfo;" );
8686 infoClsInitMethod = getMethodIdOrError (env, infoCls, " <init>" , " (ILjava/lang/String;)V" );
@@ -94,8 +94,6 @@ jint JNI_OnLoad(JavaVM* vm, void*) {
9494
9595 DLOG (INFO) << " Loaded Velox backend." ;
9696
97- gluten::vm = vm;
98-
9997 return jniVersion;
10098}
10199
@@ -108,6 +106,7 @@ void JNI_OnUnload(JavaVM* vm, void*) {
108106
109107 finalizeVeloxJniUDF (env);
110108 finalizeVeloxJniFileSystem (env);
109+ finalizeVeloxJniHashTable (env);
111110 getJniErrorState ()->close ();
112111 getJniCommonState ()->close ();
113112 google::ShutdownGoogleLogging ();
@@ -939,7 +938,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
939938 jclass,
940939 jstring tableId,
941940 jlongArray batchHandles,
942- jstring joinKey ,
941+ jobjectArray joinKeys ,
943942 jint joinType,
944943 jboolean hasMixedJoinCondition,
945944 jboolean isExistenceJoin,
@@ -949,7 +948,16 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
949948 jint broadcastHashTableBuildThreads) {
950949 JNI_METHOD_START
951950 const auto hashTableId = jStringToCString (env, tableId);
952- const auto hashJoinKey = jStringToCString (env, joinKey);
951+
952+ // Convert Java String array to C++ vector<string>
953+ std::vector<std::string> hashJoinKeys;
954+ jsize joinKeysCount = env->GetArrayLength (joinKeys);
955+ hashJoinKeys.reserve (joinKeysCount);
956+ for (jsize i = 0 ; i < joinKeysCount; ++i) {
957+ jstring jkey = (jstring)env->GetObjectArrayElement (joinKeys, i);
958+ hashJoinKeys.emplace_back (jStringToCString (env, jkey));
959+ }
960+
953961 const auto inputType = gluten::getByteArrayElementsSafe (env, namedStruct);
954962 std::string structString{
955963 reinterpret_cast <const char *>(inputType.elems ()), static_cast <std::string::size_type>(inputType.length ())};
@@ -988,7 +996,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
988996
989997 if (numThreads <= 1 ) {
990998 auto builder = nativeHashTableBuild (
991- hashJoinKey ,
999+ hashJoinKeys ,
9921000 names,
9931001 veloxTypeList,
9941002 joinType,
@@ -1008,7 +1016,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
10081016 nullptr );
10091017 builder->setHashTable (std::move (mainTable));
10101018
1011- return gluten::hashTableObjStore ->save (builder);
1019+ return gluten::getHashTableObjStore () ->save (builder);
10121020 }
10131021
10141022 std::vector<std::thread> threads;
@@ -1027,7 +1035,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
10271035 }
10281036
10291037 auto builder = nativeHashTableBuild (
1030- hashJoinKey ,
1038+ hashJoinKeys ,
10311039 names,
10321040 veloxTypeList,
10331041 joinType,
@@ -1073,7 +1081,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
10731081 }
10741082
10751083 hashTableBuilders[0 ]->setHashTable (std::move (mainTable));
1076- return gluten::hashTableObjStore ->save (hashTableBuilders[0 ]);
1084+ return gluten::getHashTableObjStore () ->save (hashTableBuilders[0 ]);
10771085 JNI_METHOD_END (kInvalidObjectHandle )
10781086}
10791087
@@ -1083,7 +1091,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_cloneH
10831091 jlong tableHandler) {
10841092 JNI_METHOD_START
10851093 auto hashTableHandler = ObjectStore::retrieve<gluten::HashTableBuilder>(tableHandler);
1086- return gluten::hashTableObjStore ->save (hashTableHandler);
1094+ return gluten::getHashTableObjStore () ->save (hashTableHandler);
10871095 JNI_METHOD_END (kInvalidObjectHandle )
10881096}
10891097
0 commit comments