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

com.clickhouse.data.stream.DeferredOutputStream Maven / Gradle / Ivy

There is a newer version: 0.7.1-patch1
Show newest version
package com.clickhouse.data.stream;

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

import com.clickhouse.data.ClickHouseDeferredValue;

public final class DeferredOutputStream extends OutputStream {
    private final ClickHouseDeferredValue ref;
    private OutputStream out;

    protected OutputStream getOutput() {
        return out != null ? out : (out = ref.get());
    }

    public DeferredOutputStream(ClickHouseDeferredValue out) {
        this.ref = out;
        this.out = null;
    }

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

    @Override
    public void write(int b) throws IOException {
        getOutput().write(b);
    }

    @Override
    public void write(byte[] b, int off, int len) throws IOException {
        getOutput().write(b, off, len);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy