}
}
@Test
public void testReadWrite() throws IOException {
MinhashSignature s = getRandomSignature();
MinhashSignature s2 = getRandomSignature();
FileSystem fs;
SequenceFile.Writer w;
Configuration conf = new Configuration();
try {
fs = FileSystem.get(conf);
w = SequenceFile.createWriter(fs, conf, new Path(TMP_FILENAME1),
IntWritable.class, MinhashSignature.class);
w.append(new IntWritable(1), s);
w.append(new IntWritable(2), s2);
w.close();
} catch (IOException e) {
e.printStackTrace();
}
List<PairOfWritables<WritableComparable<IntWritable>, Writable>> listOfKeysPairs =
SequenceFileUtils.readFile(new Path(TMP_FILENAME1));
FileSystem.get(conf).delete(new Path(TMP_FILENAME1), true);
MinhashSignature read1 = (MinhashSignature) listOfKeysPairs.get(0).getRightElement();
MinhashSignature read2 = (MinhashSignature) listOfKeysPairs.get(1).getRightElement();
assertTrue(read1.toString().equals(s.toString()));
assertTrue(read2.toString().equals(s2.toString()));
System.out.println(read1.toString());
System.out.println(read2.toString());
}