Configuration conf = new Configuration();
Path path = new Path(ROOT, name);
FileSystem fs = path.getFileSystem(conf);
FSDataOutputStream out = fs.create(path);
try {
TFile.Writer writer = new Writer(out, BLOCK_SIZE, "gz",
jClassLongWritableComparator, conf);
try {
LongWritable key = new LongWritable(0);
for (long i=0; i<NENTRY; ++i) {
key.set(cube(i-NENTRY/2));
DataOutputStream dos = writer.prepareAppendKey(-1);
try {
key.write(dos);
} finally {
dos.close();
}
dos = writer.prepareAppendValue(-1);
try {
dos.write(buildValue(i).getBytes());
} finally {
dos.close();
}
}
} finally {
writer.close();
}
} finally {
out.close();
}