public void sanityCheck(boolean timeIndexFileNewlyCreated) throws IOException {
        if (offsetIndexFile().exists()) {
            // Resize the time index file to 0 if it is newly created.
            if (timeIndexFileNewlyCreated)
              timeIndex().resize(0);
            // Sanity checks for time index and offset index are skipped because
            // we will recover the segments above the recovery point in recoverLog()
            // in any case so sanity checking them here is redundant.
            txnIndex.sanityCheck();
        } else
            throw new NoSuchFileException("Offset index file " + offsetIndexFile().getAbsolutePath() + " does not exist");
    }
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