/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param factRel fact table participating in the semijoin * @param dimRel dimension table participating in the semijoin * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, RelNode factRel, RelNode dimRel, SemiJoin rel) { return computeSemiJoinSelectivity(mq, factRel, dimRel, rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param factRel fact table participating in the semijoin * @param dimRel dimension table participating in the semijoin * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, RelNode factRel, RelNode dimRel, SemiJoin rel) { return computeSemiJoinSelectivity(mq, factRel, dimRel, rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, SemiJoin rel) { return computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, SemiJoin rel) { return computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel.getLeftKeys(), rel.getRightKeys()); }
/** * Creates a RexNode that stores a selectivity value corresponding to the * selectivity of a semijoin. This can be added to a filter to simulate the * effect of the semijoin during costing, but should never appear in a real * plan since it has no physical implementation. * * @param rel the semijoin of interest * @return constructed rexnode */ public static RexNode makeSemiJoinSelectivityRexNode(RelMetadataQuery mq, SemiJoin rel) { RexBuilder rexBuilder = rel.getCluster().getRexBuilder(); double selectivity = computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel); return rexBuilder.makeCall(ARTIFICIAL_SELECTIVITY_FUNC, rexBuilder.makeApproxLiteral(new BigDecimal(selectivity))); }
/** * Creates a RexNode that stores a selectivity value corresponding to the * selectivity of a semijoin. This can be added to a filter to simulate the * effect of the semijoin during costing, but should never appear in a real * plan since it has no physical implementation. * * @param rel the semijoin of interest * @return constructed rexnode */ public static RexNode makeSemiJoinSelectivityRexNode(RelMetadataQuery mq, SemiJoin rel) { RexBuilder rexBuilder = rel.getCluster().getRexBuilder(); double selectivity = computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel); return rexBuilder.makeCall(ARTIFICIAL_SELECTIVITY_FUNC, rexBuilder.makeApproxLiteral(new BigDecimal(selectivity))); }
RelMdUtil.computeSemiJoinSelectivity(mq, factRel, dimRel, semiJoin); if (selectivity > .5) { return 0;
RelMdUtil.computeSemiJoinSelectivity(mq, factRel, dimRel, semiJoin); if (selectivity > .5) { return 0;