private TupleBatch nextBatchDirect() throws BlockedException, TeiidProcessingException, TeiidComponentException { boolean done = false; TupleBatch result = null; try { init(); long currentTime = System.currentTimeMillis(); Assertion.assertTrue(!processorClosed); // TODO: see if there is pending work before preempting while (currentTime < context.getTimeSliceEnd() || context.isNonBlocking()) { if (requestCanceled) { throw new TeiidProcessingException( QueryPlugin.Event.TEIID30160, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30160, getProcessID())); } if (currentTime > context.getTimeoutEnd()) { throw new TeiidProcessingException( QueryPlugin.Event.TEIID30161, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30161)); } result = processPlan.nextBatch(); if (continuous) { result.setRowOffset(rowOffset); if (result.getTerminationFlag()) { result.setTermination(TupleBatch.ITERATION_TERMINATED); List<Object> terminationTuple = Arrays.asList(new Object[this.getOutputElements().size()]); result.getTuples().add(terminationTuple); this.context.getTupleSourceCache().close(); this.processPlan.close(); this.processPlan.reset(); this.context.incrementReuseCount(); this.open = false; } rowOffset = result.getEndRow() + 1; } if (result.getTermination() != TupleBatch.NOT_TERMINATED) { if (result.getTerminationFlag()) { done = true; } break; } if (result.getRowCount() > 0) { break; } } } catch (BlockedException e) { throw e; } catch (TeiidException e) { closeProcessing(); if (e instanceof TeiidProcessingException) { throw (TeiidProcessingException) e; } if (e instanceof TeiidComponentException) { throw (TeiidComponentException) e; } throw new TeiidComponentException(QueryPlugin.Event.TEIID30162, e); } if (done) { closeProcessing(); } if (result == null) { throw EXPIRED_TIME_SLICE; } return result; }