zhuzhurk commented on code in PR #25578:
URL: https://github.com/apache/flink/pull/25578#discussion_r1898203822
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/batch/BatchPhysicalHashJoin.scala:
##########
@@ -49,7 +49,8 @@ class BatchPhysicalHashJoin(
val leftIsBuild: Boolean,
// true if build side is broadcast, else false
val isBroadcast: Boolean,
- val tryDistinctBuildRow: Boolean)
+ val tryDistinctBuildRow: Boolean,
+ val withHint: Boolean)
Review Comment:
The name is not updated to `withJoinStrategyHint`
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/JoinUtil.scala:
##########
@@ -275,4 +283,42 @@ object JoinUtil {
rowCount * FlinkRelMdUtil.binaryRowAverageSize(relNode)
}
}
+
+ /**
+ * Get managed memory for hash join. Because hash join may fallback to sort
merge join, it takes
+ * larger managed memory to support a HashJoin being converted into a
SortMergeJoin.
+ */
+ def getManagedMemory(joinType: FlinkJoinType, config: ExecNodeConfig): Long
= {
+ val hashJoinManagedMemory =
+
config.get(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_HASH_JOIN_MEMORY).getBytes
+ // The memory used by SortMergeJoinIterator that buffer the matched rows,
each side needs
+ // this memory if it is full outer join
+ val externalBufferMemory =
+
config.get(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_EXTERNAL_BUFFER_MEMORY).getBytes
+ // The memory used by BinaryExternalSorter for sort, the left and right
side both need it
+ val sortMemory =
config.get(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_SORT_MEMORY).getBytes
+ var externalBufferNum = 1
+ if (joinType eq FlinkJoinType.FULL) {
+ externalBufferNum = 2
+ }
+ val sortMergeJoinManagedMemory = externalBufferMemory * externalBufferNum
+ sortMemory * 2
+ // Due to hash join maybe fallback to sort merge join, so here managed
memory choose the
+ // large one
+ Math.max(hashJoinManagedMemory, sortMergeJoinManagedMemory)
+ }
+
+ /** Get estimated row stats for hash join. */
+ def getEstimatedRowStats(joinBase: BatchPhysicalJoinBase): (Int, Long, Int,
Long) = {
+ val mq = joinBase.getCluster.getMetadataQuery
+ val leftRowSize = Util.first(mq.getAverageRowSize(joinBase.getLeft),
24).toInt
+ val leftRowCount = Util.first(mq.getRowCount(joinBase.getLeft),
200000).toLong
+ val rightRowSize = Util.first(mq.getAverageRowSize(joinBase.getRight),
24).toInt
+ val rightRowCount = Util.first(mq.getRowCount(joinBase.getRight),
200000).toLong
+
+ (leftRowSize, leftRowCount, rightRowSize, rightRowCount)
+ }
+
+ def isJoinStrategyHint(relHints: ImmutableList[RelHint]): Boolean = {
Review Comment:
-> `containsJoinStrategyHint`
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/batch/BatchPhysicalHashJoin.scala:
##########
@@ -75,7 +76,8 @@ class BatchPhysicalHashJoin(
joinType,
leftIsBuild,
isBroadcast,
- tryDistinctBuildRow)
+ tryDistinctBuildRow,
+ withHint)
Review Comment:
The name is not updated to `withJoinStrategyHint`
This also happens in a few other places.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]