/** <code>setHeader</code> or <code>readHeaderFrom</code> must have been * called first. */ @Override public RecordWriter<K,VariantContextWritable> getRecordWriter( TaskAttemptContext ctx) throws IOException { Configuration conf = ctx.getConfiguration(); boolean isCompressed = getCompressOutput(ctx); CompressionCodec codec = null; String extension = ""; if (isCompressed) { Class<? extends CompressionCodec> codecClass = getOutputCompressorClass(ctx, BGZFCodec.class); codec = ReflectionUtils.newInstance(codecClass, conf); extension = codec.getDefaultExtension(); } Path file = getDefaultWorkFile(ctx, extension); if (!isCompressed) { return getRecordWriter(ctx, file); } else { FileSystem fs = file.getFileSystem(conf); return getRecordWriter(ctx, codec.createOutputStream(fs.create(file))); } }
@Before public void setup() throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { test_vcf_output = File.createTempFile("test_vcf_output", ""); test_vcf_output.delete(); writable = new VariantContextWritable(); Configuration conf = new Configuration(); conf.set("hadoopbam.vcf.output-format", "VCF"); KeyIgnoringVCFOutputFormat<Long> outputFormat = new KeyIgnoringVCFOutputFormat<Long>(conf); outputFormat.setHeader(readHeader()); taskAttemptContext = new TaskAttemptContextImpl(conf, mock(TaskAttemptID.class)); writer = outputFormat.getRecordWriter(taskAttemptContext, new Path("file://" + test_vcf_output)); }
@Override public RecordWriter<NullWritable, VariantContextWritable> getRecordWriter( TaskAttemptContext ctx) throws IOException { Path vcfPath = new Path(conf.get(READ_HEADER_FROM_FILE)); readHeaderFrom(vcfPath, vcfPath.getFileSystem(conf)); ctx.getConfiguration().setBoolean(WRITE_HEADER_PROPERTY, false); return super.getRecordWriter(ctx); } }
public void readHeaderFrom(Path path, FileSystem fs) throws IOException { SeekableStream i = WrapSeekable.openPath(fs, path); readHeaderFrom(i); i.close(); } public void readHeaderFrom(SeekableStream in) throws IOException {
@Override public RecordWriter<NullWritable, VariantContextWritable> getRecordWriter( TaskAttemptContext ctx) throws IOException { Path vcfPath = new Path(conf.get(READ_HEADER_FROM_FILE)); readHeaderFrom(vcfPath, vcfPath.getFileSystem(conf)); return super.getRecordWriter(ctx); } }
public void readHeaderFrom(Path path, FileSystem fs) throws IOException { SeekableStream i = WrapSeekable.openPath(fs, path); readHeaderFrom(i); i.close(); } public void readHeaderFrom(SeekableStream in) throws IOException {
/** <code>setHeader</code> or <code>readHeaderFrom</code> must have been * called first. */ @Override public RecordWriter<K,VariantContextWritable> getRecordWriter( TaskAttemptContext ctx) throws IOException { Configuration conf = ctx.getConfiguration(); boolean isCompressed = getCompressOutput(ctx); CompressionCodec codec = null; String extension = ""; if (isCompressed) { Class<? extends CompressionCodec> codecClass = getOutputCompressorClass(ctx, BGZFCodec.class); codec = ReflectionUtils.newInstance(codecClass, conf); extension = codec.getDefaultExtension(); } Path file = getDefaultWorkFile(ctx, extension); if (!isCompressed) { return getRecordWriter(ctx, file); } else { FileSystem fs = file.getFileSystem(conf); return getRecordWriter(ctx, codec.createOutputStream(fs.create(file))); } }
public void readHeaderFrom(Path path, FileSystem fs) throws IOException { SeekableStream i = WrapSeekable.openPath(fs, path); readHeaderFrom(i); i.close(); } public void readHeaderFrom(SeekableStream in) throws IOException {
/** <code>setHeader</code> or <code>readHeaderFrom</code> must have been * called first. */ @Override public RecordWriter<K,VariantContextWritable> getRecordWriter( TaskAttemptContext ctx) throws IOException { Configuration conf = ctx.getConfiguration(); boolean isCompressed = getCompressOutput(ctx); CompressionCodec codec = null; String extension = ""; if (isCompressed) { Class<? extends CompressionCodec> codecClass = getOutputCompressorClass(ctx, BGZFCodec.class); codec = ReflectionUtils.newInstance(codecClass, conf); extension = codec.getDefaultExtension(); } Path file = getDefaultWorkFile(ctx, extension); if (!isCompressed) { return getRecordWriter(ctx, file); } else { FileSystem fs = file.getFileSystem(conf); return getRecordWriter(ctx, codec.createOutputStream(fs.create(file))); } }