public static ResultIterator newIterator(final List<PeekingResultIterator> iterators, QueryPlan plan) { if (iterators.isEmpty()) { return EMPTY_ITERATOR; } if (iterators.size() == 1) { return iterators.get(0); } return new RoundRobinResultIterator(iterators, plan); }
@Override public Tuple next() throws SQLException { List<RoundRobinIterator> iterators; int size; while ((size = (iterators = getIterators()).size()) > 0) { index = index % size; RoundRobinIterator itr = iterators.get(index); if (itr.getNumRecordsRead() < threshold) { Tuple tuple; if ((tuple = itr.peek()) != null) { tuple = itr.next(); if (itr.getNumRecordsRead() == threshold) { numScannersCacheExhausted++; } index = (index + 1) % size; return tuple; } else { // The underlying scanner is exhausted. Close the iterator and un-track it. itr.close(); iterators.remove(index); if (iterators.size() == 0) { close(); } } } else { index = (index + 1) % size; } } return null; }
private List<RoundRobinIterator> getIterators() throws SQLException { if (closed) { return Collections.emptyList(); } if (openIterators.size() > 0 && openIterators.size() == numScannersCacheExhausted) { /* * All the scanners have exhausted their cache. Submit the scanners back to the pool so that they can fetch * the next batch of records in parallel. */ initOpenIterators(fetchNextBatch()); } else if (openIterators.size() == 0 && resultIterators != null) { List<PeekingResultIterator> iterators = resultIterators.getIterators(); initOpenIterators(wrapToRoundRobinIterators(iterators)); } return openIterators; }
public RoundRobinResultIterator(List<PeekingResultIterator> iterators, QueryPlan plan) { this.resultIterators = null; this.plan = plan; this.threshold = getThreshold(); initOpenIterators(wrapToRoundRobinIterators(iterators)); }
? RoundRobinResultIterator.newIterator(iterators, queryPlan) : ConcatResultIterator.newIterator(iterators); if (queryPlan.getContext().getSequenceManager().getSequenceCount() > 0) {
public RoundRobinResultIterator(ResultIterators iterators, QueryPlan plan) { this.resultIterators = iterators; this.plan = plan; this.threshold = getThreshold(); }
private int getThreshold() { int cacheSize = getScannerCacheSize(); checkArgument(cacheSize > 1, "RoundRobinResultIterator doesn't work when cache size is less than or equal to 1"); return cacheSize - 1; }
if (!success) { try { close(); } catch (Exception e) { if (toThrow == null) {
public RoundRobinResultIterator(List<PeekingResultIterator> iterators, QueryPlan plan) { this.resultIterators = null; this.plan = plan; this.threshold = getThreshold(); initOpenIterators(wrapToRoundRobinIterators(iterators)); }
ResultIterator iterator = queryPlan.useRoundRobinIterator() ? RoundRobinResultIterator.newIterator(iterators, queryPlan) : ConcatResultIterator.newIterator(iterators); if(queryPlan.getContext().getSequenceManager().getSequenceCount() > 0) { iterator = new SequenceResultIterator(iterator, queryPlan.getContext().getSequenceManager());
public RoundRobinResultIterator(ResultIterators iterators, QueryPlan plan) { this.resultIterators = iterators; this.plan = plan; this.threshold = getThreshold(); }
private int getThreshold() { int cacheSize = getScannerCacheSize(); checkArgument(cacheSize > 1, "RoundRobinResultIterator doesn't work when cache size is less than or equal to 1"); return cacheSize - 1; }
if (!success) { try { close(); } catch (Exception e) { if (toThrow == null) {
public RoundRobinResultIterator(List<PeekingResultIterator> iterators, QueryPlan plan) { this.resultIterators = null; this.plan = plan; this.threshold = getThreshold(); initOpenIterators(wrapToRoundRobinIterators(iterators)); }
private List<RoundRobinIterator> getIterators() throws SQLException { if (closed) { return Collections.emptyList(); } if (openIterators.size() > 0 && openIterators.size() == numScannersCacheExhausted) { /* * All the scanners have exhausted their cache. Submit the scanners back to the pool so that they can fetch * the next batch of records in parallel. */ initOpenIterators(fetchNextBatch()); } else if (openIterators.size() == 0 && resultIterators != null) { List<PeekingResultIterator> iterators = resultIterators.getIterators(); initOpenIterators(wrapToRoundRobinIterators(iterators)); } return openIterators; }
iterators.add(peekingResultIterator); ResultIterator iterator = queryPlan.useRoundRobinIterator() ? RoundRobinResultIterator.newIterator(iterators, queryPlan) : ConcatResultIterator.newIterator(iterators); if (queryPlan.getContext().getSequenceManager().getSequenceCount() > 0) { iterator = new SequenceResultIterator(iterator, queryPlan.getContext().getSequenceManager());
@Override public Tuple next() throws SQLException { List<RoundRobinIterator> iterators; int size; while ((size = (iterators = getIterators()).size()) > 0) { index = index % size; RoundRobinIterator itr = iterators.get(index); if (itr.getNumRecordsRead() < threshold) { Tuple tuple; if ((tuple = itr.peek()) != null) { tuple = itr.next(); if (itr.getNumRecordsRead() == threshold) { numScannersCacheExhausted++; } index = (index + 1) % size; return tuple; } else { // The underlying scanner is exhausted. Close the iterator and un-track it. itr.close(); iterators.remove(index); if (iterators.size() == 0) { close(); } } } else { index = (index + 1) % size; } } return null; }
public static ResultIterator newIterator(final List<PeekingResultIterator> iterators, QueryPlan plan) { if (iterators.isEmpty()) { return EMPTY_ITERATOR; } if (iterators.size() == 1) { return iterators.get(0); } return new RoundRobinResultIterator(iterators, plan); }
public RoundRobinResultIterator(ResultIterators iterators, QueryPlan plan) { this.resultIterators = iterators; this.plan = plan; this.threshold = getThreshold(); }
private int getThreshold() { int cacheSize = getScannerCacheSize(); checkArgument(cacheSize > 1, "RoundRobinResultIterator doesn't work when cache size is less than or equal to 1"); return cacheSize - 1; }