Currently I use the following code to append to an existing SequenceFile:
// initialize sequence writer
Writer writer = SequenceFile.createWriter(
FileContext.getFileContext(this.conf),
this.conf,
new Path("/tmp/sequencefile"),
Text.class,
BytesWritable.class,
CompressionType.NONE,
null,
new Metadata(),
EnumSet.of(CreateFlag.CREATE, CreateFlag.APPEND),
CreateOpts.blockSize(64 * 1024 * 1024));
writer.append(key, value);
// close writer
writer.hsync();
writer.close();
Everything works if the sequencefile not exists, but when the file exists Hadoop write the SequenceFile header (SEQ ...) again in the middle of the file and the file is unreadble for Hadoop.
I use Hadoop 2.6.0