Java Code Examples for org.apache.avro.io.Encoder#writeFloat()
The following examples show how to use
org.apache.avro.io.Encoder#writeFloat() .
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: PigAvroDatumWriter.java From Cubert with Apache License 2.0 | 5 votes |
/** * Write float. Users can cast long and integer into float. * */ protected void writeFloat(Object datum, Encoder out) throws IOException { float num; if (datum instanceof Integer) { num = ((Integer) datum).floatValue(); } else if (datum instanceof Long) { num = ((Long) datum).floatValue(); } else if (datum instanceof Float) { num = (Float) datum; } else throw new IOException("Cannot convert to float:" + datum.getClass()); out.writeFloat(num); }
Example 2
Source File: PigAvroDatumWriter.java From spork with Apache License 2.0 | 5 votes |
/** * Write float. Users can cast long and integer into float. * */ protected void writeFloat(Object datum, Encoder out) throws IOException { float num; if (datum instanceof Integer) { num = ((Integer) datum).floatValue(); } else if (datum instanceof Long) { num = ((Long) datum).floatValue(); } else if (datum instanceof Float) { num = (Float) datum; } else throw new IOException("Cannot convert to float:" + datum.getClass()); out.writeFloat(num); }
Example 3
Source File: ValueWriters.java From iceberg with Apache License 2.0 | 4 votes |
@Override public void write(Float f, Encoder encoder) throws IOException { encoder.writeFloat(f); }
Example 4
Source File: ValueWriters.java From iceberg with Apache License 2.0 | 4 votes |
@Override public void write(Float f, Encoder encoder) throws IOException { encoder.writeFloat(f); }