private void addToCache(Result result) { queue.add(result); cacheSize += calcEstimatedSize(result); }
private Result pollCache() { Result res = cache.poll(); long estimatedSize = calcEstimatedSize(res); addEstimatedSize(-estimatedSize); return res; }
@Override public synchronized Result next() throws IOException { while (queue.isEmpty()) { if (closed) { return null; } if (error != null) { Throwables.propagateIfPossible(error, IOException.class); throw new IOException(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; }
for (Result rs : resultsToAddToCache) { cache.add(rs); long estimatedHeapSizeOfResult = calcEstimatedSize(rs); countdown--; remainingResultSize -= estimatedHeapSizeOfResult;
private void addToCache(Result result) { queue.add(result); cacheSize += calcEstimatedSize(result); }
private Result pollCache() { Result res = cache.poll(); long estimatedSize = calcEstimatedSize(res); addEstimatedSize(-estimatedSize); return res; }
@Override public synchronized Result next() throws IOException { while (queue.isEmpty()) { if (closed) { return null; } if (error != null) { Throwables.propagateIfPossible(error, IOException.class); throw new IOException(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; }
private void addToCache(Result result) { queue.add(result); cacheSize += calcEstimatedSize(result); }
for (Result rs : resultsToAddToCache) { cache.add(rs); long estimatedHeapSizeOfResult = calcEstimatedSize(rs); countdown--; remainingResultSize -= estimatedHeapSizeOfResult;
private Result pollCache() { Result res = cache.poll(); long estimatedSize = calcEstimatedSize(res); addEstimatedSize(-estimatedSize); return res; }
@Override public synchronized Result next() throws IOException { while (queue.isEmpty()) { if (closed) { return null; } if (error != null) { Throwables.propagateIfPossible(error, IOException.class); throw new IOException(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; }
for (Result rs : resultsToAddToCache) { cache.add(rs); long estimatedHeapSizeOfResult = calcEstimatedSize(rs); countdown--; remainingResultSize -= estimatedHeapSizeOfResult;