ngsg commented on code in PR #5717:
URL: https://github.com/apache/hive/pull/5717#discussion_r2086310925


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java:
##########
@@ -1427,12 +1426,29 @@ private static SharedResult 
extractSharedOptimizationInfoForRoot(ParseContext pc
     if (equalOp1.getNumChild() > 1 || equalOp2.getNumChild() > 1) {
       // TODO: Support checking multiple child operators to merge further.
       discardableInputOps.addAll(gatherDPPBranchOps(pctx, optimizerCache, 
discardableOps));
-      return new SharedResult(retainableOps, discardableOps, 
discardableInputOps,
-          dataSize, maxDataSize);
+
+      // Accumulate InMemoryDataSize of unmerged MapJoin operators.
+      Set<Operator<?>> opsWork1 = findWorkOperators(optimizerCache, 
retainableTsOp);
+      for (Operator<?> op : opsWork1) {
+        if (op instanceof MapJoinOperator) {
+          MapJoinOperator mop = (MapJoinOperator) op;
+          dataSize = StatsUtils.safeAdd(dataSize, 
mop.getConf().getInMemoryDataSize());
+          maxDataSize = 
mop.getConf().getMemoryMonitorInfo().getAdjustedNoConditionalTaskSize();
+        }
+      }
+      Set<Operator<?>> opsWork2 = findWorkOperators(optimizerCache, 
discardableTsOp);
+      for (Operator<?> op : opsWork2) {
+        if (op instanceof MapJoinOperator) {
+          MapJoinOperator mop = (MapJoinOperator) op;
+          dataSize = StatsUtils.safeAdd(dataSize, 
mop.getConf().getInMemoryDataSize());
+          maxDataSize = 
mop.getConf().getMemoryMonitorInfo().getAdjustedNoConditionalTaskSize();

Review Comment:
   The original code in `extractSharedOptimizationInfo`, which I used as a 
reference, overwrites it for every MapJoinOperator. I followed the same 
approach in `extractSharedOptimizationInfoForRoot` for consistency, but I'm not 
sure the current version is expected, and I think that it would be better to 
replace this overwriting logic with max() (StatsUtils version if available). 
I'll update the code in both `extractSharedOptimizationInfoForRoot` and 
`extractSharedOptimizationInfo` in the next commit.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to