use of org.apache.hadoop.io.BinaryComparable in project presto by prestodb.
the class GenericHiveRecordCursor method parseStringFromPrimitiveWritableObjectValue.
private static Slice parseStringFromPrimitiveWritableObjectValue(Type type, Object fieldValue) {
checkState(fieldValue != null, "fieldValue should not be null");
BinaryComparable hiveValue;
if (fieldValue instanceof Text) {
hiveValue = (Text) fieldValue;
} else if (fieldValue instanceof BytesWritable) {
hiveValue = (BytesWritable) fieldValue;
} else if (fieldValue instanceof HiveVarcharWritable) {
hiveValue = ((HiveVarcharWritable) fieldValue).getTextValue();
} else if (fieldValue instanceof HiveCharWritable) {
hiveValue = ((HiveCharWritable) fieldValue).getTextValue();
} else {
throw new IllegalStateException("unsupported string field type: " + fieldValue.getClass().getName());
}
// create a slice view over the hive value and trim to character limits
Slice value = trimStringToCharacterLimits(type, Slices.wrappedBuffer(hiveValue.getBytes(), 0, hiveValue.getLength()));
// store a copy of the bytes, since the hive reader can reuse the underlying buffer
return Slices.copyOf(value);
}
Aggregations