com.adgear.anoa.write.AvroWriteConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anoa-core Show documentation
Show all versions of anoa-core Show documentation
Core classes for Anoa library, which aims to be a safe, convenient and fast record
de/serialization wrapper for the Avro, Thrift and Jackson libraries, using the functional idioms
of Java 8.
The anoa-core module tries to keep upstream dependencies to a minimum.
package com.adgear.anoa.write;
import org.apache.avro.generic.IndexedRecord;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.Encoder;
import java.io.IOException;
class AvroWriteConsumer implements WriteConsumer {
final DatumWriter writer;
final Encoder encoder;
AvroWriteConsumer(DatumWriter writer, Encoder encoder) {
this.writer = writer;
this.encoder = encoder;
}
@Override
public void acceptChecked(R record) throws IOException {
writer.write(record, encoder);
}
@Override
public void flush() throws IOException {
encoder.flush();
}
}