sohami commented on a change in pull request #1504: DRILL-6792: Find the right 
probe side fragment wrapper & fix DrillBuf…
URL: https://github.com/apache/drill/pull/1504#discussion_r226809347
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/work/filter/RuntimeFilterRouter.java
 ##########
 @@ -303,10 +332,28 @@ private Wrapper findPhysicalOpContainer(Wrapper wrapper, 
PhysicalOperator op) {
         return opContainer;
       }
     }
-    //should not be here
-    throw new IllegalStateException(String.format("No valid Wrapper found for 
physicalOperator with id=%d", op.getOperatorId()));
+    return null;
+  }
+
+  private Wrapper findRuntimeFilterContainer(Wrapper wrapper, long 
runtimeFilterIdentifier) {
+    boolean contain = containsRuntimeFilterPhysicalOperator(wrapper, 
runtimeFilterIdentifier);
+    if (contain) {
+      return wrapper;
+    }
+    List<Wrapper> dependencies = wrapper.getFragmentDependencies();
+    if (CollectionUtils.isEmpty(dependencies)) {
+      return null;
+    }
+    for (Wrapper dependencyWrapper : dependencies) {
+      Wrapper opContainer = findRuntimeFilterContainer(dependencyWrapper, 
runtimeFilterIdentifier);
+      if (opContainer != null) {
+        return opContainer;
+      }
+    }
+    return null;
 
 Review comment:
   `findRuntimeFilterContainer` and `findPhysicalOpContainer` are doing same 
thing except they are using different visitor. We can refactor this code as 
below then caller can call with appropriate visitor.
   ```suggestion
   private Wrapper findPhysicalOpContainer(Wrapper wrapper, PhysicalVisitor 
visitor) {
          boolean contain = containsPhysicalOperator(visitor);
       if (contain) {
         return wrapper;
       }
       List<Wrapper> dependencies = wrapper.getFragmentDependencies();
       if (CollectionUtils.isEmpty(dependencies)) {
         return null;
       }
       for (Wrapper dependencyWrapper : dependencies) {
         Wrapper opContainer = findPhysicalOpContainer(dependencyWrapper, 
visitor);
         if (opContainer != null) {
           return opContainer;
         }
       }
       return null;
     }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to