private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws TeiidComponentException, TeiidProcessingException { while (true) { sortedSublist.tuple = null; sortedSublist.tuple = sortedSublist.its.nextTuple(); if (sortedSublist.tuple == null) { return; // done with this sublist } int index = Collections.binarySearch(subLists, sortedSublist); if (index < 0) { subLists.add(-index - 1, sortedSublist); return; } if (mode == Mode.SORT) { subLists.add(index, sortedSublist); return; } } }
private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws TeiidComponentException, TeiidProcessingException { while (true) { sortedSublist.tuple = null; sortedSublist.tuple = sortedSublist.its.nextTuple(); if (sortedSublist.tuple == null) { return; // done with this sublist } int index = Collections.binarySearch(subLists, sortedSublist); if (index < 0) { subLists.add(-index - 1, sortedSublist); return; } if (mode == Mode.SORT) { subLists.add(index, sortedSublist); return; } } }
private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws TeiidComponentException, TeiidProcessingException { while (true) { sortedSublist.tuple = null; sortedSublist.tuple = sortedSublist.its.nextTuple(); if (sortedSublist.tuple == null) { return; // done with this sublist } int index = Collections.binarySearch(subLists, sortedSublist); if (index < 0) { subLists.add(-index - 1, sortedSublist); return; } if (mode == Mode.SORT) { subLists.add(index, sortedSublist); return; } } }
break; List<?> tuple = ts.nextTuple();
break; List<?> tuple = ts.nextTuple();
break; List<?> tuple = ts.nextTuple();
undoTs.setReverse(true); List<?> tuple = null; while ((tuple = undoTs.nextTuple()) != null) { try { undo(tuple);
undoTs.setReverse(true); List<?> tuple = null; while ((tuple = undoTs.nextTuple()) != null) { try { undo(tuple);
undoTs.setReverse(true); List<?> tuple = null; while ((tuple = undoTs.nextTuple()) != null) { try { undo(tuple);
@Override protected void afterCompletion(boolean success) throws TeiidComponentException { if (!success && upsertUndoLog != null) { upsertUndoLog.setFinal(true); TupleBufferTupleSource undoTs = upsertUndoLog.createIndexedTupleSource(); undoTs.setReverse(true); List<?> tuple = null; try { while ((tuple = undoTs.nextTuple()) != null) { try { updateTuple(tuple); } catch (TeiidException e) { LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage()); } } } catch (TeiidProcessingException e) { //shouldn't happen throw new TeiidComponentException(e); } } tree.setBatchInsert(false); }
@Override protected void afterCompletion(boolean success) throws TeiidComponentException { if (!success && upsertUndoLog != null) { upsertUndoLog.setFinal(true); TupleBufferTupleSource undoTs = upsertUndoLog.createIndexedTupleSource(); undoTs.setReverse(true); List<?> tuple = null; try { while ((tuple = undoTs.nextTuple()) != null) { try { updateTuple(tuple); } catch (TeiidException e) { LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage()); } } } catch (TeiidProcessingException e) { //shouldn't happen throw new TeiidComponentException(e); } } tree.setBatchInsert(false); }
@Override protected void afterCompletion(boolean success) throws TeiidComponentException { if (!success && upsertUndoLog != null) { upsertUndoLog.setFinal(true); TupleBufferTupleSource undoTs = upsertUndoLog.createIndexedTupleSource(); undoTs.setReverse(true); List<?> tuple = null; try { while ((tuple = undoTs.nextTuple()) != null) { try { updateTuple(tuple); } catch (TeiidException e) { LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage()); } } } catch (TeiidProcessingException e) { //shouldn't happen throw new TeiidComponentException(e); } } tree.setBatchInsert(false); }
@Test public void testReverseIteration() throws Exception { ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ x.setType(DataTypeManager.DefaultDataClasses.INTEGER); List<ElementSymbol> schema = Arrays.asList(x); TupleBuffer tb = BufferManagerFactory.getStandaloneBufferManager().createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tb.addTuple(Arrays.asList(1)); tb.addTuple(Arrays.asList(2)); TupleBufferTupleSource tbts = tb.createIndexedTupleSource(); tbts.setReverse(true); assertTrue(tbts.hasNext()); assertEquals(2, tbts.nextTuple().get(0)); assertEquals(1, tbts.nextTuple().get(0)); assertFalse(tbts.hasNext()); }