Examples of TupleBatch


Examples of org.teiid.common.buffer.TupleBatch

    @Test public void testOffsetWithoutLimit() throws Exception {
        LimitNode node = new LimitNode(1, null, new Constant(new Integer(10)));
        node.addChild(new FakeRelationalNode(2, getRows(10), 50));
        node.open();

        TupleBatch batch = node.nextBatch();
        assertNotNull(batch);
        assertEquals(0, batch.getRowCount());
        assertTrue(batch.getTerminationFlag());
    }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

      //TODO: could recreate the reference
    }

    private void addToCache(boolean update) {
      synchronized (activeBatches) {
        TupleBatch batch = this.activeBatch;
        if (batch == null) {
          return; //already removed
        }
        activeBatchColumnCount += batchManager.columnCount;
        TupleBufferInfo tbi = null;
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

          }
        }
      }
      persistBatchReferences();
      synchronized (this) {
        TupleBatch batch = this.activeBatch;
        if (batch != null){
          return batch;
        }
        Reference<TupleBatch> ref = this.batchReference;
        this.batchReference = null;
        if (ref != null) {
          batch = ref.get();
          if (batch != null) {
            if (cache) {
              this.activeBatch = batch;
                  addToCache(true);
            }
            referenceHit.getAndIncrement();
            return batch;
          }
        }
        long count = readCount.incrementAndGet();
        LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
        try {
          this.batchManager.compactionLock.readLock().lock();
          long[] info = batchManager.physicalMapping.get(this.id);
          ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(batchManager.store.createInputStream(info[0]), IO_BUFFER_SIZE));
                batch = new TupleBatch();
                batch.setDataTypes(types);
                batch.readExternal(ois);
                batch.setRowOffset(this.beginRow);
              batch.setDataTypes(null);
          if (lobManager != null) {
            for (List<?> tuple : batch.getTuples()) {
              lobManager.updateReferences(batchManager.lobIndexes, tuple);
            }
          }
              if (cache) {
                this.activeBatch = batch;
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

    }

    public synchronized void persist() throws TeiidComponentException {
      boolean lockheld = false;
            try {
        TupleBatch batch = activeBatch;
        if (batch != null) {
          if (!persistent) {
            long count = writeCount.incrementAndGet();
            LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
            long offset = 0;
            if (lobManager != null) {
              for (List<?> tuple : batch.getTuples()) {
                lobManager.updateReferences(batchManager.lobIndexes, tuple);
              }
            }
            synchronized (batchManager.store) {
              offset = batchManager.getOffset();
              OutputStream fsos = new BufferedOutputStream(batchManager.store.createOutputStream(), IO_BUFFER_SIZE);
                    ObjectOutputStream oos = new ObjectOutputStream(fsos);
                    batch.writeExternal(oos);
                    oos.close();
                    long size = batchManager.store.getLength() - offset;
                    long[] info = new long[] {offset, size};
                    batchManager.physicalMapping.put(this.id, info);
            }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

            for(int j=0; j<numColumns; j++) {
                row.add("data-" + (rowBegin + i) + "-" + j); //$NON-NLS-1$ //$NON-NLS-2$
            }
            rows.add(row);   
        }           
        return new TupleBatch(rowBegin, rows);
    }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

            last = batch.getTerminationFlag();
          } else if (fromBuffer && isForwardOnly()) {
              savedBatch = batch;
          }
                List<List<?>> memoryRows = batch.getTuples();
                batch = new TupleBatch(beginRow, memoryRows.subList(beginRow - batch.getBeginRow(), endRow - batch.getBeginRow() + 1));
                batch.setTerminationFlag(last);
        } else if (!fromBuffer){
          result = !isForwardOnly();
        }
          int finalRowCount = this.resultsBuffer.isFinal()?this.resultsBuffer.getRowCount():(batch.getTerminationFlag()?batch.getEndRow():-1);
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

                      reader.close();
                    } catch (IOException e) {
                    }
                      }
                    }
                  TupleBatch batch = new TupleBatch(nextBatchCount++, Arrays.asList(Arrays.asList(xml)));
                  return batch;
                }
                inst = env.getCurrentInstruction();
            }
           
          TupleBatch batch = new TupleBatch(nextBatchCount++, Collections.EMPTY_LIST);
          batch.setTerminationFlag(true);
          return batch;
        }
    }
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

        throws TeiidComponentException, TeiidProcessingException, BlockedException {

        // Already returned results?
        if(done) {
            // Already returned all results
            TupleBatch emptyTerminationBatch = new TupleBatch(beginBatch, new List[0]);
            emptyTerminationBatch.setTerminationFlag(true);
            return emptyTerminationBatch;

        }
        // First attempt to process
        if(this.finalTupleSource == null) {
View Full Code Here

Examples of org.teiid.common.buffer.TupleBatch

    protected boolean isBatchFull() {
        return (this.batchRows != null) && (this.batchRows.size() == this.batchSize);
    }

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

        batch.setTerminationFlag(this.lastBatch);

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

Examples of org.teiid.common.buffer.TupleBatch

      TeiidComponentException, TeiidProcessingException {
    while (true) {
      if (currentTuple == null) {
        currentTuple = tupleSource.nextTuple();
        if (currentTuple == null) {
          TupleBatch result = new TupleBatch(1, new List[] {Arrays.asList(updateCount)});
          result.setTerminationFlag(true);
          return result;
        }
      }
      if (this.rowProcessor == null) {
        rowProcedure.reset();
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.