pigServer.store("A", OUTPUT1, "OrcStorage");
Path outputFilePath = new Path(new Path(OUTPUT1), "part-m-00000");
Reader reader = OrcFile.createReader(fs, outputFilePath);
assertEquals(reader.getNumberOfRows(), 2);
RecordReader rows = reader.rows(null);
Object row = rows.next(null);
StructObjectInspector soi = (StructObjectInspector)reader.getObjectInspector();
IntWritable intWritable = (IntWritable)soi.getStructFieldData(row,
soi.getAllStructFieldRefs().get(0));
Text text = (Text)soi.getStructFieldData(row,
soi.getAllStructFieldRefs().get(1));
assertEquals(intWritable.get(), 65536);
assertEquals(text.toString(), "world");
row = rows.next(null);
intWritable = (IntWritable)soi.getStructFieldData(row,
soi.getAllStructFieldRefs().get(0));
text = (Text)soi.getStructFieldData(row,
soi.getAllStructFieldRefs().get(1));
assertEquals(intWritable.get(), 1);
assertEquals(text.toString(), "hello");
// A bug in ORC InputFormat does not allow empty file in input directory
fs.delete(new Path(OUTPUT1, "_SUCCESS"), true);
// Read the output file back
pigServer.registerQuery("A = load '" + OUTPUT1 + "' using OrcStorage();");
Schema s = pigServer.dumpSchema("A");
assertEquals(s.toString(), "{a0: int,a1: chararray}");
Iterator<Tuple> iter = pigServer.openIterator("A");
Tuple t = iter.next();
assertEquals(t.size(), 2);
assertEquals(t.get(0), 65536);
assertEquals(t.get(1), "world");
t = iter.next();
assertEquals(t.size(), 2);
assertEquals(t.get(0), 1);
assertEquals(t.get(1), "hello");
assertFalse(iter.hasNext());
rows.close();
}