@Test public void testDeepCopySpecific() { Person person = new Person(); person.setName("John Doe"); person.setAge(42); person.setSiblingnames(Lists.<CharSequence> newArrayList()); Person deepCopyPerson = new AvroSpecificDeepCopier<Person>(Person.class, Person.SCHEMA$) .deepCopy(person); assertEquals(person, deepCopyPerson); assertNotSame(person, deepCopyPerson); }
public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; }
AvroDeepCopier implements Serializable { public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; } }
AvroDeepCopier implements Serializable { public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; } protected  AvroDeepCopier(DatumWriter<T> datumWriter, DatumReader<T> datumReader); }
AvroDeepCopier implements Serializable { public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; } protected  AvroDeepCopier(DatumWriter<T> datumWriter, DatumReader<T> datumReader); T deepCopy(T source); }
AvroDeepCopier implements Serializable { public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; } protected  AvroDeepCopier(DatumWriter<T> datumWriter, DatumReader<T> datumReader); T deepCopy(T source);  }