Exemple #1
0
  @Override
  protected synchronized TupleBatch nextBatchDirect()
      throws BlockedException, TeiidComponentException, TeiidProcessingException {

    evaluate(false);

    if (streaming) {
      while (state == State.BUILDING) {
        try {
          this.wait();
        } catch (InterruptedException e) {
          throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30169, e);
        }
      }
      unwrapException(asynchException);
      TupleBatch batch = this.buffer.getBatch(outputRow);
      outputRow = batch.getEndRow() + 1;
      if (state != State.DONE && !batch.getTerminationFlag()) {
        state = hasNextBatch() ? State.AVAILABLE : State.BUILDING;
      }
      return batch;
    }

    while (!isBatchFull() && !isLastBatch()) {
      if (item == null) {
        try {
          item = result.iter.next();
        } catch (XPathException e) {
          throw new TeiidProcessingException(
              QueryPlugin.Event.TEIID30170,
              e,
              QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30170, e.getMessage()));
        }
        rowCount++;
        if (item == null) {
          terminateBatches();
          break;
        }
      }
      addBatchRow(processRow());
      if (rowCount == rowLimit) {
        terminateBatches();
        break;
      }
    }
    return pullBatch();
  }