Search in sources :

Example 1 with UnownedOutputStream

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();
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnownedOutputStream(org.apache.beam.sdk.util.UnownedOutputStream) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UnownedOutputStream (org.apache.beam.sdk.util.UnownedOutputStream)1