ReaderWriterProfiler.setProfilerOptions(conf);
Writer writer = OrcFile.createWriter(fs, testFilePath, conf, inspector,
5000, CompressionKind.SNAPPY, 1000, 0);
Random rand = new Random(24);
for(int i=0; i < 10000; ++i) {
InnerStruct row = new InnerStruct(rand.nextInt(),
Integer.toBinaryString(rand.nextInt()));
for(int j=0; j< 5; ++j) {
writer.addRow(row);
}
}
writer.close();
ReaderWriterProfiler.setProfilerOptions(conf);
Reader reader = OrcFile.createReader(fs, testFilePath, conf);
assertEquals(50000, reader.getNumberOfRows());
assertEquals(0, reader.getRowIndexStride());
StripeInformation stripe = reader.getStripes().iterator().next();
assertEquals(true, stripe.getDataLength() != 0);
assertEquals(0, stripe.getIndexLength());
RecordReader rows = reader.rows(null);
rand = new Random(24);
OrcLazyStruct lazyRow = null;
OrcStruct row = null;
for(int i=0; i < 10000; ++i) {
int intVal = rand.nextInt();
String strVal = Integer.toBinaryString(rand.nextInt());
for(int j=0; j < 5; ++j) {
assertEquals(true, rows.hasNext());
lazyRow = (OrcLazyStruct) rows.next(lazyRow);
row = (OrcStruct) lazyRow.materialize();
assertEquals(intVal, ((IntWritable) ((OrcLazyInt) row.getFieldValue(0)).materialize()).get());
assertEquals(strVal, ((OrcLazyString) row.getFieldValue(1)).materialize().toString());
}
}
assertEquals(false, rows.hasNext());
rows.close();
}