com.adgear.anoa.write.AvroWriter Maven / Gradle / Ivy
package com.adgear.anoa.write;
import com.fasterxml.jackson.core.JsonGenerator;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.IndexedRecord;
import org.apache.avro.specific.SpecificData;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
class AvroWriter extends AbstractRecordWriter {
final Map> fieldWriters;
final Map fieldDefaults;
final DefaultValueTester tester;
final Schema schema;
AvroWriter(Class recordClass) {
this(new AvroWriterSpecificData(), SpecificData.get().getSchema(recordClass));
}
AvroWriter(Schema schema) {
this(new AvroWriterGenericData(), schema);
}
@SuppressWarnings("unchecked")
private AvroWriter(DefaultValueTester tester, Schema schema) {
this.tester = tester;
this.schema = schema;
this.fieldWriters = new LinkedHashMap<>();
this.fieldDefaults = new HashMap<>();
schema.getFields().stream().forEach(f -> {
fieldWriters.put(f, (AbstractWriter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy