public AbstractFile findFileByLogIndex(final long logIndex, final boolean returnFirstIfNotFound) {
        this.readLock.lock();
        try {
            if (this.files.isEmpty()) {
                return null;
            }
            if (this.files.size() == 1) {
                return getFirstFile();
            }
            int lo = 0, hi = this.files.size() - 1;
            while (lo <= hi) {
                final int mid = (lo + hi) >>> 1;
                final AbstractFile file = this.files.get(mid);
                if (file.getLastLogIndex() < logIndex) {
                    lo = mid + 1;
                } else if (file.getFirstLogIndex() > logIndex) {
                    hi = mid - 1;
                } else {
                    return this.files.get(mid);
                }
            }
            if (returnFirstIfNotFound) {
                return getFirstFile();
            }
        } finally {
            this.readLock.unlock();
        }
        return null;
    }
@return the file that contains this logIndex
jraft-extension/java-log-storage-impl/src/main/java/com/alipay/sofa/jraft/storage/file/FileManager.java