Skip to content

Commit 2f34754

Browse files
committed
fix
1 parent c93e4c5 commit 2f34754

6 files changed

Lines changed: 24 additions & 9 deletions

File tree

backends-velox/src/main/java/org/apache/gluten/vectorized/HashJoinBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public long rtHandle() {
4141

4242
public native long nativeBuild(
4343
String buildHashTableId,
44+
String executionId,
4445
long[] batchHandlers,
4546
String[] joinKeys,
4647
String[] filterBuildColumns,

backends-velox/src/main/scala/org/apache/gluten/execution/HashJoinExecTransformer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ case class BroadcastHashJoinExecTransformer(
175175
filterBuildColumns,
176176
filterPropagatesNulls,
177177
buildBroadcastTableId,
178+
executionId,
178179
isNullAwareAntiJoin,
179180
bloomFilterPushdownSize,
180181
metrics.get("buildHashTableTime")
@@ -195,6 +196,7 @@ case class BroadcastHashJoinContext(
195196
filterBuildColumns: Array[String],
196197
filterPropagatesNulls: Boolean,
197198
buildHashTableId: String,
199+
executionId: String,
198200
isNullAwareAntiJoin: Boolean = false,
199201
bloomFilterPushdownSize: Long,
200202
buildHashTableTimeMetric: Option[SQLMetric] = None)

backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ case class ColumnarBuildSideRelation(
213213
hashTableData = hashJoinBuilder
214214
.nativeBuild(
215215
broadcastContext.buildHashTableId,
216+
broadcastContext.executionId,
216217
batchArray.toArray,
217218
joinKeys,
218219
broadcastContext.filterBuildColumns,

backends-velox/src/main/scala/org/apache/spark/sql/execution/unsafe/UnsafeColumnarBuildSideRelation.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class UnsafeColumnarBuildSideRelation(
183183
hashTableData = hashJoinBuilder
184184
.nativeBuild(
185185
broadcastContext.buildHashTableId,
186+
broadcastContext.executionId,
186187
batchArray.toArray,
187188
joinKeys,
188189
broadcastContext.filterBuildColumns,

cpp/velox/compute/WholeStageResultIterator.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ std::string getVeloxTaskId(const SparkTaskInfo& taskInfo) {
7777
if (taskInfo.executionId != -1) {
7878
return fmt::format("Gluten_Execution_{}", std::to_string(taskInfo.executionId));
7979
}
80-
return fmt::format(
81-
"Gluten_Stage_{}_TID_{}_VTID_{}",
82-
std::to_string(taskInfo.stageId),
83-
std::to_string(taskInfo.taskId),
84-
std::to_string(taskInfo.vId));
80+
81+
return "Gluten_Execution_";
82+
// return fmt::format(
83+
// "Gluten_Stage_{}_TID_{}_VTID_{}",
84+
// std::to_string(taskInfo.stageId),
85+
// std::to_string(taskInfo.taskId),
86+
// std::to_string(taskInfo.vId));
8587
}
8688
} // namespace
8789

cpp/velox/jni/VeloxJniWrapper.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)