2017-02-27 3 views
0

私はHBaseを読み込んでファイルにレコードを書き込むアプリケーションを持っています。 最終出力は、hadoopでサポートされていない形式の.zip圧縮形式である必要があります。 このため私はカスタムZipFileOutputFormatを使って.zipファイルにレコードを取得しています。ここでZip形式の出力を与えないZipFileOutputFormat mapreduce

は、これは私がR-000001の形式で任意のエラーが、それでも中に私の出力を得ていないのですZipFileOutputFormat.class

public class ZipFileOutputFormat extends FileOutputFormat<NullWritable, Text> { 
    @Override 
    public RecordWriter<NullWritable, Text> getRecordWriter(
      TaskAttemptContext job) throws IOException, InterruptedException { 
     Path file = getDefaultWorkFile(job, ".zip"); 

     FileSystem fs = file.getFileSystem(job.getConfiguration()); 

     return new ZipRecordWriter(fs.create(file, false)); 
    } 

    public static class ZipRecordWriter extends 
      RecordWriter<NullWritable, Text> { 
     protected ZipOutputStream zos; 

     public ZipRecordWriter(FSDataOutputStream os) { 
      zos = new ZipOutputStream(os); 
     } 

     @Override 
     public void write(NullWritable key, Text value) throws IOException, 
       InterruptedException { 
      // TODO: create new ZipEntry & add to the ZipOutputStream (zos) 
     } 

     @Override 
     public void close(TaskAttemptContext context) throws IOException, 
       InterruptedException { 
      zos.close(); 
     } 
    } 
} 

の詳細である私の実装

ZipFileOutputFormat.setOutputPath(job, new Path(args[1])); 

です。

ここに設定がありません。

答えて

0

私はこの問題を発見しました。ジョブで以下の設定した後 は、それが

LazyOutputFormat.setOutputFormatClass(job, TextInputFormat.class); 

はまた

job.setOutputFormatClass(ZipFileOutputFormat.class); 
を設定した前に私の問題は

LazyOutputFormat.setOutputFormatClass(job, ZipFileOutputFormat.class); 

を削除されていCONF