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


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java:
##########
@@ -385,17 +385,22 @@ public static int countOperatorsUpstream(Operator<?> 
start, Set<Class<? extends
   }
 
   public static void setMemoryAvailable(final List<Operator<? extends 
OperatorDesc>> operators,
-    final long memoryAvailableToTask) {
-    if (operators == null) {
+    final long memoryAvailable) {
+    if (operators == null || operators.isEmpty()) {
       return;
     }
 
+    final long memoryAvailablePerOperator = memoryAvailable / operators.size();
+    Preconditions.checkArgument(memoryAvailablePerOperator > 0);
+    if (operators.size() > 1) {
+      LOG.info("Assigning {} bytes to {} operators", 
memoryAvailablePerOperator, operators.size());
+    }
     for (Operator<? extends OperatorDesc> op : operators) {
       if (op.getConf() != null) {
-        op.getConf().setMaxMemoryAvailable(memoryAvailableToTask);
+        op.getConf().setMaxMemoryAvailable(memoryAvailablePerOperator);
       }
       if (op.getChildOperators() != null && !op.getChildOperators().isEmpty()) 
{
-        setMemoryAvailable(op.getChildOperators(), memoryAvailableToTask);
+        setMemoryAvailable(op.getChildOperators(), memoryAvailablePerOperator);

Review Comment:
   I have a minor question here. If I understand correctly, this code may 
subdivide the memory size as shown in the diagram. Is this the intended 
behavior, given that we only consider operators running in parallel?
   ```
   Grandparent(400M) - Parent1(200M) - Child11(100M)
                                     - Child12(100M)
                     - Parent2(200M) - Child21(100M)
                                     - Child22(100M)
   ```



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