private int estimatedBytesWritten() {
        if (compression.type() == CompressionType.NONE) {
            return batchHeaderSizeInBytes + uncompressedRecordsSizeInBytes;
        } else {
            // estimate the written bytes to the underlying byte buffer based on uncompressed written bytes
            return batchHeaderSizeInBytes + (int) (uncompressedRecordsSizeInBytes * estimatedCompressionRatio * COMPRESSION_RATE_ESTIMATION_FACTOR);
        }
    }
Get an estimate of the number of bytes written (based on the estimation factor hard-coded in {@link CompressionType}).
@return The estimated number of bytes written
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java