@@ -0,0 +1,2295 @@
+/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A==============================================================================*/%0A%0Apackage org.tensorflow.hadoop.io;%0A%0Aimport org.apache.hadoop.fs.FSDataOutputStream;%0Aimport org.apache.hadoop.fs.FileSystem;%0Aimport org.apache.hadoop.fs.Path;%0Aimport org.apache.hadoop.io.BytesWritable;%0Aimport org.apache.hadoop.io.NullWritable;%0Aimport org.apache.hadoop.io.Writable;%0Aimport org.apache.hadoop.mapred.FileOutputFormat;%0Aimport org.apache.hadoop.mapred.JobConf;%0Aimport org.apache.hadoop.mapred.RecordWriter;%0Aimport org.apache.hadoop.mapred.Reporter;%0Aimport org.apache.hadoop.util.Progressable;%0Aimport org.tensorflow.hadoop.util.TFRecordWriter;%0A%0Aimport java.io.IOException;%0A%0Apublic class TFRecordFileOutputFormatV1 extends FileOutputFormat%3CBytesWritable, Writable%3E %7B%0A  @Override%0A  public RecordWriter%3CBytesWritable, Writable%3E getRecordWriter(FileSystem ignored,%0A                                                               JobConf job, String name,%0A                                                               Progressable progress) throws IOException %7B%0A    Path file = FileOutputFormat.getTaskOutputPath(job, name);%0A    FileSystem fs = file.getFileSystem(job);%0A%0A    int bufferSize = TFRecordIOConf.getBufferSize(job);%0A    final FSDataOutputStream fsdos = fs.create(file, true, bufferSize);%0A    final TFRecordWriter writer = new TFRecordWriter(fsdos);%0A    return new RecordWriter%3CBytesWritable, Writable%3E() %7B%0A      @Override%0A      public void write(BytesWritable key, Writable value)%0A        throws IOException %7B%0A        writer.write(key.getBytes(), 0, key.getLength());%0A      %7D%0A%0A      @Override%0A      public void close(Reporter reporter)%0A        throws IOException %7B%0A        fsdos.close();%0A      %7D%0A    %7D;%0A  %7D%0A%0A%7D%0A

Add TFRecordFileOutputFormatV1 to support MRv1 (#58)