public void addInput(List<?> tuple, CommandContext commandContext, long startFrame, long endFrame, TupleBuffer frame) throws TeiidComponentException, TeiidProcessingException { Integer nthIndex = (Integer)tuple.get(argIndexes[1]); if (nthIndex > endFrame || nthIndex < startFrame) { this.value = null; } else { this.value = frame.getBatch(nthIndex).getTuple(nthIndex).get(argIndexes[0]); } //TODO: the computation of the nth value should be done as needed, not over the whole input set }
public void addInput(List<?> tuple, CommandContext commandContext, long startFrame, long endFrame, TupleBuffer frame) throws TeiidComponentException, TeiidProcessingException { Integer nthIndex = (Integer)tuple.get(argIndexes[1]); if (nthIndex > endFrame || nthIndex < startFrame) { this.value = null; } else { this.value = frame.getBatch(nthIndex).getTuple(nthIndex).get(argIndexes[0]); } //TODO: the computation of the nth value should be done as needed, not over the whole input set }
@Override public List<?> get(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(String.valueOf(index)); } try { return tb.getBatch(index+1).getTuple(index+1); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30483, e); } }
@Override public List<?> get(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(String.valueOf(index)); } try { return tb.getBatch(index+1).getTuple(index+1); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30483, e); } }
@Override public List<?> get(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(String.valueOf(index)); } try { return tb.getBatch(index+1).getTuple(index+1); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30483, e); } }
protected List<?> getCurrentTuple() throws TeiidComponentException, BlockedException, TeiidProcessingException { if (available() > 0) { //if (forwardOnly) { long row = getCurrentIndex(); if (batch == null || !batch.containsRow(row)) { batch = getBatch(row); } return batch.getTuple(row); //} //TODO: determine if we should directly hold a soft reference here //return getRow(currentRow); } batch = null; return finalRow(); }
protected List<?> getCurrentTuple() throws TeiidComponentException, BlockedException, TeiidProcessingException { if (available() > 0) { //if (forwardOnly) { long row = getCurrentIndex(); if (batch == null || !batch.containsRow(row)) { batch = getBatch(row); } return batch.getTuple(row); //} //TODO: determine if we should directly hold a soft reference here //return getRow(currentRow); } batch = null; return finalRow(); }
protected List<?> getCurrentTuple() throws TeiidComponentException, BlockedException, TeiidProcessingException { if (available() > 0) { //if (forwardOnly) { long row = getCurrentIndex(); if (batch == null || !batch.containsRow(row)) { batch = getBatch(row); } return batch.getTuple(row); //} //TODO: determine if we should directly hold a soft reference here //return getRow(currentRow); } batch = null; return finalRow(); }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
@Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { synchronized (tb) { if (rowNumber <= tb.getRowCount()) { return tb.getBatch(rowNumber).getTuple(rowNumber++); } if (tb.isFinal()) { return null; } List<?> row = ts.nextTuple(); if (row == null) { tb.setFinal(true); } else { tb.addTuple(row); rowNumber++; } return row; } }
@Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { synchronized (tb) { if (rowNumber <= tb.getRowCount()) { return tb.getBatch(rowNumber).getTuple(rowNumber++); } if (tb.isFinal()) { return null; } List<?> row = ts.nextTuple(); if (row == null) { tb.setFinal(true); } else { tb.addTuple(row); rowNumber++; } return row; } }
@Override public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException { synchronized (tb) { if (rowNumber <= tb.getRowCount()) { return tb.getBatch(rowNumber).getTuple(rowNumber++); } if (tb.isFinal()) { return null; } List<?> row = ts.nextTuple(); if (row == null) { tb.setFinal(true); } else { tb.addTuple(row); rowNumber++; } return row; } }
private void helpTestNextBatch(int[] commandsPerPlan) throws Exception { List plans = new ArrayList(commandsPerPlan.length); int totalCommands = 0; for (int i = 0; i < commandsPerPlan.length; i++) { totalCommands += commandsPerPlan[i]; plans.add(new FakeProcessorPlan(commandsPerPlan[i])); } BatchedUpdatePlan plan = new BatchedUpdatePlan(plans, totalCommands, null, false); plan.initialize(new CommandContext(), null, null); TupleBatch batch = plan.nextBatch(); assertEquals(totalCommands, batch.getRowCount()); for (int i = 1; i <= totalCommands; i++) { assertEquals(new Integer(1), batch.getTuple(i).get(0)); } }
@Test public void testOffsetInSecondBatch() throws Exception { LimitNode node = getOffsetNode(55, new FakeRelationalNode(2, getRows(100), 50)); // batch 1 TupleBatch batch = node.nextBatch(); assertNotNull(batch); assertEquals(45, batch.getRowCount()); assertEquals(1, batch.getBeginRow()); assertEquals(45, batch.getEndRow()); assertEquals(Arrays.asList(new Object[] {new Integer(56)}), batch.getTuple(1)); assertTrue(batch.getTerminationFlag()); }
@Test public void testOffsetMultipleOfBatchSize() throws Exception { LimitNode node = getOffsetNode(100, new FakeRelationalNode(2, getRows(300), 50)); TupleBatch batch = node.nextBatch(); assertNotNull(batch); assertEquals(50, batch.getRowCount()); assertEquals(1, batch.getBeginRow()); assertEquals(50, batch.getEndRow()); assertEquals(Arrays.asList(new Object[] {new Integer(101)}), batch.getTuple(1)); assertFalse(batch.getTerminationFlag()); }
@Test public void testOffsetAtBatchSize() throws Exception { LimitNode node = getOffsetNode(50, new FakeRelationalNode(2, getRows(100), 50)); TupleBatch batch = node.nextBatch(); assertNotNull(batch); assertEquals(50, batch.getRowCount()); assertEquals(1, batch.getBeginRow()); assertEquals(50, batch.getEndRow()); assertEquals(Arrays.asList(new Object[] {new Integer(51)}), batch.getTuple(1)); assertTrue(batch.getTerminationFlag()); }
public void helpTestProject(List elements, List[] data, List childElements, List[] expected, ProcessorDataManager dataMgr) throws TeiidComponentException, TeiidProcessingException { ProjectNode projectNode = helpSetupProject(elements, data, childElements, dataMgr); projectNode.open(); int currentRow = 1; while(true) { try { TupleBatch batch = projectNode.nextBatch(); for(int row = currentRow; row <= batch.getEndRow(); row++) { assertEquals("Rows don't match at " + row, expected[row-1], batch.getTuple(row)); //$NON-NLS-1$ } if(batch.getTerminationFlag()) { break; } currentRow += batch.getRowCount(); } catch(BlockedException e) { // ignore and try again } } }
@Test public void testOffsetInFirstBatch() throws Exception { LimitNode node = getOffsetNode(49, new FakeRelationalNode(2, getRows(100), 50)); // batch 1 TupleBatch batch = node.nextBatch(); assertNotNull(batch); assertEquals(1, batch.getRowCount()); assertEquals(1, batch.getBeginRow()); assertEquals(1, batch.getEndRow()); assertEquals(Arrays.asList(new Object[] {new Integer(50)}), batch.getTuple(1)); assertFalse(batch.getTerminationFlag()); // batch2 batch = node.nextBatch(); assertNotNull(batch); assertEquals(50, batch.getRowCount()); assertEquals(2, batch.getBeginRow()); assertEquals(51, batch.getEndRow()); assertEquals(Arrays.asList(new Object[] {new Integer(51)}), batch.getTuple(2)); assertTrue(batch.getTerminationFlag()); }