### Question:
JoinPredicate implements Serializable { public boolean filter(Tuple t1, Tuple t2) { Field field1= t1.getField(numField1); Field field2= t2.getField(numField2); return field1.compare(op,field2); } JoinPredicate(int field1, Predicate.Op op, int field2); boolean filter(Tuple t1, Tuple t2); int getField1(); int getField2(); Predicate.Op getOperator();  }### Answer:
@Test public void filterVaryingVals() { int[] vals = new int[] { -1, 0, 1 }; for (int i : vals) { JoinPredicate p = new JoinPredicate(0, Predicate.Op.EQUALS, 0); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i - 1))); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i))); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i + 1))); } for (int i : vals) { JoinPredicate p = new JoinPredicate(0, Predicate.Op.GREATER_THAN, 0); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i - 1))); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i))); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i + 1))); } for (int i : vals) { JoinPredicate p = new JoinPredicate(0, Predicate.Op.GREATER_THAN_OR_EQ, 0); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i - 1))); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i))); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i + 1))); } for (int i : vals) { JoinPredicate p = new JoinPredicate(0, Predicate.Op.LESS_THAN, 0); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i - 1))); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i))); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i + 1))); } for (int i : vals) { JoinPredicate p = new JoinPredicate(0, Predicate.Op.LESS_THAN_OR_EQ, 0); assertFalse(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i - 1))); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i))); assertTrue(p.filter(Utility.getHeapTuple(i), Utility.getHeapTuple(i + 1))); } }