public long numMessages() {
        if (firstOffset >= 0 && lastOffset >= 0) {
            return lastOffset - firstOffset + 1;
        }
        return 0;
    }
Get the (maximum) number of messages described by LogAppendInfo

@return Maximum possible number of messages described by LogAppendInfo
storage/src/main/java/org/apache/kafka/storage/internals/log/LogAppendInfo.java