@Test public void testWriteAvroEntity() throws Exception { String schemaString = "{ \"type\": \"int\" }"; InputStream is = new ByteArrayInputStream(schemaString.getBytes()); Schema schema = parser.parse(is); DatumWriter<Integer> writer = new GenericDatumWriter<Integer>(schema); byte[] bytes = AvroUtils.writeAvroEntity(1, writer); assertArrayEquals(new byte[] { (byte) 2 }, bytes); }
public static <T> byte[] writeAvroEntity(T entity, DatumWriter<T> writer) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Encoder encoder = new EncoderFactory().binaryEncoder(outputStream, null); writeAvroEntity(entity, encoder, writer); return outputStream.toByteArray(); }
AvroUtils { public static <T> byte[] writeAvroEntity(T entity, DatumWriter<T> writer) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Encoder encoder = new EncoderFactory().binaryEncoder(outputStream, null); writeAvroEntity(entity, encoder, writer); return outputStream.toByteArray(); } }
AvroUtils { public static <T> byte[] writeAvroEntity(T entity, DatumWriter<T> writer) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Encoder encoder = new EncoderFactory().binaryEncoder(outputStream, null); writeAvroEntity(entity, encoder, writer); return outputStream.toByteArray(); }  }
AvroUtils { public static <T> byte[] writeAvroEntity(T entity, DatumWriter<T> writer) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Encoder encoder = new EncoderFactory().binaryEncoder(outputStream, null); writeAvroEntity(entity, encoder, writer); return outputStream.toByteArray(); }  static T readAvroEntity(byte[] bytes, DatumReader<T> reader); static T readAvroEntity(Decoder decoder, DatumReader<T> reader); static byte[] writeAvroEntity(T entity, DatumWriter<T> writer); static void writeAvroEntity(T entity, Encoder encoder,
      DatumWriter<T> writer); static Field cloneField(Field field); static String inputStreamToString(InputStream in); static Map<String, Object> getDefaultValueMap(Schema avroRecordSchema); static AvroKeySchema mergeSpecificStringTypes(
      Class<? extends SpecificRecord> specificClass, AvroKeySchema keySchema); static AvroEntitySchema mergeSpecificStringTypes(
      Class<? extends SpecificRecord> specificClass,
      AvroEntitySchema entitySchema); static boolean avroSchemaTypesEqual(Schema schema1, Schema schema2); }
AvroUtils { public static <T> byte[] writeAvroEntity(T entity, DatumWriter<T> writer) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Encoder encoder = new EncoderFactory().binaryEncoder(outputStream, null); writeAvroEntity(entity, encoder, writer); return outputStream.toByteArray(); }  static T readAvroEntity(byte[] bytes, DatumReader<T> reader); static T readAvroEntity(Decoder decoder, DatumReader<T> reader); static byte[] writeAvroEntity(T entity, DatumWriter<T> writer); static void writeAvroEntity(T entity, Encoder encoder,
      DatumWriter<T> writer); static Field cloneField(Field field); static String inputStreamToString(InputStream in); static Map<String, Object> getDefaultValueMap(Schema avroRecordSchema); static AvroKeySchema mergeSpecificStringTypes(
      Class<? extends SpecificRecord> specificClass, AvroKeySchema keySchema); static AvroEntitySchema mergeSpecificStringTypes(
      Class<? extends SpecificRecord> specificClass,
      AvroEntitySchema entitySchema); static boolean avroSchemaTypesEqual(Schema schema1, Schema schema2);  }