}
@Test public void testAlternateModel() throws Exception {
LOG.debug("Writing some reflect records...");
ReflectData model = ReflectData.get();
Configuration conf = new Configuration();
SortedKeyValueFile.Writer.Options options
= new SortedKeyValueFile.Writer.Options()
.withKeySchema(model.getSchema(Stringy.class))
.withValueSchema(model.getSchema(Stringy.class))
.withConfiguration(conf)
.withPath(new Path(mTempDir.getRoot().getPath(), "reflect"))
.withDataModel(model)
.withIndexInterval(2);
SortedKeyValueFile.Writer<Stringy,Stringy> writer
= new SortedKeyValueFile.Writer<Stringy,Stringy>(options);
try {
writer.append(new Stringy("apple"), new Stringy("Apple"));
writer.append(new Stringy("banana"), new Stringy("Banana"));
writer.append(new Stringy("carrot"), new Stringy("Carrot"));
writer.append(new Stringy("durian"), new Stringy("Durian"));
} finally {
writer.close();
}
LOG.debug("Reading the file back using a reader...");
SortedKeyValueFile.Reader.Options readerOptions =
new SortedKeyValueFile.Reader.Options()
.withKeySchema(model.getSchema(Stringy.class))
.withValueSchema(model.getSchema(Stringy.class))
.withConfiguration(conf)
.withPath(new Path(mTempDir.getRoot().getPath(), "reflect"))
.withDataModel(model);
SortedKeyValueFile.Reader<Stringy,Stringy> reader