PARQUET-415: Fix ByteBuffer Binary serialization.
This also adds a test to validate that serialization works for all
Binary objects that are already test cases.
Author: Ryan Blue <blue@apache.org>
Closes #305 from rdblue/PARQUET-415-fix-bytebuffer-binary-serialization and squashes the following
commits:
4e75d54 [Ryan Blue] PARQUET-415: Fix ByteBuffer Binary serialization.
Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/7ec373df
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/7ec373df
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/7ec373df
Branch: refs/heads/parquet-1.8.x
Commit: 7ec373df83b1bfd376704bf42a52bfbe97ae6bb8
Parents: a5ce86d
Author: Ryan Blue <blue@apache.org>
Authored: Wed Feb 3 12:45:27 2016 -0800
Committer: Ryan Blue <blue@apache.org>
Committed: Fri Jan 6 12:06:55 2017 -0800
----------------------------------------------------------------------
.../org/apache/parquet/io/api/TestBinary.java | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/7ec373df/parquet-column/src/test/java/org/apache/parquet/io/api/TestBinary.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/test/java/org/apache/parquet/io/api/TestBinary.java b/parquet-column/src/test/java/org/apache/parquet/io/api/TestBinary.java
index bd8a69d..4f9b8f9 100644
--- a/parquet-column/src/test/java/org/apache/parquet/io/api/TestBinary.java
+++ b/parquet-column/src/test/java/org/apache/parquet/io/api/TestBinary.java
@@ -18,6 +18,10 @@
*/
package org.apache.parquet.io.api;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -27,6 +31,7 @@ import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
public class TestBinary {
@@ -202,6 +207,22 @@ public class TestBinary {
assertArrayEquals(testString.getBytes(UTF8), copy.copy().getBytes());
}
+ private void testSerializable(BinaryFactory bf, boolean reused) throws Exception {
+ BinaryAndOriginal bao = bf.get("polygon".getBytes(UTF8), reused);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(bao.binary);
+ out.close();
+ baos.close();
+
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
+ baos.toByteArray()));
+ Object object = in.readObject();
+ assertTrue(object instanceof Binary);
+ assertEquals(bao.binary, object);
+ }
+
private void testBinary(BinaryFactory bf, boolean reused) throws Exception {
testSlice(bf, reused);
@@ -211,5 +232,6 @@ public class TestBinary {
testConstantCopy(bf);
}
+ testSerializable(bf, reused);
}
}
|