use of com.drew.lang.Rational in project drill by apache.
the class ImageDirectoryProcessor method processValue.
/**
* Convert the value if necessary
* @see org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter#setObject(Object)
* @param writer MapColumnDefn
* @param name Tag Name
* @param value Tag Value
*/
protected static void processValue(final MapColumnDefn writer, final String name, final Object value) {
if (value == null) {
return;
}
if (value instanceof Boolean) {
writer.addObject(name, MinorType.BIT).setObject(value);
} else if (value instanceof Byte) {
writer.addObject(name, MinorType.TINYINT).setObject(value);
} else if (value instanceof Short) {
writer.addObject(name, MinorType.SMALLINT).setObject(value);
} else if (value instanceof Integer) {
writer.addObject(name, MinorType.INT).setObject(value);
} else if (value instanceof Long) {
writer.addObject(name, MinorType.BIGINT).setObject(value);
} else if (value instanceof Float) {
writer.addObject(name, MinorType.FLOAT4).setObject(value);
} else if (value instanceof Double) {
writer.addObject(name, MinorType.FLOAT8).setObject(value);
} else if (value instanceof Rational) {
writer.addDouble(name).setDouble(((Rational) value).doubleValue());
} else if (value instanceof StringValue) {
writer.addText(name).setString(((StringValue) value).toString());
} else if (value instanceof Date) {
writer.addDate(name).setTimestamp(Instant.ofEpochMilli(((Date) value).getTime()));
} else if (value instanceof String[]) {
writer.addList(name).setObject(value);
} else if (value instanceof byte[]) {
writer.addListByte(name).setObject(value);
} else if (value instanceof JpegComponent) {
JpegComponent v = (JpegComponent) value;
TupleWriter component = writer.addMap(name);
writer.addIntToMap(component, TagName.JPEGCOMPONENT_CID).setInt(v.getComponentId());
writer.addIntToMap(component, TagName.JPEGCOMPONENT_HSF).setInt(v.getHorizontalSamplingFactor());
writer.addIntToMap(component, TagName.JPEGCOMPONENT_VSF).setInt(v.getVerticalSamplingFactor());
writer.addIntToMap(component, TagName.JPEGCOMPONENT_QTN).setInt(v.getQuantizationTableNumber());
} else if (value instanceof List<?>) {
ArrayWriter listMap = writer.addListMap(name);
ListColumnDefn list = new ListColumnDefn(name).builder(listMap);
for (Object v : (List<?>) value) {
if (v instanceof KeyValuePair) {
list.addText(TagName.KEYVALUEPAIR_K).setString(((KeyValuePair) v).getKey());
list.addText(TagName.KEYVALUEPAIR_V).setString(((KeyValuePair) v).getValue().toString());
} else {
list.addText(TagName.KEYVALUEPAIR_V).setString(v.toString());
}
listMap.save();
}
} else {
writer.addText(name).setString(value.toString());
}
}
Aggregations