@@ -0,0 +1,2993 @@
+package org.opencb.hpg.bigdata.core.io;%0A%0A%0Aimport org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;%0Aimport org.apache.commons.lang3.NotImplementedException;%0Aimport org.apache.commons.lang3.StringUtils;%0Aimport org.opencb.commons.io.DataWriter;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.*;%0Aimport java.nio.file.Path;%0Aimport java.util.List;%0Aimport java.util.concurrent.atomic.AtomicLong;%0A%0A/**%0A * Created by mh719 on 11/05/2016.%0A */%0Apublic class ProtoFileWriter%3CT extends com.google.protobuf.GeneratedMessage%3E implements DataWriter%3CT%3E %7B%0A    private String compression = StringUtils.EMPTY;%0A    protected Logger logger = LoggerFactory.getLogger(this.getClass().toString());%0A%0A    private OutputStream outputStream = null;%0A    private Path input = null;%0A    private final AtomicLong timeWrite = new AtomicLong(0);%0A%0A    public ProtoFileWriter(OutputStream outputStream) %7B%0A        this.outputStream = outputStream;%0A    %7D%0A%0A    public ProtoFileWriter(Path input) %7B%0A        this.input = input;%0A    %7D%0A%0A    public ProtoFileWriter(Path input, String compression) %7B%0A        this(input);%0A        this.compression = compression;%0A    %7D%0A%0A    @Override%0A    public boolean open() %7B%0A        if (null != this.input) %7B%0A            try %7B%0A                OutputStream out = new BufferedOutputStream(new FileOutputStream(input.toFile()));%0A                if (StringUtils.equalsIgnoreCase(compression, %22gzip%22) %7C%7C StringUtils.equalsIgnoreCase(compression, %22gz%22)) %7B%0A                    out = new GzipCompressorOutputStream(out);%0A                %7D else if (StringUtils.isNotBlank(compression)) %7B%0A                    throw new NotImplementedException(%22Proto compression not implemented yet: %22 + compression);%0A                %7D%0A                outputStream = out;%0A            %7D catch (IOException e) %7B%0A                throw new RuntimeException(e);%0A            %7D%0A        %7D%0A%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean close() %7B%0A        try %7B%0A            this.outputStream.flush();%0A        %7D catch (IOException e) %7B%0A            logger.error(%22Problems flushing outputstream%22, e);%0A            return false;%0A        %7D%0A        if (null != this.input) %7B%0A            try %7B%0A                this.outputStream.close();%0A            %7D catch (IOException e) %7B%0A                logger.error(%22Problems closing outputstream%22, e);%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean pre() %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public boolean post() %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public boolean write(T elem) %7B%0A        try %7B%0A            elem.writeDelimitedTo(this.outputStream);%0A        %7D catch (IOException e) %7B%0A            throw new IllegalStateException(%22Problems writing Proto element ot output stream!!! %22 + elem, e);%0A        %7D%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean write(List%3CT%3E batch) %7B%0A        batch.forEach(e -%3E write(e));%0A        return true;%0A    %7D%0A%7D%0A

add generic Proto file writer