Search in sources :

Example 1 with InputReferencedVisitor

use of org.apache.calcite.plan.RelOptUtil.InputReferencedVisitor in project hive by apache.

the class FilterSelectivityEstimator method getMaxNDV.

private Double getMaxNDV(RexCall call) {
    double tmpNDV;
    double maxNDV = 1.0;
    InputReferencedVisitor irv;
    for (RexNode op : call.getOperands()) {
        if (op instanceof RexInputRef) {
            tmpNDV = HiveRelMdDistinctRowCount.getDistinctRowCount(this.childRel, mq, ((RexInputRef) op).getIndex());
            if (tmpNDV > maxNDV)
                maxNDV = tmpNDV;
        } else {
            irv = new InputReferencedVisitor();
            irv.apply(op);
            for (Integer childProjIndx : irv.inputPosReferenced) {
                tmpNDV = HiveRelMdDistinctRowCount.getDistinctRowCount(this.childRel, mq, childProjIndx);
                if (tmpNDV > maxNDV)
                    maxNDV = tmpNDV;
            }
        }
    }
    return maxNDV;
}
Also used : InputReferencedVisitor(org.apache.calcite.plan.RelOptUtil.InputReferencedVisitor) RexInputRef(org.apache.calcite.rex.RexInputRef) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

InputReferencedVisitor (org.apache.calcite.plan.RelOptUtil.InputReferencedVisitor)1 RexInputRef (org.apache.calcite.rex.RexInputRef)1 RexNode (org.apache.calcite.rex.RexNode)1