use of org.apache.hadoop.hive.serde2.io.ShortWritable in project hive by apache.
the class TypedBytesRecordReader method write.
private void write(int pos, Writable inpw) throws IOException {
String typ = columnTypes.get(pos);
Writable w = (Writable) converters.get(pos).convert(inpw);
if (typ.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) {
tbOut.writeBoolean((BooleanWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) {
tbOut.writeByte((ByteWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) {
tbOut.writeShort((ShortWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) {
tbOut.writeInt((IntWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) {
tbOut.writeLong((LongWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) {
tbOut.writeFloat((FloatWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) {
tbOut.writeDouble((DoubleWritable) w);
} else if (typ.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {
tbOut.writeText((Text) w);
} else {
assert false;
}
}
use of org.apache.hadoop.hive.serde2.io.ShortWritable in project hive by apache.
the class TestDeepParquetHiveMapInspector method testEmptyContainer.
@Test
public void testEmptyContainer() {
final ArrayWritable map = new ArrayWritable(ArrayWritable.class, new ArrayWritable[0]);
assertNull("Should be null", inspector.getMapValueElement(map, new ShortWritable((short) 0)));
}
use of org.apache.hadoop.hive.serde2.io.ShortWritable in project hive by apache.
the class TestStandardParquetHiveMapInspector 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)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 0)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 2)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 4)));
assertNull("Wrong result of inspection", inspector.getMapValueElement(map, new ShortWritable((short) 6)));
}
use of org.apache.hadoop.hive.serde2.io.ShortWritable in project hive by apache.
the class TestParquetShortInspector method testShortWritable.
@Test
public void testShortWritable() {
ShortWritable obj = new ShortWritable((short) 5);
assertEquals(obj, inspector.getPrimitiveWritableObject(obj));
assertEquals((short) 5, inspector.getPrimitiveJavaObject(obj));
}
use of org.apache.hadoop.hive.serde2.io.ShortWritable in project hive by apache.
the class TestParquetShortInspector method testIntWritable.
@Test
public void testIntWritable() {
IntWritable obj = new IntWritable(10);
assertEquals(new ShortWritable((short) 10), inspector.getPrimitiveWritableObject(obj));
assertEquals((short) 10, inspector.getPrimitiveJavaObject(obj));
}
Aggregations