protected TupleExpr selectNextTupleExpr(List<TupleExpr> expressions,Map<TupleExpr,Double> cardinalityMap,Map<TupleExpr,List<Var>> varsMap,Map<Var,Integer> varFreqMap,Set<String> boundVars){
  TupleExpr result=null;
  if (expressions.size() > 1) {
    double lowestCardinality=Double.POSITIVE_INFINITY;
    for (    TupleExpr tupleExpr : expressions) {
      double cardinality=getTupleExprCardinality(tupleExpr,cardinalityMap,varsMap,varFreqMap,boundVars);
      if (cardinality < lowestCardinality || result == null) {
        lowestCardinality=cardinality;
        result=tupleExpr;
      }
    }
  }
 else {
    result=expressions.get(0);
  }
  return result;
}

protected TupleExpr selectNextTupleExpr ( List < TupleExpr > expressions , Map < TupleExpr , Double > cardinalityMap , Map < TupleExpr , List < Var > > varsMap , Map < Var , Integer > varFreqMap , Set < String > boundVars ) { TupleExpr result = null ; if ( expressions . size ( ) > 1 ) { double lowestCardinality = Double . POSITIVE_INFINITY ; for ( TupleExpr tupleExpr : expressions ) { double cardinality = getTupleExprCardinality ( tupleExpr , cardinalityMap , varsMap , varFreqMap , boundVars ) ; if ( cardinality < lowestCardinality || result == null ) { lowestCardinality = cardinality ; result = tupleExpr ; } } } else { result = expressions . get ( 0 ) ; } return result ; }
selects from a list of tuple expressions the next tuple expression that should be evaluated . this method selects the tuple expression with highest number of bound variables , preferring variables that have been bound in other tuple expressions over variables with a fixed value .
