private Placement placeJoin(ExprList exprs, OpJoin opJoin) {
Op left = opJoin.getLeft() ;
Op right = opJoin.getRight() ;
Collection<Var> leftVars = fixedVars(left) ;
Collection<Var> rightVars = fixedVars(right) ;
ExprList unpushed = new ExprList() ;
ExprList pushLeft = new ExprList() ;
ExprList pushRight = new ExprList() ;
for (Expr expr : exprs) {
Set<Var> vars = expr.getVarsMentioned() ;
boolean pushed = false ;
if ( leftVars.containsAll(vars) ) {
pushLeft.add(expr) ;
pushed = true ;
}
if ( pushed && ! pushRightAsWellAsLeft )
continue ;
// If left only, make this "else if" of left test, remove "continue"
if ( rightVars.containsAll(vars) ) {
// Push right
pushRight.add(expr) ;
pushed = true ;
}
if ( !pushed )
unpushed.add(expr) ;
}
if ( pushLeft.isEmpty() && pushRight.isEmpty() )
return null ;
Op opLeftNew = left ;
if ( !pushLeft.isEmpty() )
opLeftNew = transformOpAlways(pushLeft, opLeftNew) ;
Op opRightNew = right ;
if ( !pushRight.isEmpty() )
opRightNew = transformOpAlways(pushRight, opRightNew) ;
Op op = OpJoin.create(opLeftNew, opRightNew) ;
return result(op, unpushed) ;
}