public boolean shouldRoll(RollParams rollParams) throws IOException {
        boolean reachedRollMs = timeWaitedForRoll(rollParams.now, rollParams.maxTimestampInMessages) > rollParams.maxSegmentMs - rollJitterMs;
        int size = size();
        return size > rollParams.maxSegmentBytes - rollParams.messagesSize ||
            (size > 0 && reachedRollMs) ||
            offsetIndex().isFull() || timeIndex().isFull() || !canConvertToRelativeOffset(rollParams.maxOffsetInMessages);
    }
Create a LogSegment with the provided parameters.

@param log The file records containing log entries
@param lazyOffsetIndex The offset index
@param lazyTimeIndex The timestamp index
@param txnIndex The transaction index
@param baseOffset A lower bound on the offsets in this segment
@param indexIntervalBytes The approximate number of bytes between entries in the index
@param rollJitterMs The maximum random jitter subtracted from the scheduled segment roll time
@param time The time instance
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java