public int truncateToSlot(final int slot) {
        this.writeLock.lock();
        try {
            this.header.setLastLogIndex(this.header.getFirstLogIndex() + slot - 1);
            final int lastPos = this.header.getHeaderSize() + slot * getIndexSize();
            updateAllPosition(lastPos);
            clear(getWrotePosition());
            return lastPos;
        } finally {
            this.writeLock.unlock();
        }
    }
Truncate to a known number of slot.
jraft-extension/java-log-storage-impl/src/main/java/com/alipay/sofa/jraft/storage/file/index/IndexFile.java