assertEquals(reader.getContentLength(), currentOffset);
RecordReader rows = reader.rows(null);
assertEquals(0, rows.getRowNumber());
assertEquals(0.0, rows.getProgress(), 0.000001);
assertEquals(true, rows.hasNext());
OrcLazyStruct lazyRow = (OrcLazyStruct) rows.next(null);
row = (OrcStruct) lazyRow.materialize();
inspector = reader.getObjectInspector();
assertEquals("struct<time:timestamp,union:uniontype<int,string>>",
inspector.getTypeName());
assertEquals(Timestamp.valueOf("2000-03-12 15:00:00"),
((TimestampWritable) ((OrcLazyTimestamp) row.getFieldValue(0)).materialize()).getTimestamp());
union = (OrcUnion) ((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(0, union.getTag());
assertEquals(new IntWritable(42), union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(Timestamp.valueOf("2000-03-20 12:00:00.123456789"),
((TimestampWritable) ((OrcLazyTimestamp) row.getFieldValue(0)).materialize()).getTimestamp());
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(1, union.getTag());
assertEquals(new Text("hello"), union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(null, ((OrcLazyObject) row.getFieldValue(0)).materialize());
assertEquals(null, ((OrcLazyObject) row.getFieldValue(1)).materialize());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(null, ((OrcLazyObject) row.getFieldValue(0)).materialize());
union = (OrcUnion) ((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(0, union.getTag());
assertEquals(null, union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(null, ((OrcLazyObject) row.getFieldValue(0)).materialize());
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(1, union.getTag());
assertEquals(null, union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(Timestamp.valueOf("1900-01-01 00:00:00"),
((TimestampWritable) ((OrcLazyTimestamp) row.getFieldValue(0)).materialize()).getTimestamp());
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(new IntWritable(200000), union.getObject());
for(int i=1900; i < 2200; ++i) {
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(Timestamp.valueOf(i + "-05-05 12:34:56." + i),
((TimestampWritable) ((OrcLazyTimestamp) row.getFieldValue(0)).materialize()).getTimestamp());
((OrcLazyUnion) row.getFieldValue(1)).materialize();
if ((i & 1) == 0) {
assertEquals(0, union.getTag());
assertEquals(new IntWritable(i*i), union.getObject());
} else {
assertEquals(1, union.getTag());
assertEquals(new Text(new Integer(i*i).toString()), union.getObject());
}
}
for(int i=0; i < 5000; ++i) {
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(new IntWritable(1732050807), union.getObject());
}
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(new IntWritable(0), union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(new IntWritable(10), union.getObject());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
((OrcLazyUnion) row.getFieldValue(1)).materialize();
assertEquals(new IntWritable(138), union.getObject());
assertEquals(false, rows.hasNext());
assertEquals(1.0, rows.getProgress(), 0.00001);
assertEquals(reader.getNumberOfRows(), rows.getRowNumber());