private FutureGroup<List<KVEntry>> internalScan(final byte[] startKey, final byte[] endKey,
                                                    final boolean readOnlySafe, final boolean returnValue,
                                                    final int retriesLeft, final Throwable lastCause) {
        Requires.requireNonNull(startKey, "startKey");
        final List<Region> regionList = this.pdClient.findRegionsByKeyRange(startKey, endKey, ApiExceptionHelper.isInvalidEpoch(lastCause));
        final List<CompletableFuture<List<KVEntry>>> futures = Lists.newArrayListWithCapacity(regionList.size());
        final Errors lastError = lastCause == null ? null : Errors.forException(lastCause);
        for (final Region region : regionList) {
            final byte[] regionStartKey = region.getStartKey();
            final byte[] regionEndKey = region.getEndKey();
            final byte[] subStartKey = regionStartKey == null ? startKey : BytesUtil.max(regionStartKey, startKey);
            final byte[] subEndKey = regionEndKey == null ? endKey :
                    (endKey == null ? regionEndKey : BytesUtil.min(regionEndKey, endKey));
            final ListRetryCallable<KVEntry> retryCallable = retryCause -> internalScan(subStartKey, subEndKey,
                    readOnlySafe, returnValue, retriesLeft - 1, retryCause);
            final ListFailoverFuture<KVEntry> future = new ListFailoverFuture<>(retriesLeft, retryCallable);
            internalRegionScan(region, subStartKey, subEndKey, false, readOnlySafe, returnValue, future, retriesLeft,
                    lastError, this.onlyLeaderRead);
            futures.add(future);
        }
        return new FutureGroup<>(futures);
    }
Returns a heap-allocated iterator over the contents of the
database.
<p>
Caller should close the iterator when it is no longer needed.
The returned iterator should be closed before this db is closed.
<p>
<pre>
    KVIterator it = unsafeLocalIterator();
    try {
        // do something
    } finally {
        it.close();
    }
<pre/>
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java