public static boolean writeValuePreamble(OutputStream out, boolean defaultsSupport, Object value, boolean isNullable, ClickHouseDataType dataType, boolean hasDefault, String column) throws IOException {
        if (defaultsSupport) {
            if (value != null) {//Because we now support defaults, we have to send nonNull
                SerializerUtils.writeNonNull(out);//Write 0 for no default

                if (isNullable) {//If the column is nullable
                    SerializerUtils.writeNonNull(out);//Write 0 for not null
                }
            } else {//So if the object is null
                if (hasDefault) {
                    SerializerUtils.writeNull(out);//Send 1 for default
                    return false;
                } else if (isNullable) {//And the column is nullable
                    SerializerUtils.writeNonNull(out);
                    SerializerUtils.writeNull(out);//Then we send null, write 1
                    return false;//And we're done
                } else if (dataType == ClickHouseDataType.Array) {//If the column is an array
                    SerializerUtils.writeNonNull(out);//Then we send nonNull
                } else if (dataType == ClickHouseDataType.Dynamic) {
                    // do nothing
                } else {
                    throw new IllegalArgumentException(String.format("An attempt to write null into not nullable column '%s'", column));
                }
            }
        } else {
            if (isNullable) {
                if (value == null) {
                    SerializerUtils.writeNull(out);
                    return false;
                }
                SerializerUtils.writeNonNull(out);
            } else if (value == null) {
                if (dataType == ClickHouseDataType.Array) {
                    SerializerUtils.writeNonNull(out);
                } else if (dataType == ClickHouseDataType.Dynamic) {
                    // do nothing
                } else {
                    throw new IllegalArgumentException(String.format("An attempt to write null into not nullable column '%s'", column));
                }
            }
        }

        return true;
    }
This class is intended to be used for very precise data serializations.
It is an auxiliary class to handle only low level write operations.
<p>
Experimental API
client-v2/src/main/java/com/clickhouse/client/api/data_formats/RowBinaryFormatSerializer.java