fail(crushOutMask);
}
Path crushOut = globStatus[0].getPath();
Reader reader = new Reader(getFileSystem(), crushOut, getFileSystem().getConf());
assertThat(reader.isBlockCompressed(), is(true));
assertThat(reader.getCompressionCodec().getClass(), equalTo((Object) codec.getClass()));
CustomWritable key = new CustomWritable();
CustomWritable value = new CustomWritable();
Set<String> expected = new HashSet<String>();
Set<String> actual = new HashSet<String>();
for (String fileName : fileNames) {
int max = Integer.parseInt(fileName.substring(4));
for (int k = 1, v = max * 100 + 1; k <= max; k++, v++) {
reader.next(key, value);
assertThat(expected.add(String.format("%s\t%s", k, v)), is(true));
assertThat(actual.add(String.format("%s\t%s", key, value)), is(true));
}
}
assertThat("Should be at end of crush output file " + crushOut, reader.next(key, value), is(false));
reader.close();
assertThat(actual, equalTo(expected));
} else if (Format.TEXT == inFmt && Format.SEQUENCE == outFmt) {
FileStatus[] globStatus = getFileSystem().globStatus(new Path(dir + "/" + crushOutMask));
if (globStatus == null || 1 != globStatus.length || globStatus[0].isDir()) {
fail(crushOutMask);
}
Path crushOut = globStatus[0].getPath();
Reader reader = new Reader(getFileSystem(), crushOut, getFileSystem().getConf());
assertThat(reader.isCompressed(), is(true));
assertThat(reader.isBlockCompressed(), is(true));
assertThat(reader.getCompressionCodec().getClass(), equalTo((Object) codec.getClass()));
Text key = new Text();
Text value = new Text();
Set<String> expected = new HashSet<String>();
Set<String> actual = new HashSet<String>();
for (String fileName : fileNames) {
int max = Integer.parseInt(fileName.substring(4));
for (int k = 1, v = max * 100 + 1; k <= max; k++, v++) {
reader.next(key, value);
assertThat(expected.add(String.format("%s\t%s", k, v)), is(true));
assertThat(actual.add(String.format("%s\t%s", key, value)), is(true));
}
}
assertThat("Should be at end of crush output file " + crushOut, reader.next(key, value), is(false));
reader.close();
assertThat(actual, equalTo(expected));
} else {
fail();