Skip to content
Merged
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
2 changes: 2 additions & 0 deletions java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ public void nextVector(ColumnVector previousVector,
// Read present/isNull stream
super.nextVector(result, isNull, batchSize);

scratchlcv.ensureSize(batchSize, false);
BytesColumnVectorUtil.readOrcByteArrays(stream, lengths, scratchlcv, result, batchSize);
}

Expand Down Expand Up @@ -1365,6 +1366,7 @@ public void nextVector(ColumnVector previousVector,
// Read present/isNull stream
super.nextVector(result, isNull, batchSize);

scratchlcv.ensureSize(batchSize, false);
BytesColumnVectorUtil.readOrcByteArrays(stream, lengths, scratchlcv,
result, batchSize);
}
Expand Down
38 changes: 38 additions & 0 deletions java/core/src/test/org/apache/orc/TestVectorOrcFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

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;

Expand Down Expand Up @@ -2779,4 +2780,41 @@ public void testMaps() throws Exception {
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();
}
}