use of org.apache.hadoop.io.IntWritable in project hive by apache.
the class TestDeepParquetHiveMapInspector method testRegularMap.
@Test
public void testRegularMap() {
final Writable[] entry1 = new Writable[] { new IntWritable(0), new IntWritable(1) };
final Writable[] entry2 = new Writable[] { new IntWritable(2), new IntWritable(3) };
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, new Writable[] { new ArrayWritable(Writable.class, entry1), new ArrayWritable(Writable.class, entry2) });
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new IntWritable(0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new IntWritable(2)));
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new ShortWritable((short) 0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new ShortWritable((short) 2)));
}
use of org.apache.hadoop.io.IntWritable in project hive by apache.
the class TestDeepParquetHiveMapInspector method testHashMap.
@Test
public void testHashMap() {
final Map<Writable, Writable> map = new HashMap<Writable, Writable>();
map.put(new IntWritable(0), new IntWritable(1));
map.put(new IntWritable(2), new IntWritable(3));
map.put(new IntWritable(4), new IntWritable(5));
map.put(new IntWritable(6), new IntWritable(7));
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new IntWritable(0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new IntWritable(2)));
assertEquals("Wrong result of inspection", new IntWritable(5), inspector.getMapValueElement(map, new IntWritable(4)));
assertEquals("Wrong result of inspection", new IntWritable(7), inspector.getMapValueElement(map, new IntWritable(6)));
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new ShortWritable((short) 0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new ShortWritable((short) 2)));
assertEquals("Wrong result of inspection", new IntWritable(5), inspector.getMapValueElement(map, new ShortWritable((short) 4)));
assertEquals("Wrong result of inspection", new IntWritable(7), inspector.getMapValueElement(map, new ShortWritable((short) 6)));
}
use of org.apache.hadoop.io.IntWritable in project hive by apache.
the class TestStandardParquetHiveMapInspector method testRegularMap.
@Test
public void testRegularMap() {
final Writable[] entry1 = new Writable[] { new IntWritable(0), new IntWritable(1) };
final Writable[] entry2 = new Writable[] { new IntWritable(2), new IntWritable(3) };
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, new Writable[] { new ArrayWritable(Writable.class, entry1), new ArrayWritable(Writable.class, entry2) });
assertEquals("Wrong result of inspection", new IntWritable(1), inspector.getMapValueElement(map, new IntWritable(0)));
assertEquals("Wrong result of inspection", new IntWritable(3), inspector.getMapValueElement(map, new IntWritable(2)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 0)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 2)));
}
use of org.apache.hadoop.io.IntWritable in project hive by apache.
the class TestToInteger method testTextToInteger.
@Test
public void testTextToInteger() throws Exception {
UDFToInteger ti = new UDFToInteger();
Text t1 = new Text("-1");
IntWritable i1 = ti.evaluate(t1);
assertEquals(-1, i1.get());
Text t2 = new Text("0");
IntWritable i2 = ti.evaluate(t2);
assertEquals(0, i2.get());
Text t3 = new Text("A");
IntWritable i3 = ti.evaluate(t3);
assertNull(i3);
Text t4 = new Text("1.1");
IntWritable i4 = ti.evaluate(t4);
assertEquals(1, i4.get());
}
use of org.apache.hadoop.io.IntWritable in project hive by apache.
the class TestGenericUDFAbs method testInt.
public void testInt() throws HiveException {
GenericUDFAbs udf = new GenericUDFAbs();
ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
ObjectInspector[] arguments = { valueOI };
udf.initialize(arguments);
DeferredObject valueObj = new DeferredJavaObject(new IntWritable(107));
DeferredObject[] args = { valueObj };
IntWritable output = (IntWritable) udf.evaluate(args);
assertEquals("abs() test for INT failed ", 107, output.get());
valueObj = new DeferredJavaObject(new IntWritable(-107));
args[0] = valueObj;
output = (IntWritable) udf.evaluate(args);
assertEquals("abs() test for INT failed ", 107, output.get());
}
Aggregations