@Override public void close() { if (closeable != null) { closeable.close(); closeable = null; } }
@Override public void startDecode() throws Exception { consumerThread.start(); super.startDecode(); }
@Override public boolean hasNext() { if (nextResult == null) { computeNext(); } return nextResult != null; }
private void computeNext() { try { nextResult = null; while (remainingTasks > 0) { while (!hasException() && ((nextResult = results.poll()) == null)) { // No results available, but there are still tasks running, // wait for more results. Thread.sleep(1); } // task end was signaled, reduce remaining task count. if (nextResult == TASK_END_MARKER) { remainingTasks--; nextResult = null; continue; } break; } } catch (final InterruptedException e) { setDecodeException(e); } if (hasException()) { throw new RuntimeException(getException()); } }
/** * Start the parallel decode. * * @throws Exception */ public void startDecode() throws Exception { final List<RowProvider> rowProviders = getRowProviders(); remainingTasks = rowProviders.size(); for (final RowProvider rowProvider : rowProviders) { threadPool.submit(new DecodeTask<>(rowProvider, this)); } }
@Override public void close() { if (consumerThread.isAlive()) { consumerThread.interrupt(); } super.close(); }
Iterators.transform(rowIter, r -> (GeoWaveRow) r)); try { decoder.startDecode(); } catch (final Exception e) { Throwables.propagate(e);
@SuppressWarnings("unchecked") @Override public T next() { if (nextResult == null) { computeNext(); } final Object next = nextResult; nextResult = null; return (T) next; }