Examples of TupleBatch


Examples of org.teiid.common.buffer.TupleBatch

            this.buffer.setForwardOnly(fowardOnly);
        }
    }

    public TupleBuffer collectTuples() throws TeiidComponentException, TeiidProcessingException {
        TupleBatch batch = null;
      while(!done) {
        if (this.sourceNode.hasFinalBuffer()) {
          if (this.buffer == null) {
            TupleBuffer finalBuffer = this.sourceNode.getFinalBuffer();
            Assertion.isNotNull(finalBuffer);
          this.buffer = finalBuffer;
          }
          if (this.buffer.isFinal()) {
          this.buffer.setForwardOnly(forwardOnly);
          done = true;
          break;
        }
        }
        batch = sourceNode.nextBatch();
           
            flushBatch(batch);

            // Check for termination condition
            if(batch.getTerminationFlag()) {
              done = true;
              buffer.close();
                break;
            }
        }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

           
            // since we are done with the plan explicitly close it.
            updatePlans[planIndex].close();
        }
        // Add tuples to current batch
        TupleBatch batch = new TupleBatch(1, updateCounts);
        batch.setTerminationFlag(true);
        return batch;
    }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

  }
 
  @Override
  public TupleBatch nextBatch() throws BlockedException,
      TeiidComponentException, TeiidProcessingException {
    TupleBatch tupleBatch = new TupleBatch(1, new List[] {Arrays.asList(0)});
    tupleBatch.setTerminationFlag(true);
    return tupleBatch;
  }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

 
  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.Util.getString("QueryProcessor.request_cancelled", getProcessID())); //$NON-NLS-1$
              }
            if (currentTime > context.getTimeoutEnd()) {
              throw new TeiidProcessingException("Query timed out"); //$NON-NLS-1$
            }
              result = processPlan.nextBatch();
 
            if(result.getTerminationFlag()) {
              done = true;
              break;
            }
           
            if (result.getRowCount() > 0) {
              break;
            }
           
          }
      } catch (BlockedException e) {
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

          create.setElementSymbolsAsColumns(withCommand.getColumns());
          create.setTable(withCommand.getGroupSymbol());
          this.root.getDataManager().registerRequest(getContext(), create, TempMetadataAdapter.TEMP_MODEL.getID(), null, 0, -1);
          }
          while (true) {
            TupleBatch batch = withProcessor.nextBatch();
            Insert insert = new Insert(withCommand.getGroupSymbol(), withCommand.getColumns(), null);
                insert.setTupleSource(new CollectionTupleSource(batch.getTuples().iterator()));
                this.root.getDataManager().registerRequest(getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getID(), null, 0, -1);
            if (batch.getTerminationFlag()) {
              break;
            }
          }
            this.tempTableStore.setUpdatable(withCommand.getGroupSymbol().getCanonicalName(), false);
            withToProcess.remove(0);
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

        if(currentBatch == null) {
            // There was no saved batch, so get a new one
            //in the case of select with no from, should return only
            //one batch with one row
            if(this.getChildren()[0] == null){
              currentBatch = new TupleBatch(1, new List[]{Arrays.asList(new Object[] {})});
              currentBatch.setTerminationFlag(true);
            }else{
              currentBatch = this.getChildren()[0].nextBatch();
            }

            // Check for no project needed and pass through
            if(!needsProject) {
              TupleBatch result = currentBatch;
              currentBatch = null;
                return result;
            }
        }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

    protected boolean hasPendingRows() {
      return this.getProcessingState().batchRows != null;
    }

    protected TupleBatch pullBatch() {
        TupleBatch batch = null;
        if(this.getProcessingState().batchRows != null) {
            batch = new TupleBatch(this.getProcessingState().beginBatch, this.getProcessingState().batchRows);
            getProcessingState().beginBatch += this.getProcessingState().batchRows.size();
        } else {
            batch = new TupleBatch(this.getProcessingState().beginBatch, Collections.EMPTY_LIST);
        }

        batch.setTerminationFlag(this.getProcessingState().lastBatch);

        // Reset batch state
        this.getProcessingState().batchRows = null;
        this.getProcessingState().lastBatch = false;
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

            while (true) {
              //start timer for this batch
                if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
                    this.getProcessingState().nodeStatistics.startBatchTimer();
                }
                TupleBatch batch = nextBatchDirect();
                if (recordStats) {
                    if(this.getProcessingState().context.getCollectNodeStatistics()) {
                        // stop timer for this batch (normal)
                        this.getProcessingState().nodeStatistics.stopBatchTimer();
                        this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(batch, RelationalNodeStatistics.BATCHCOMPLETE_STOP);
                        if (batch.getTerminationFlag()) {
                            this.getProcessingState().nodeStatistics.collectNodeStats(this.getChildren(), this.getClassName());
                            //this.nodeStatistics.dumpProperties(this.getClassName());
                        }
                    }
                    this.recordBatch(batch);
                }
                //24663: only return non-zero batches.
                //there have been several instances in the code that have not correctly accounted for non-terminal zero length batches
                //this processing style however against the spirit of batch processing (but was already utilized by Sort and Grouping nodes)
                if (batch.getRowCount() != 0 || batch.getTerminationFlag()) {
                    if (batch.getTerminationFlag()) {
                        close();
                    }
                    return batch;
                }
            }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

  }
   
    protected TupleBatch nextBatchDirect() throws BlockedException,
                                          TeiidComponentException,
                                          TeiidProcessingException {
        TupleBatch batch = null; // Can throw BlockedException
       
        if (limit == 0) {
          this.terminateBatches();
          return pullBatch();
        }
       
        // If we haven't reached the offset, then skip rows/batches
        if (offsetPhase) {
            while (rowCounter <= offset) {
                batch = getChildren()[0].nextBatch(); // Can throw BlockedException
                rowCounter += batch.getRowCount();
                if (batch.getTerminationFlag()) {
                    break;
                }
            }
           
            List[] tuples = null;
           
            if (rowCounter > offset) {
                List[] originalTuples = batch.getAllTuples();
                int rowsToKeep = rowCounter - offset;
                tuples = new List[rowsToKeep];
                System.arraycopy(originalTuples, batch.getRowCount() - rowsToKeep, tuples, 0, tuples.length);
            } else {
                tuples = new List[0]; //empty batch
            }
            TupleBatch resultBatch = new TupleBatch(1, tuples);
            resultBatch.setTerminationFlag(batch.getTerminationFlag());
            batch = resultBatch;
            offsetPhase = false;
            rowCounter = 0;
        } else {
            batch = getChildren()[0].nextBatch(); // Can throw BlockedException
        }
       
        List[] tuples = null;
       
        if (limit < 0 || rowCounter + batch.getRowCount() <= limit) {
            // Passthrough
           tuples = batch.getAllTuples();
        } else {
            // Partial batch
            List[] originalTuples = batch.getAllTuples();
            tuples = new List[limit - rowCounter];
            System.arraycopy(originalTuples, 0, tuples, 0, tuples.length);
        }
       
        TupleBatch resultBatch = new TupleBatch(rowCounter+1, tuples);
       
        rowCounter += resultBatch.getRowCount();
        if (rowCounter == limit || batch.getTerminationFlag()) {
            resultBatch.setTerminationFlag(true);
        }       
        return resultBatch;
    }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

        if (!needsProcessing) {
            terminateBatches();
            return pullBatch();
        }
       
    TupleBatch batch = plan.nextBatch();
      
        for (List tuple : batch.getTuples()) {
            addBatchRow(tuple);
    }
       
        if(batch.getTerminationFlag()) {
          if (hasNextCommand()) {
            resetPlan();
          } else {
            terminateBatches();
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.