/// TODO: this method is same as the one for ScanPrel...eventually we should consolidate /// this and few other methods in a common base class which would be extended /// by both logical and physical rels. @Override public RelOptCost computeSelfCost(final RelOptPlanner planner) { final ScanStats stats = groupScan.getScanStats(settings); int columnCount = getRowType().getFieldCount(); double ioCost = 0; boolean isStarQuery = Iterables.tryFind( getRowType().getFieldNames(), new Predicate<String>() { @Override public boolean apply(String input) { return Preconditions.checkNotNull(input).equals("*"); } }) .isPresent(); if (isStarQuery) { columnCount = STAR_COLUMN_COST; } // double rowCount = RelMetadataQuery.getRowCount(this); double rowCount = stats.getRecordCount(); if (rowCount < 1) { rowCount = 1; } if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) { return planner .getCostFactory() .makeCost(rowCount * columnCount, stats.getCpuCost(), stats.getDiskCost()); } double cpuCost = rowCount * columnCount; // for now, assume cpu cost is proportional to row count. // Even though scan is reading from disk, in the currently generated plans all plans will // need to read the same amount of data, so keeping the disk io cost 0 is ok for now. // In the future we might consider alternative scans that go against projections or // different compression schemes etc that affect the amount of data read. Such alternatives // would affect both cpu and io cost. DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory(); return costFactory.makeCost(rowCount, cpuCost, ioCost, 0); }
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw).item("groupscan", groupScan.getDigest()); }
@Override public Void visitGroupScan(GroupScan groupScan, Wrapper wrapper) { Stats stats = wrapper.getStats(); stats.addMaxWidth(groupScan.getMaxParallelizationWidth()); return super.visitGroupScan(groupScan, wrapper); }