public void overrideLastOffset(long lastOffset) {
        if (builtRecords != null)
            throw new IllegalStateException("Cannot override the last offset after the records have been built");
        this.lastOffset = lastOffset;
    }
Return the sum of the size of the batch header (always uncompressed) and the records (before compression).
clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java