Java Code Examples for org.apache.avro.io.Encoder#writeBoolean()

The following examples show how to use org.apache.avro.io.Encoder#writeBoolean() . 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 vote down vote up
/**
 * Write boolean. Users can cast an integer into boolean.
 * 
 */
protected void writeBoolean(Object datum, Encoder out) throws IOException {

    if (datum instanceof Boolean) {
        out.writeBoolean((Boolean) datum);
    } else if (datum instanceof Integer) {
        out.writeBoolean(((Integer) datum) != 0);
    } else
        throw new RuntimeException("Unsupported type boolean:" + datum.getClass());

}
 
Example 2
Source File: PigAvroDatumWriter.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * Write boolean. Users can cast an integer into boolean.
 * 
 */
protected void writeBoolean(Object datum, Encoder out) throws IOException {

    if (datum instanceof Boolean) {
        out.writeBoolean((Boolean) datum);
    } else if (datum instanceof Integer) {
        out.writeBoolean(((Integer) datum) != 0);
    } else
        throw new RuntimeException("Unsupported type boolean:" + datum.getClass());

}
 
Example 3
Source File: ValueWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Boolean bool, Encoder encoder) throws IOException {
  encoder.writeBoolean(bool);
}
 
Example 4
Source File: ValueWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Boolean bool, Encoder encoder) throws IOException {
  encoder.writeBoolean(bool);
}