use of org.apache.hadoop.hive.serde2.objectinspector.FullMapEqualComparer in project cdap by caskdata.
the class FullMapEqualComparerTest method testTransitivity.
@Test
public void testTransitivity() {
IntegerIntegerMapHolder o1 = new IntegerIntegerMapHolder();
IntegerIntegerMapHolder o2 = new IntegerIntegerMapHolder();
IntegerIntegerMapHolder o3 = new IntegerIntegerMapHolder();
ObjectInspector oi = ObjectInspectorFactory.getReflectionObjectInspector(IntegerIntegerMapHolder.class);
o1.mMap.put(1, 1);
o1.mMap.put(99, 99);
o2.mMap.put(0, 99);
o2.mMap.put(99, 99);
o3.mMap.put(0, 1);
o3.mMap.put(1, 99);
{
// non-transitive
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new SimpleMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc23 = ObjectInspectorUtils.compare(o2, oi, o3, oi, new SimpleMapEqualComparer());
Assert.assertTrue(rc23 > 0);
int rc13 = ObjectInspectorUtils.compare(o1, oi, o3, oi, new SimpleMapEqualComparer());
Assert.assertTrue(rc13 < 0);
}
{
// non-transitive
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new CrossMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc23 = ObjectInspectorUtils.compare(o2, oi, o3, oi, new CrossMapEqualComparer());
Assert.assertTrue(rc23 > 0);
int rc13 = ObjectInspectorUtils.compare(o1, oi, o3, oi, new CrossMapEqualComparer());
Assert.assertTrue(rc13 < 0);
}
{
// transitive
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new FullMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc23 = ObjectInspectorUtils.compare(o2, oi, o3, oi, new FullMapEqualComparer());
Assert.assertTrue(rc23 > 0);
int rc13 = ObjectInspectorUtils.compare(o1, oi, o3, oi, new FullMapEqualComparer());
Assert.assertTrue(rc13 > 0);
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.FullMapEqualComparer in project cdap by caskdata.
the class FullMapEqualComparerTest method testAntiSymmetry.
@Test
public void testAntiSymmetry() {
IntegerIntegerMapHolder o1 = new IntegerIntegerMapHolder();
IntegerIntegerMapHolder o2 = new IntegerIntegerMapHolder();
ObjectInspector oi = ObjectInspectorFactory.getReflectionObjectInspector(IntegerIntegerMapHolder.class);
o1.mMap.put(1, 1);
o2.mMap.put(0, 99);
{
// not anti-symmetric
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new SimpleMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc21 = ObjectInspectorUtils.compare(o2, oi, o1, oi, new SimpleMapEqualComparer());
Assert.assertTrue(rc21 > 0);
}
{
// not anti-symmetric
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new CrossMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc21 = ObjectInspectorUtils.compare(o2, oi, o1, oi, new CrossMapEqualComparer());
Assert.assertTrue(rc21 > 0);
}
{
// anti-symmetric
int rc12 = ObjectInspectorUtils.compare(o1, oi, o2, oi, new FullMapEqualComparer());
Assert.assertTrue(rc12 > 0);
int rc21 = ObjectInspectorUtils.compare(o2, oi, o1, oi, new FullMapEqualComparer());
Assert.assertTrue(rc21 < 0);
}
}
Aggregations