/// 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(RelOptPlanner planner) {
ScanStats stats = groupScan.getScanStats();
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.