@Override
  public synchronized Result next() throws IOException {
    while (queue.isEmpty()) {
      if (closed) {
        return null;
      }
      if (error != null) {
        throw FutureUtils.rethrow(error);
      }
      try {
        wait();
      } catch (InterruptedException e) {
        throw new InterruptedIOException();
      }
    }
    Result result = queue.poll();
    if (!result.isCursor()) {
      cacheSize -= calcEstimatedSize(result);
      if (resumer != null && cacheSize <= maxCacheSize / 2) {
        resumePrefetch();
      }
    }
    return result;
  }
The {@link ResultScanner} implementation for {@link RawAsyncTableImpl}. It will fetch data
automatically in background and cache it in memory. Typically, the {@link #maxCacheSize} will be
{@code 2 * scan.getMaxResultSize()}.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableResultScanner.java