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