@@ -962,6 +962,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
962962 JNIEnv* env,
963963 jobject wrapper,
964964 jstring tableId,
965+ jstring executionId,
965966 jlongArray batchHandles,
966967 jobjectArray joinKeys,
967968 jobjectArray filterBuildColumns,
@@ -987,6 +988,13 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
987988 const auto abandonHashBuildDedupMinPct =
988989 queryConf.get <uint32_t >(kAbandonDedupHashMapMinPct , kAbandonDedupHashMapMinPctDefault );
989990 const auto hashTableId = jStringToCString (env, tableId);
991+ const auto sparkExecutionId = jStringToCString (env, executionId);
992+
993+ auto queryId = fmt::format (" Gluten_Execution_{}" , sparkExecutionId);
994+
995+ auto cacheKey = fmt::format (" {}:{}" , queryId, hashTableId);
996+
997+ // std::cout << "the cacheKey in VeloxJniWrapper is " << cacheKey << std::endl;
990998
991999 // Convert Java String array to C++ vector<string>
9921000 std::vector<std::string> hashJoinKeys;
@@ -1063,8 +1071,8 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
10631071
10641072 auto * cache = facebook::velox::exec::HashTableCache::instance ();
10651073
1066- if (!cache->hasTable (hashTableId )) {
1067- cache->injectTable (hashTableId , builder->hashTable (), builder->joinHasNullKeys (), defaultLeafVeloxMemoryPool ());
1074+ if (!cache->hasTable (cacheKey )) {
1075+ cache->injectTable (cacheKey , builder->hashTable (), builder->joinHasNullKeys (), defaultLeafVeloxMemoryPool ());
10681076 }
10691077
10701078 return gluten::getHashTableObjStore ()->save (builder);
@@ -1147,9 +1155,9 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_HashJoinBuilder_native
11471155 hashTableBuilders[0 ]->setHashTable (std::move (mainTable));
11481156
11491157 auto * cache = facebook::velox::exec::HashTableCache::instance ();
1150- if (!cache->hasTable (hashTableId )) {
1158+ if (!cache->hasTable (cacheKey )) {
11511159 cache->injectTable (
1152- hashTableId ,
1160+ cacheKey ,
11531161 hashTableBuilders[0 ]->hashTable (),
11541162 hashTableBuilders[0 ]->joinHasNullKeys (),
11551163 defaultLeafVeloxMemoryPool ());
0 commit comments