parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexleven...@apache.org
Subject parquet-mr git commit: PARQUET-246: fix incomplete state reset in DeltaByteArrayWriter.reset()
Date Wed, 17 Jun 2015 16:17:32 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master 2e62764c0 -> 4590f14e9


PARQUET-246: fix incomplete state reset in DeltaByteArrayWriter.reset()

...thod

Author: Alex Levenson <alexlevenson@twitter.com>
Author: Konstantin Shaposhnikov <Konstantin.Shaposhnikov@sc.com>
Author: kostya-sh <kostya-sh@users.noreply.github.com>

Closes #171 from kostya-sh/PARQUET-246 and squashes the following commits:

75950c5 [kostya-sh] Merge pull request #1 from isnotinvain/PR-171
a718309 [Konstantin Shaposhnikov] Merge remote-tracking branch 'refs/remotes/origin/master'
into PARQUET-246
0367588 [Alex Levenson] Add regression test for PR-171
94e8fda [Alex Levenson] Merge branch 'master' into PR-171
0a9ac9f [Konstantin Shaposhnikov] [PARQUET-246] bugfix: reset all DeltaByteArrayWriter state
in reset() method


Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/4590f14e
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/4590f14e
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/4590f14e

Branch: refs/heads/master
Commit: 4590f14e97beb6d10ffb7b5dd312c632af155ed3
Parents: 2e62764
Author: Alex Levenson <alexlevenson@twitter.com>
Authored: Wed Jun 17 09:17:23 2015 -0700
Committer: Alex Levenson <alexlevenson@twitter.com>
Committed: Wed Jun 17 09:17:23 2015 -0700

----------------------------------------------------------------------
 .../deltastrings/DeltaByteArrayWriter.java      |  1 +
 .../values/deltastrings/TestDeltaByteArray.java | 39 ++++++++++++--------
 2 files changed, 25 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/4590f14e/parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java
b/parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java
index 8c71d5d..eb33d30 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java
@@ -66,6 +66,7 @@ public class DeltaByteArrayWriter extends ValuesWriter{
   public void reset() {
     prefixLengthWriter.reset();
     suffixWriter.reset();
+    previous = new byte[0];
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/4590f14e/parquet-column/src/test/java/org/apache/parquet/column/values/deltastrings/TestDeltaByteArray.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/test/java/org/apache/parquet/column/values/deltastrings/TestDeltaByteArray.java
b/parquet-column/src/test/java/org/apache/parquet/column/values/deltastrings/TestDeltaByteArray.java
index 693557a..b62ef84 100644
--- a/parquet-column/src/test/java/org/apache/parquet/column/values/deltastrings/TestDeltaByteArray.java
+++ b/parquet-column/src/test/java/org/apache/parquet/column/values/deltastrings/TestDeltaByteArray.java
@@ -34,29 +34,18 @@ public class TestDeltaByteArray {
   static String[] randvalues = Utils.getRandomStringSamples(10000, 32);
 
   @Test
-  public void testSerialization () throws IOException {
+  public void testSerialization () throws Exception {
     DeltaByteArrayWriter writer = new DeltaByteArrayWriter(64 * 1024, 64 * 1024);
     DeltaByteArrayReader reader = new DeltaByteArrayReader();
 
-    Utils.writeData(writer, values);
-    Binary[] bin = Utils.readData(reader, writer.getBytes().toByteArray(), values.length);
-
-    for(int i =0; i< bin.length ; i++) {
-      Assert.assertEquals(Binary.fromString(values[i]), bin[i]);
-    }
+    assertReadWrite(writer, reader, values);
   }
 
   @Test
-  public void testRandomStrings() throws IOException {
+  public void testRandomStrings() throws Exception {
     DeltaByteArrayWriter writer = new DeltaByteArrayWriter(64 * 1024, 64 * 1024);
     DeltaByteArrayReader reader = new DeltaByteArrayReader();
-
-    Utils.writeData(writer, randvalues);
-    Binary[] bin = Utils.readData(reader, writer.getBytes().toByteArray(), randvalues.length);
-
-    for(int i =0; i< bin.length ; i++) {
-      Assert.assertEquals(Binary.fromString(randvalues[i]), bin[i]);
-    }
+    assertReadWrite(writer, reader, randvalues);
   }
 
   @Test
@@ -81,4 +70,24 @@ public class TestDeltaByteArray {
     Assert.assertEquals(0, bin[1]);
     Assert.assertEquals(7, bin[2]);
   }
+
+  private void assertReadWrite(DeltaByteArrayWriter writer, DeltaByteArrayReader reader,
String[] vals) throws Exception {
+    Utils.writeData(writer, vals);
+    Binary[] bin = Utils.readData(reader, writer.getBytes().toByteArray(), vals.length);
+
+    for(int i = 0; i< bin.length ; i++) {
+      Assert.assertEquals(Binary.fromString(vals[i]), bin[i]);
+    }
+  }
+
+  @Test
+  public void testWriterReset() throws Exception {
+    DeltaByteArrayWriter writer = new DeltaByteArrayWriter(64 * 1024, 64 * 1024);
+
+    assertReadWrite(writer, new DeltaByteArrayReader(), values);
+
+    writer.reset();
+
+    assertReadWrite(writer, new DeltaByteArrayReader(), values);
+  }
 }


Mime
View raw message