binaryEncoder metodu
Avro formatında kodekler
Örnek
Şöyle yaparız
import org.apache.avro.io.DatumWriter;import org.apache.avro.io.Encoder;import org.apache.avro.io.EncoderFactory;import org.apache.avro.specific.SpecificDatumWriter;DatumWriter<InsuranceClaim> writer = new SpecificDatumWriter<>(InsuranceClaim.class);ByteArrayOutputStream stream = new ByteArrayOutputStream();Encoder encoder = EncoderFactory.get().binaryEncoder(stream, null);List<InsuranceClaim> records = ...;for (InsuranceClaim record : records) {writer.write(record, encoder);}encoder.flush();byte[] data = stream.toByteArray();
No comments:
Post a Comment