@Override public int size() { return (int)tb.getRowCount(); } }
@Override public int size() { return (int)tb.getRowCount(); } }
public long getRowCount() { if (buffer == null) { return 0; } return buffer.getRowCount(); }
public long getRowCount() { if (buffer == null) { return 0; } return buffer.getRowCount(); }
private TupleBufferList(TupleBuffer tb) { this.tb = tb; if (tb.getRowCount() > Integer.MAX_VALUE) { throw new AssertionError("TupleBuffer too large for TupleBufferList"); //$NON-NLS-1$ } }
private TupleBufferList(TupleBuffer tb) { this.tb = tb; if (tb.getRowCount() > Integer.MAX_VALUE) { throw new AssertionError("TupleBuffer too large for TupleBufferList"); //$NON-NLS-1$ } }
public void disableSave() { if (buffer != null) { this.saveOnMark = true; this.mark = false; if (batch != null && batch.getEndRow() <= this.buffer.getRowCount()) { this.batch = null; } } }
public void disableSave() { if (buffer != null) { this.saveOnMark = true; this.mark = false; if (batch != null && batch.getEndRow() <= this.buffer.getRowCount()) { this.batch = null; } } }
@Override protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException { if(isFinal || noBlocking || reverse) { return null; } throw BlockedException.blockWithTrace("Blocking on non-final TupleBuffer", tupleSourceID, "size", getRowCount()); //$NON-NLS-1$ //$NON-NLS-2$ }
@Override protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException { if(isFinal || noBlocking || reverse) { return null; } throw BlockedException.blockWithTrace("Blocking on non-final TupleBuffer", tupleSourceID, "size", getRowCount()); //$NON-NLS-1$ //$NON-NLS-2$ }
protected boolean removeEldestEntry(Map.Entry<java.util.List<?>,TupleBuffer> eldest) { if (super.removeEldestEntry(eldest)) { if (spillOver != null && eldest.getValue().getRowCount() <= 2) { spillOver.put(eldest.getKey(), eldest.getValue()); } else { eldest.getValue().remove(); } return true; } return false; }
@Override public long getCurrentIndex() { if (!reverse) { return super.getCurrentIndex(); } return getRowCount() - super.getCurrentIndex() + 1; }
@Override public long getCurrentIndex() { if (!reverse) { return super.getCurrentIndex(); } return getRowCount() - super.getCurrentIndex() + 1; }
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
private void saveTuple(List<?> tuple) throws TeiidComponentException { if (tuple != null && mark && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.setRowCount(this.getCurrentIndex() - 1); this.buffer.addTuple(tuple); } }
@Override public void mark() throws TeiidComponentException { super.mark(); if (this.buffer != null && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.purge(); } mark = true; saveTuple(this.currentTuple); }
@Override public void mark() throws TeiidComponentException { super.mark(); if (this.buffer != null && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.purge(); } mark = true; saveTuple(this.currentTuple); }
@Test public void testCollect() throws Exception { FakeRelationalNode sourceNode = new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 1); sourceNode.setElements(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER))); BatchCollector bc = new BatchCollector(sourceNode, BufferManagerFactory.getStandaloneBufferManager(), new CommandContext(), false); bc.collectTuples(true); assertEquals(1, bc.getTupleBuffer().getManagedRowCount()); assertEquals(3, bc.collectTuples().getRowCount()); }