sohami commented on a change in pull request #1677: DRILL-7068: Support memory 
adjustment framework for resource manageme…
URL: https://github.com/apache/drill/pull/1677#discussion_r262773873
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PhysicalPlanCreator.java
 ##########
 @@ -54,7 +56,11 @@ public QueryContext getContext() {
 
   public PhysicalOperator addMetadata(Prel originalPrel, PhysicalOperator op){
     op.setOperatorId(opIdMap.get(originalPrel).getAsSingleInt());
-    
op.setCost(originalPrel.estimateRowCount(originalPrel.getCluster().getMetadataQuery()));
+    PrelCostEstimates costEstimates = 
originalPrel.getCostEstimates(originalPrel.getCluster().getPlanner(), 
originalPrel.getCluster().getMetadataQuery());
+    if (!op.isBufferedOperator(context)) {
+      costEstimates = new 
PrelCostEstimates(context.getOptions().getLong(ExecConstants.OUTPUT_BATCH_SIZE),
 costEstimates.getOutputRowCount());
+    }
+    op.setCost(costEstimates);
 
 Review comment:
   I think this method should be the one creating the **PrelCostEstimates** 
after getting the DrillCostBase as below. Then it will act as a true factory 
for `PreCostEstimates` and `getCostEstimates` from Prel.java can be removed.
   
   ```
       final RelMetadataQuery mq = originalPrel.getCluster().getMetadataQuery();
       final double estimatedRowCount = originalPrel.estimateRowCount(mq);
       final DrillCostBase costBase = (DrillCostBase) 
originalPrel.computeSelfCost(originalPrel.getCluster().getPlanner(),
         mq);
       final PrelCostEstimates costEstimates;
       if (!op.isBufferedOperator(context)) {
         costEstimates = new 
PrelCostEstimates(context.getOptions().getLong(ExecConstants.OUTPUT_BATCH_SIZE),
 estimatedRowCount);
       } else {
         costEstimates = new PrelCostEstimates(costBase.getMemory(), 
estimatedRowCount);
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to