} finally {
writer.close();
}
long fileLen = fs.getFileStatus(path).getLen();
StringOption value = new StringOption();
for (int attempt = 0; attempt < 5; attempt++) {
int index = 0;
long offset = 0;
while (offset < fileLen) {
long length = SequenceFile.SYNC_INTERVAL * (rand.nextInt(10) + 2);
length = Math.min(length, fileLen - offset);
ModelInput<StringOption> in = format.createInput(
StringOption.class,
fs,
path,
offset,
length,
new Counter());
try {
while (in.readTo(value)) {
String answer = "Hello, world at " + index;
assertThat(value.getAsString(), is(answer));
index++;
}
assertThat("eof", in.readTo(value), is(false));
} finally {
in.close();