use of org.apache.beam.sdk.util.UnownedOutputStream in project beam by apache.
the class CoderProperties method encode.
//////////////////////////////////////////////////////////////////////////
@VisibleForTesting
static <T> byte[] encode(Coder<T> coder, Coder.Context context, T value) throws CoderException, IOException {
@SuppressWarnings("unchecked") Coder<T> deserializedCoder = SerializableUtils.clone(coder);
ByteArrayOutputStream os = new ByteArrayOutputStream();
deserializedCoder.encode(value, new UnownedOutputStream(os), context);
return os.toByteArray();
}
Aggregations