Java Code Examples for org.apache.avro.Conversion#toFloat()
The following examples show how to use
org.apache.avro.Conversion#toFloat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvroWriteSupportInt96Avro18.java From datacollector with Apache License 2.0 | 6 votes |
private <D> Object convert(Schema schema, LogicalType logicalType, Conversion<D> conversion, Object datum) { if (conversion == null) { return datum; } Class<D> fromClass = conversion.getConvertedType(); switch (schema.getType()) { case RECORD: return conversion.toRecord(fromClass.cast(datum), schema, logicalType); case ENUM: return conversion.toEnumSymbol(fromClass.cast(datum), schema, logicalType); case ARRAY: return conversion.toArray(fromClass.cast(datum), schema, logicalType); case MAP: return conversion.toMap(fromClass.cast(datum), schema, logicalType); case FIXED: return conversion.toFixed(fromClass.cast(datum), schema, logicalType); case STRING: return conversion.toCharSequence(fromClass.cast(datum), schema, logicalType); case BYTES: return conversion.toBytes(fromClass.cast(datum), schema, logicalType); case INT: return conversion.toInt(fromClass.cast(datum), schema, logicalType); case LONG: return conversion.toLong(fromClass.cast(datum), schema, logicalType); case FLOAT: return conversion.toFloat(fromClass.cast(datum), schema, logicalType); case DOUBLE: return conversion.toDouble(fromClass.cast(datum), schema, logicalType); case BOOLEAN: return conversion.toBoolean(fromClass.cast(datum), schema, logicalType); default: break; } return datum; }
Example 2
Source File: AvroWriteSupport.java From parquet-mr with Apache License 2.0 | 6 votes |
private <D> Object convert(Schema schema, LogicalType logicalType, Conversion<D> conversion, Object datum) { if (conversion == null) { return datum; } Class<D> fromClass = conversion.getConvertedType(); switch (schema.getType()) { case RECORD: return conversion.toRecord(fromClass.cast(datum), schema, logicalType); case ENUM: return conversion.toEnumSymbol(fromClass.cast(datum), schema, logicalType); case ARRAY: return conversion.toArray(fromClass.cast(datum), schema, logicalType); case MAP: return conversion.toMap(fromClass.cast(datum), schema, logicalType); case FIXED: return conversion.toFixed(fromClass.cast(datum), schema, logicalType); case STRING: return conversion.toCharSequence(fromClass.cast(datum), schema, logicalType); case BYTES: return conversion.toBytes(fromClass.cast(datum), schema, logicalType); case INT: return conversion.toInt(fromClass.cast(datum), schema, logicalType); case LONG: return conversion.toLong(fromClass.cast(datum), schema, logicalType); case FLOAT: return conversion.toFloat(fromClass.cast(datum), schema, logicalType); case DOUBLE: return conversion.toDouble(fromClass.cast(datum), schema, logicalType); case BOOLEAN: return conversion.toBoolean(fromClass.cast(datum), schema, logicalType); } return datum; }