All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codelibs.elasticsearch.idxproxy.stream.IndexingProxyStreamOutput Maven / Gradle / Ivy

There is a newer version: 5.6.5
Show newest version
package org.codelibs.elasticsearch.idxproxy.stream;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.apache.commons.io.output.CountingOutputStream;
import org.elasticsearch.common.io.stream.StreamOutput;

public class IndexingProxyStreamOutput extends StreamOutput {
    private final CountingOutputStream out;

    public IndexingProxyStreamOutput(final OutputStream out) {
        this.out = new CountingOutputStream(new BufferedOutputStream(out));
    }

    @Override
    public void writeByte(final byte b) throws IOException {
        out.write(b);
    }

    @Override
    public void writeBytes(final byte[] b, final int offset, final int length) throws IOException {
        out.write(b, offset, length);
    }

    @Override
    public void flush() throws IOException {
        out.flush();
    }

    @Override
    public void close() throws IOException {
        out.close();
    }

    @Override
    public void reset() throws IOException {
        throw new UnsupportedOperationException();
    }

    public long getByteCount() {
        return out.getByteCount();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy