public Double getPopulationSize(Project rel, RelMetadataQuery mq, ImmutableBitSet groupKey) { ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder(); ImmutableBitSet.Builder projCols = ImmutableBitSet.builder(); List<RexNode> projExprs = rel.getProjects(); RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols); Double population = mq.getPopulationSize(rel.getInput(), baseCols.build()); if (population == null) { return null; } // No further computation required if the projection expressions are // all column references if (projCols.cardinality() == 0) { return population; } for (int bit : projCols.build()) { Double subRowCount = RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit)); if (subRowCount == null) { return null; } population *= subRowCount; } // REVIEW zfong 6/22/06 - Broadbase did not have the call to // numDistinctVals. This is needed; otherwise, population can be // larger than the number of rows in the RelNode. return RelMdUtil.numDistinctVals(population, mq.getRowCount(rel)); }
public Double getPopulationSize(Project rel, RelMetadataQuery mq, ImmutableBitSet groupKey) { ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder(); ImmutableBitSet.Builder projCols = ImmutableBitSet.builder(); List<RexNode> projExprs = rel.getProjects(); RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols); Double population = mq.getPopulationSize(rel.getInput(), baseCols.build()); if (population == null) { return null; } // No further computation required if the projection expressions are // all column references if (projCols.cardinality() == 0) { return population; } for (int bit : projCols.build()) { Double subRowCount = RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit)); if (subRowCount == null) { return null; } population *= subRowCount; } // REVIEW zfong 6/22/06 - Broadbase did not have the call to // numDistinctVals. This is needed; otherwise, population can be // larger than the number of rows in the RelNode. return RelMdUtil.numDistinctVals(population, mq.getRowCount(rel)); }
ImmutableBitSet.Builder projCols = ImmutableBitSet.builder(); List<RexNode> projExprs = rel.getProjects(); RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
ImmutableBitSet.Builder projCols = ImmutableBitSet.builder(); List<RexNode> projExprs = rel.getProjects(); RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);