use of org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableLongObjectInspector in project presto by prestodb.
the class ParquetTestUtils method getObjectInspector.
private static ObjectInspector getObjectInspector(Type type) {
if (type.equals(BOOLEAN)) {
return writableBooleanObjectInspector;
}
if (type.equals(BIGINT)) {
return writableLongObjectInspector;
}
if (type.equals(INTEGER)) {
return writableIntObjectInspector;
}
if (type.equals(SmallintType.SMALLINT)) {
return writableShortObjectInspector;
}
if (type.equals(TinyintType.TINYINT)) {
return writableByteObjectInspector;
}
if (type.equals(DOUBLE)) {
return writableDoubleObjectInspector;
}
if (type.equals(REAL)) {
return writableFloatObjectInspector;
}
if (type.equals(TIMESTAMP)) {
return writableTimestampObjectInspector;
}
if (type instanceof VarcharType) {
VarcharType varcharType = (VarcharType) type;
int varcharLength = varcharType.getLength();
return getPrimitiveWritableObjectInspector(getVarcharTypeInfo(varcharLength));
}
if (type instanceof DecimalType) {
DecimalType decimalType = (DecimalType) type;
return getPrimitiveWritableObjectInspector(new DecimalTypeInfo(decimalType.getPrecision(), decimalType.getScale()));
}
if (type instanceof ArrayType || type instanceof RowType) {
return getJavaObjectInspector(type);
}
throw new IllegalArgumentException("unsupported type: " + type);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableLongObjectInspector in project presto by prestodb.
the class TestObjectEncoders method testPrimitiveObjectEncoders.
@Test
public void testPrimitiveObjectEncoders() {
ObjectInspector inspector;
ObjectEncoder encoder;
inspector = writableLongObjectInspector;
encoder = createEncoder(BIGINT, inspector);
assertTrue(encoder.encode(new LongWritable(123456L)) instanceof Long);
inspector = writableIntObjectInspector;
encoder = createEncoder(INTEGER, inspector);
assertTrue(encoder.encode(new IntWritable(12345)) instanceof Long);
inspector = writableShortObjectInspector;
encoder = createEncoder(SMALLINT, inspector);
assertTrue(encoder.encode(new ShortWritable((short) 1234)) instanceof Long);
inspector = writableByteObjectInspector;
encoder = createEncoder(TINYINT, inspector);
assertTrue(encoder.encode(new ByteWritable((byte) 123)) instanceof Long);
inspector = writableBooleanObjectInspector;
encoder = createEncoder(BOOLEAN, inspector);
assertTrue(encoder.encode(new BooleanWritable(true)) instanceof Boolean);
inspector = writableDoubleObjectInspector;
encoder = createEncoder(DOUBLE, inspector);
assertTrue(encoder.encode(new DoubleWritable(0.1)) instanceof Double);
inspector = writableDateObjectInspector;
encoder = createEncoder(DATE, inspector);
assertTrue(encoder.encode(new DateWritable(DateTimeUtils.createDate(18380L))) instanceof Long);
inspector = writableHiveDecimalObjectInspector;
encoder = createEncoder(createDecimalType(11, 10), inspector);
assertTrue(encoder.encode(new HiveDecimalWritable("1.2345678910")) instanceof Long);
encoder = createEncoder(createDecimalType(34, 33), inspector);
assertTrue(encoder.encode(new HiveDecimalWritable("1.281734081274028174012432412423134")) instanceof Slice);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableLongObjectInspector in project presto by prestodb.
the class HiveWriteUtils method getRowColumnInspector.
public static ObjectInspector getRowColumnInspector(Type type) {
if (type.equals(BooleanType.BOOLEAN)) {
return writableBooleanObjectInspector;
}
if (type.equals(BigintType.BIGINT)) {
return writableLongObjectInspector;
}
if (type.equals(IntegerType.INTEGER)) {
return writableIntObjectInspector;
}
if (type.equals(SmallintType.SMALLINT)) {
return writableShortObjectInspector;
}
if (type.equals(TinyintType.TINYINT)) {
return writableByteObjectInspector;
}
if (type.equals(RealType.REAL)) {
return writableFloatObjectInspector;
}
if (type.equals(DoubleType.DOUBLE)) {
return writableDoubleObjectInspector;
}
if (type instanceof VarcharType) {
VarcharType varcharType = (VarcharType) type;
int varcharLength = varcharType.getLength();
// VARCHAR columns with the length less than or equal to 65535 are supported natively by Hive
if (varcharLength <= HiveVarchar.MAX_VARCHAR_LENGTH) {
return getPrimitiveWritableObjectInspector(getVarcharTypeInfo(varcharLength));
} else // Values for such columns must be stored as STRING in Hive
if (varcharLength == VarcharType.UNBOUNDED_LENGTH) {
return writableStringObjectInspector;
}
}
if (isCharType(type)) {
CharType charType = (CharType) type;
int charLength = charType.getLength();
return getPrimitiveWritableObjectInspector(getCharTypeInfo(charLength));
}
if (type.equals(VarbinaryType.VARBINARY)) {
return writableBinaryObjectInspector;
}
if (type.equals(DateType.DATE)) {
return writableDateObjectInspector;
}
if (type.equals(TimestampType.TIMESTAMP)) {
return writableTimestampObjectInspector;
}
if (type instanceof DecimalType) {
DecimalType decimalType = (DecimalType) type;
return getPrimitiveWritableObjectInspector(new DecimalTypeInfo(decimalType.getPrecision(), decimalType.getScale()));
}
if (isArrayType(type) || isMapType(type) || isRowType(type)) {
return getJavaObjectInspector(type);
}
throw new IllegalArgumentException("unsupported type: " + type);
}
Aggregations