new Path(TMP_FILENAME1), IntWritable.class, ArrayListOfFloatsWritable.class);
SequenceFile.Writer writer2 = SequenceFile.createWriter(fs, conf,
new Path(TMP_FILENAME2), IntWritable.class, FloatAsBytesWritable.class);
ArrayListOfFloatsWritable a1 = WriteRandomVectors.generateUnitRandomVector(100);
FloatAsBytesWritable a2 = WriteRandomVectors.generateUnitRandomVectorAsBytes(100);
writer1.append(new IntWritable(1), a1);
writer1.close();
writer2.append(new IntWritable(1), a2);
writer2.close();
List<PairOfWritables<WritableComparable, Writable>> listOfKeysPairs1 =
SequenceFileUtils.readFile(new Path(TMP_FILENAME1));
fs.delete(new Path(TMP_FILENAME1), true);
List<PairOfWritables<WritableComparable, Writable>> listOfKeysPairs2 =
SequenceFileUtils.readFile(new Path(TMP_FILENAME2));
fs.delete(new Path(TMP_FILENAME2), true);
FloatAsBytesWritable b2 = (FloatAsBytesWritable) listOfKeysPairs2.get(0).getRightElement();
ArrayListOfFloatsWritable b1 = (ArrayListOfFloatsWritable) listOfKeysPairs1.get(0)
.getRightElement();
for (int i = 0; i < 100; i++) {
float f = b1.get(i);
float g = a1.get(i);
assertTrue(f == g);
}
for (int i = 0; i < 100; i++) {
float f2 = b2.getAsFloat(i);
float g2 = a2.getAsFloat(i);
assertTrue(f2 == g2);
}
}