ParquetFileFormat<MockSimple> format = format(MockSimple.class);
LocalFileSystem fs = FileSystem.getLocal(format.getConf());
ModelOutput<MockSimple> output = format.createOutput(
MockSimple.class,
fs, new Path(file.toURI()),
new Counter());
try {
output.write(new MockSimple(100, "Hello, world!"));
} finally {
output.close();
}
assertThat(file.exists(), is(true));
FileStatus stat = fs.getFileStatus(new Path(file.toURI()));
List<DirectInputFragment> fragments = format.computeInputFragments(new StripedDataFormat.InputContext(
MockSimple.class,
Arrays.asList(stat), fs,
-1L, -1L,
false, false));
assertThat(fragments, hasSize(1));
DirectInputFragment first = fragments.get(0);
ModelInput<MockSimple> input = format.createInput(
MockSimple.class,
fs, new Path(first.getPath()),
first.getOffset(), first.getSize(),
new Counter());
try {
MockSimple buf = new MockSimple();
assertThat(input.readTo(buf), is(true));
assertThat(buf.number, is(new IntOption(100)));
assertThat(buf.string, is(new StringOption("Hello, world!")));