this.sortUtility = new SortUtility(null, sortSymbols, sortDirection, Mode.DUP_REMOVE, dependentNode.getBufferManager(), dependentNode.getConnectionID(), originalVs.getSchema()); this.sortUtility.setWorkingBuffer(originalVs.getTupleBuffer());
partitionMapping[specIndex] = this.getBufferManager().createSTree(elements, this.getConnectionID(), 1); SortUtility su = new SortUtility(null, Mode.SORT, this.getBufferManager(), this.getConnectionID(), tb.getSchema(), info.orderType, info.nullOrderings, sortKeys); su.setWorkingBuffer(tb); su.setNonBlocking(true);
this.sortUtility = new SortUtility(null, sortSymbols, sortDirection, Mode.DUP_REMOVE, dependentNode.getBufferManager(), dependentNode.getConnectionID(), originalVs.getSchema()); this.sortUtility.setWorkingBuffer(originalVs.getTupleBuffer());
this.sortUtility = new SortUtility(null, sortSymbols, sortDirection, Mode.DUP_REMOVE, dependentNode.getBufferManager(), dependentNode.getConnectionID(), originalVs.getSchema()); this.sortUtility.setWorkingBuffer(originalVs.getTupleBuffer());
@Test public void testOnePass() throws Exception { ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER); ElementSymbol es2 = new ElementSymbol("e2"); //$NON-NLS-1$ es2.setType(DataTypeManager.DefaultDataClasses.INTEGER); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es2), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tsid.addTuple(Arrays.asList(1, 1)); tsid.addTuple(Arrays.asList(1, 2)); tsid.close(); SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema()); //$NON-NLS-1$ List<TupleBuffer> buffers = su.onePassSort(true); assertEquals(1, buffers.size()); assertTrue(!buffers.get(0).isForwardOnly()); }
try { if (ii.ordering == null && orderBy != null) { SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID, projectedCols); sort.setNonBlocking(true); tb = sort.sort();
ts = new BatchIterator(this.source); this.sortUtility = new SortUtility(ts, expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), sortOption == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT, this.source.getBufferManager(), this.source.getConnectionID(), source.getElements()); this.markExpressionsDistinct(sortOption == SortOption.SORT_DISTINCT && expressions.size() == this.getOuterVals().size());
try { if (ii.ordering == null && orderBy != null) { SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID, projectedCols); sort.setNonBlocking(true); tb = sort.sort();
try { if (ii.ordering == null && orderBy != null) { SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID, projectedCols); sort.setNonBlocking(true); tb = sort.sort();
ts = new BatchIterator(this.source); this.sortUtility = new SortUtility(ts, expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), sortOption == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT, this.source.getBufferManager(), this.source.getConnectionID(), source.getElements()); this.markExpressionsDistinct(sortOption == SortOption.SORT_DISTINCT && expressions.size() == this.getOuterVals().size());
ts = new BatchIterator(this.source); this.sortUtility = new SortUtility(ts, expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), sortOption == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT, this.source.getBufferManager(), this.source.getConnectionID(), source.getElements()); this.markExpressionsDistinct(sortOption == SortOption.SORT_DISTINCT && expressions.size() == this.getOuterVals().size());
@Test public void testDistinct() throws Exception { ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER); ElementSymbol es2 = new ElementSymbol("e2"); //$NON-NLS-1$ es2.setType(DataTypeManager.DefaultDataClasses.INTEGER); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es2), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tsid.addTuple(Arrays.asList(1, 1)); tsid.addTuple(Arrays.asList(1, 2)); tsid.close(); SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.DUP_REMOVE_SORT, bm, "test", tsid.getSchema()); //$NON-NLS-1$ su.sort(); assertFalse(su.isDistinct()); }
@Test public void testStableSort() throws Exception { ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es1), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tsid.addTuple(Arrays.asList(1, 1)); tsid.addTuple(Arrays.asList(1, 2)); tsid.addTuple(Arrays.asList(1, 3)); tsid.close(); SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema()); //$NON-NLS-1$ 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()); }
@Test public void testSortLimit() throws Exception { ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1, es1), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tsid.addTuple(Arrays.asList(4)); tsid.addTuple(Arrays.asList(3)); tsid.addTuple(Arrays.asList(2)); tsid.addTuple(Arrays.asList(1)); tsid.close(); SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema()); //$NON-NLS-1$ su.setBatchSize(2); TupleBuffer out = su.sort(2); TupleSource ts = out.createIndexedTupleSource(); assertEquals(Arrays.asList(1), ts.nextTuple()); assertEquals(Arrays.asList(2), ts.nextTuple()); assertNull(ts.nextTuple()); su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.SORT, bm, "test", tsid.getSchema()); //$NON-NLS-1$ su.setBatchSize(10); out = su.sort(2); ts = out.createIndexedTupleSource(); assertEquals(Arrays.asList(1), ts.nextTuple()); assertEquals(Arrays.asList(2), ts.nextTuple()); assertNull(ts.nextTuple()); }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.sortUtility == null) { TupleSource ts = null; TupleBuffer working = null; if (!getChildren()[0].hasBuffer()) { ts = new BatchIterator(getChildren()[0]); } else { working = getChildren()[0].getBuffer(-1); } this.sortUtility = new SortUtility(ts, items, this.mode, getBufferManager(), getConnectionID(), getChildren()[0].getElements()); if (ts == null) { this.sortUtility.setWorkingBuffer(working); } } this.output = this.sortUtility.sort(rowLimit); if (this.outputTs == null) { this.outputTs = this.output.createIndexedTupleSource(); } this.phase = OUTPUT; }
sortUtility = new SortUtility(null, sortItems, removeDuplicates?Mode.DUP_REMOVE_SORT:Mode.SORT, mgr, groupName, collectionBuffer.getSchema()); collectionBuffer.setForwardOnly(true); this.sortUtility.setWorkingBuffer(collectionBuffer);
sortUtility = new SortUtility(null, sortItems, removeDuplicates?Mode.DUP_REMOVE_SORT:Mode.SORT, mgr, groupName, collectionBuffer.getSchema()); collectionBuffer.setForwardOnly(true); this.sortUtility.setWorkingBuffer(collectionBuffer);
sortUtility = new SortUtility(null, sortItems, removeDuplicates?Mode.DUP_REMOVE_SORT:Mode.SORT, mgr, groupName, collectionBuffer.getSchema()); collectionBuffer.setForwardOnly(true); this.sortUtility.setWorkingBuffer(collectionBuffer);