You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2016/07/01 18:05:41 UTC

orc git commit: ORC-73. Fix the vector expansion.

Repository: orc
Updated Branches:
  refs/heads/master 15da55edf -> 0e72b6626


ORC-73. Fix the vector expansion.

Fixes #74.

Signed-off-by: Owen O'Malley <om...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/0e72b662
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/0e72b662
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/0e72b662

Branch: refs/heads/master
Commit: 0e72b662653c5d4b978759f605342393e43ed61a
Parents: 15da55e
Author: Owen O'Malley <om...@apache.org>
Authored: Wed Jun 29 12:36:37 2016 -0700
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri Jul 1 11:04:50 2016 -0700

----------------------------------------------------------------------
 .../org/apache/orc/impl/TreeReaderFactory.java  |  2 ++
 .../test/org/apache/orc/TestVectorOrcFile.java  | 38 ++++++++++++++++++++
 2 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/0e72b662/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java b/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
index c4a2093..bbba932 100644
--- a/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
+++ b/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
@@ -794,6 +794,7 @@ public class TreeReaderFactory {
       // Read present/isNull stream
       super.nextVector(result, isNull, batchSize);
 
+      scratchlcv.ensureSize(batchSize, false);
       BytesColumnVectorUtil.readOrcByteArrays(stream, lengths, scratchlcv, result, batchSize);
     }
 
@@ -1365,6 +1366,7 @@ public class TreeReaderFactory {
       // Read present/isNull stream
       super.nextVector(result, isNull, batchSize);
 
+      scratchlcv.ensureSize(batchSize, false);
       BytesColumnVectorUtil.readOrcByteArrays(stream, lengths, scratchlcv,
           result, batchSize);
     }

http://git-wip-us.apache.org/repos/asf/orc/blob/0e72b662/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
index 112edb9..6dcef20 100644
--- a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
+++ b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
@@ -69,6 +69,7 @@ import java.util.Random;
 
 import static junit.framework.TestCase.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
@@ -2779,4 +2780,41 @@ public class TestVectorOrcFile {
     rows.nextBatch(batch);
     assertEquals(0, batch.size);
   }
+
+  @Test
+  public void testExpansion() throws Exception {
+    TypeDescription schema =
+        TypeDescription.fromString(
+            "struct<list1:array<string>," +
+                    "list2:array<binary>>");
+    Writer writer = OrcFile.createWriter(testFilePath,
+        OrcFile.writerOptions(conf).setSchema(schema));
+    VectorizedRowBatch batch = schema.createRowBatch();
+    batch.size = 2;
+    ListColumnVector list1 = (ListColumnVector) batch.cols[0];
+    BytesColumnVector str = (BytesColumnVector) list1.child;
+    str.ensureSize(6000, false);
+    ListColumnVector list2 = (ListColumnVector) batch.cols[1];
+    BytesColumnVector bin = (BytesColumnVector) list2.child;
+    bin.ensureSize(6000, false);
+    list1.offsets[0] = 0;
+    list1.lengths[0] = 2000;
+    list2.offsets[1] = 2000;
+    list2.lengths[1] = 3000;
+    for(int v=0; v < 5000; ++v) {
+      byte[] bytes = Long.toHexString(v).getBytes();
+      str.setVal(v, bytes);
+      bin.setVal(v, bytes);
+    }
+    writer.addRowBatch(batch);
+    writer.close();
+    Reader reader = OrcFile.createReader(testFilePath,
+        OrcFile.readerOptions(conf));
+    RecordReader rows = reader.rows();
+    batch = reader.getSchema().createRowBatch();
+    assertTrue(rows.nextBatch(batch));
+    assertEquals(2, batch.size);
+    assertFalse(rows.nextBatch(batch));
+    rows.close();
+  }
 }