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

The following examples show how to use org.apache.avro.io.Encoder#writeIndex() . 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: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
public void write(T option, Encoder encoder) throws IOException {
  if (option == null) {
    encoder.writeIndex(nullIndex);
  } else {
    encoder.writeIndex(valueIndex);
    valueWriter.write(option, encoder);
  }
}
 
Example 2
Source File: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
public void write(T option, Encoder encoder) throws IOException {
  if (option == null) {
    encoder.writeIndex(nullIndex);
  } else {
    encoder.writeIndex(valueIndex);
    valueWriter.write(option, encoder);
  }
}
 
Example 3
Source File: PigAvroDatumWriter.java    From Cubert with Apache License 2.0 5 votes vote down vote up
/**
 * Called to write union. 
 */
protected void writeUnion(Schema schema, Object datum, Encoder out)
                                throws IOException {
    int index = resolveUnionSchema(schema, datum);
    out.writeIndex(index);
    write(schema.getTypes().get(index), datum, out);
}
 
Example 4
Source File: PigAvroDatumWriter.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * Called to write union. 
 */
protected void writeUnion(Schema schema, Object datum, Encoder out)
                                throws IOException {
    int index = resolveUnionSchema(schema, datum);
    out.writeIndex(index);
    write(schema.getTypes().get(index), datum, out);
}