private int binarySearchFileIndexByLogIndex(final long logIndex) {
        this.readLock.lock();
        try {
            if (this.segments.isEmpty()) {
                return -1;
            }
            if (this.segments.size() == 1) {
                final SegmentFile firstFile = this.segments.get(0);
                if (firstFile.contains(logIndex)) {
                    return 0;
                } else {
                    return -1;
                }
            }

            int low = 0;
            int high = this.segments.size() - 1;

            while (low <= high) {
                final int mid = (low + high) >>> 1;

                final SegmentFile file = this.segments.get(mid);
                if (file.getLastLogIndex() < logIndex) {
                    low = mid + 1;
                } else if (file.getFirstLogIndex() > logIndex) {
                    high = mid - 1;
                } else {
                    return mid;
                }
            }
            return -(low + 1);
        } finally {
            this.readLock.unlock();
        }
    }
Encode segment file firstLogIndex(fileName) and position to a byte array in the format of:
<ul>
 <li> magic bytes(2 B)</li>
 <li> reserved (2 B)</li>
 <li> firstLogIndex(8 B)</li>
 <li> wrote position(4 B)</li>
</ul>
@param firstLogIndex the first log index
@param pos           the wrote position
@return segment info
jraft-core/src/main/java/com/alipay/sofa/jraft/storage/log/RocksDBSegmentLogStorage.java