public static ClickHouseOutputStream of(OutputStream output, int bufferSize, ClickHouseCompression compression,
            int level, Runnable postCloseAction) {
        final ClickHouseOutputStream chOutput;
        if (output == null) {
            chOutput = EmptyOutputStream.INSTANCE;
        } else if (compression == null || compression == ClickHouseCompression.NONE) {
            chOutput = output != EmptyOutputStream.INSTANCE && output instanceof ClickHouseOutputStream
                    ? (ClickHouseOutputStream) output
                    : new WrappedOutputStream(null, output, bufferSize, postCloseAction);
        } else {
            chOutput = wrap(null, output, bufferSize, compression, level, postCloseAction);
        }
        return chOutput;
    }
Wraps the given output stream.

@param output          output stream
@param bufferSize      buffer size which is always greater than zero(usually
                       4096 or larger)
@param compression     compression algorithm, null or
                       {@link ClickHouseCompression#NONE} means no
                       compression
@param level           compression level
@param postCloseAction custom action will be performed right after closing
                       the output stream
@return wrapped output, or the same output if it's instance of
        {@link ClickHouseOutputStream}
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseOutputStream.java