Source:
public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate innerCost) throws StandardException{ if(outerCost.isUninitialized() ||(outerCost.localCost()==0d && outerCost.getEstimatedRowCount()==1.0)){ RowOrdering ro = outerCost.getRowOrdering(); if(ro!=null) outerCost.setRowOrdering(ro); return; } SpliceLogUtils.trace(LOG,"rightResultSetCostEstimate outerCost=%s, innerFullKeyCost=%s",outerCost,innerCost); AccessPath currentAccessPath = innerTable.getCurrentAccessPath(); innerCost.setBase(innerCost.cloneMe()); double joinSelectivity = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost, SelectivityUtil.JoinPredicateType.ALL); double totalOutputRows = SelectivityUtil.getTotalRows(joinSelectivity, outerCost.rowCount(), innerCost.rowCount()); double joinSelectivityWithSearchConditionsOnly = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost, SelectivityUtil.JoinPredicateType.HASH_SEARCH); double totalJoinedRows = SelectivityUtil.getTotalRows(joinSelectivityWithSearchConditionsOnly, outerCost.rowCount(), innerCost.rowCount()); innerCost.setNumPartitions(outerCost.partitionCount()); double joinCost = crossJoinStrategyLocalCost(innerCost, outerCost, totalJoinedRows); innerCost.setLocalCost(joinCost); innerCost.setLocalCostPerPartition(joinCost); innerCost.setRemoteCost(SelectivityUtil.getTotalRemoteCost(innerCost, outerCost, totalOutputRows)); innerCost.setRowCount(totalOutputRows); innerCost.setEstimatedHeapSize((long) SelectivityUtil.getTotalHeapSize(innerCost, outerCost, totalOutputRows)); innerCost.setNumPartitions(outerCost.partitionCount()); innerCost.setRowOrdering(null); }

Target:
public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate innerCost) throws StandardException{ if(outerCost.isUninitialized() ||(outerCost.localCost()==0d && outerCost.getEstimatedRowCount()==1.0)){ RowOrdering ro = outerCost.getRowOrdering(); if(ro!=null) outerCost.setRowOrdering(ro); return; } SpliceLogUtils.trace(LOG,"rightResultSetCostEstimate outerCost=%s, innerFullKeyCost=%s",outerCost,innerCost); AccessPath currentAccessPath = innerTable.getCurrentAccessPath(); innerCost.setBase(innerCost.cloneMe()); double joinSelectivity = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost, SelectivityUtil.JoinPredicateType.ALL); double totalOutputRows = SelectivityUtil.getTotalRows(joinSelectivity, outerCost.rowCount(), innerCost.rowCount()); double joinSelectivityWithSearchConditionsOnly = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost, SelectivityUtil.JoinPredicateType.HASH_SEARCH); double totalJoinedRows = SelectivityUtil.getTotalRows(joinSelectivityWithSearchConditionsOnly, outerCost.rowCount(), innerCost.rowCount()); double joinCost = crossJoinStrategyLocalCost(innerCost, outerCost, totalJoinedRows); innerCost.setLocalCost(joinCost); innerCost.setLocalCostPerPartition(joinCost); innerCost.setRemoteCost(SelectivityUtil.getTotalRemoteCost(innerCost, outerCost, totalOutputRows)); innerCost.setRowCount(totalOutputRows); innerCost.setEstimatedHeapSize((long) SelectivityUtil.getTotalHeapSize(innerCost, outerCost, totalOutputRows)); innerCost.setNumPartitions(outerCost.partitionCount()); innerCost.setRowOrdering(null); }