public MergeJoinPlan(Plan p1,Plan p2,String fldName1,String fldName2,Transaction tx){
  this.fldName1=fldName1;
  List<String> sortlist1=Arrays.asList(fldName1);
  this.sp1=new SortPlan(p1,sortlist1,tx);
  this.fldName2=fldName2;
  List<String> sortlist2=Arrays.asList(fldName2);
  this.sp2=new SortPlan(p2,sortlist2,tx);
  schema.addAll(p1.schema());
  schema.addAll(p2.schema());
  hist=joinHistogram(p1.histogram(),p2.histogram(),fldName1,fldName2);
}

public MergeJoinPlan ( Plan p1 , Plan p2 , String fldName1 , String fldName2 , Transaction tx ) { this . fldName1 = fldName1 ; List < String > sortlist1 = Arrays . asList ( fldName1 ) ; this . sp1 = new SortPlan ( p1 , sortlist1 , tx ) ; this . fldName2 = fldName2 ; List < String > sortlist2 = Arrays . asList ( fldName2 ) ; this . sp2 = new SortPlan ( p2 , sortlist2 , tx ) ; schema . addAll ( p1 . schema ( ) ) ; schema . addAll ( p2 . schema ( ) ) ; hist = joinHistogram ( p1 . histogram ( ) , p2 . histogram ( ) , fldName1 , fldName2 ) ; }
creates a mergejoin plan for the two specified queries . the rhs must be materialized after it is sorted , in order to deal with possible duplicates .
