Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,12 @@
<version>${avro.version}</version>
</dependency>

<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.2.1</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.google.cloud.dataflow.sdk.coders.CoderException;
import com.google.common.base.Preconditions;

import org.xerial.snappy.SnappyInputStream;
import org.xerial.snappy.SnappyOutputStream;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -43,7 +46,7 @@ public class SerializableUtils {
public static byte[] serializeToByteArray(Serializable value) {
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(buffer)) {
try (ObjectOutputStream oos = new ObjectOutputStream(new SnappyOutputStream(buffer))) {
oos.writeObject(value);
}
return buffer.toByteArray();
Expand All @@ -66,7 +69,7 @@ public static Object deserializeFromByteArray(byte[] encodedValue,
String description) {
try {
try (ObjectInputStream ois = new ObjectInputStream(
new ByteArrayInputStream(encodedValue))) {
new SnappyInputStream(new ByteArrayInputStream(encodedValue)))) {
return ois.readObject();
}
} catch (IOException | ClassNotFoundException exn) {
Expand Down