class IgniteMdCumulativeCost implements MetadataHandler<BuiltInMetadata.CumulativeCost> {
    /** */
    public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
        BuiltInMethod.CUMULATIVE_COST.method, new IgniteMdCumulativeCost());

    /** {@inheritDoc} */
    @Override public MetadataDef<BuiltInMetadata.CumulativeCost> getDef() {
        return BuiltInMetadata.CumulativeCost.DEF;
    }

    /** */
    public RelOptCost getCumulativeCost(RelSubset rel, RelMetadataQuery mq) {
        return VolcanoUtils.bestCost(rel);
    }

    /** */
    public RelOptCost getCumulativeCost(RelNode rel, RelMetadataQuery mq) {
        RelOptCost cost = nonCumulativeCost(rel, mq);

        if (cost.isInfinite())
            return cost;

        for (RelNode input : rel.getInputs()) {
            RelOptCost inputCost = mq.getCumulativeCost(input);
            if (inputCost.isInfinite())
                return inputCost;

            cost = cost.plus(inputCost);
        }

        return cost;
    }

    /** */
    public RelOptCost getCumulativeCost(IgniteCorrelatedNestedLoopJoin rel, RelMetadataQuery mq) {<FILL_FUNCTION_BODY>}

    /** */
    private static RelOptCost nonCumulativeCost(RelNode rel, RelMetadataQuery mq) {
        RelOptCost cost = mq.getNonCumulativeCost(rel);

        if (cost.isInfinite())
            return cost;

        RelOptCostFactory costFactory = rel.getCluster().getPlanner().getCostFactory();

        if (rel.getConvention() == Convention.NONE || distribution(rel) == any())
            return costFactory.makeInfiniteCost();

        return costFactory.makeZeroCost().isLt(cost) ? cost : costFactory.makeTinyCost();
    }
}

        RelOptCost cost = nonCumulativeCost(rel, mq);

        if (cost.isInfinite())
            return cost;

        RelNode left = rel.getLeft();
        RelNode right = rel.getRight();

        Set<CorrelationId> corIds = rel.getVariablesSet();

        RelOptCost leftCost = mq.getCumulativeCost(left);
        if (leftCost.isInfinite())
            return leftCost;

        RelOptCost rightCost = mq.getCumulativeCost(right);
        if (rightCost.isInfinite())
            return rightCost;

        return cost.plus(leftCost).plus(rightCost.multiplyBy(left.estimateRowCount(mq) / corIds.size()));
    
<no_super_class>