use of org.teiid.common.buffer.TupleSource in project teiid by teiid.
the class TestSortNode method testStableSort.
@Test
public void testStableSort() throws Exception {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
// $NON-NLS-1$
TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es1), "test", TupleSourceType.PROCESSOR);
tsid.addTuple(Arrays.asList(1, 1));
tsid.addTuple(Arrays.asList(1, 2));
tsid.addTuple(Arrays.asList(1, 3));
tsid.close();
// $NON-NLS-1$
SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema());
su.setBatchSize(1);
su.setStableSort(true);
TupleBuffer out = su.sort();
TupleSource ts = out.createIndexedTupleSource();
assertEquals(Arrays.asList(1, 1), ts.nextTuple());
assertEquals(Arrays.asList(1, 2), ts.nextTuple());
assertEquals(Arrays.asList(1, 3), ts.nextTuple());
assertNull(ts.nextTuple());
}
Aggregations