public Integer firstBatchSize() {
        if (buffer.remaining() < HEADER_SIZE_UP_TO_MAGIC)
            return null;
        return new ByteBufferLogInputStream(buffer, Integer.MAX_VALUE).nextBatchSize();
    }
Validates the header of the first batch and returns batch size.
@return first batch size including LOG_OVERHEAD if buffer contains header up to
        magic byte, null otherwise
@throws CorruptRecordException if record size or magic is invalid
clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java