Author: shawkins
Date: 2009-05-29 17:23:05 -0400 (Fri, 29 May 2009)
New Revision: 1012
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
Log:
TEIID-636 fix for dup removal performed by a grouping node.
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-05-29
19:53:46 UTC (rev 1011)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2009-05-29
21:23:05 UTC (rev 1012)
@@ -320,6 +320,7 @@
private void sortPhase() throws BlockedException, MetaMatrixComponentException,
MetaMatrixProcessingException {
this.sortedID = this.sortUtility.sort();
+ this.rowCount = this.getBufferManager().getFinalRowCount(this.sortedID);
this.phase = GROUP;
}
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-05-29
19:53:46 UTC (rev 1011)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2009-05-29
21:23:05 UTC (rev 1012)
@@ -178,20 +178,7 @@
public void test2() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- // Set up
- GroupingNode node = new GroupingNode(1);
- List outputElements = new ArrayList();
- ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
- col1.setType(Integer.class);
- ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
- col2.setType(Integer.class);
- outputElements.add(col1);
- outputElements.add(new AggregateSymbol("countDist", "COUNT",
true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
- node.setElements(outputElements);
-
- List groupingElements = new ArrayList();
- groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
- node.setGroupingElements(groupingElements);
+ GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test",
null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
@@ -214,20 +201,7 @@
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
((BufferManagerImpl)mgr).getConfig().setProcessorBatchSize(5);
- // Set up
- GroupingNode node = new GroupingNode(1);
- List outputElements = new ArrayList();
- ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
- col1.setType(Integer.class);
- ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
- col2.setType(Integer.class);
- outputElements.add(col1);
- outputElements.add(new AggregateSymbol("countDist", "COUNT",
true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
- node.setElements(outputElements);
-
- List groupingElements = new ArrayList();
- groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
- node.setGroupingElements(groupingElements);
+ GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test",
null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
node.initialize(context, mgr, null);
@@ -431,4 +405,44 @@
public void testLookupFunctionMultipleBatches() throws Exception {
helpTestLookupFunctionInAggregate(3);
}
+
+ public void testDupSort() throws Exception {
+ BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
+
+ GroupingNode node = getExampleGroupingNode();
+ node.setRemoveDuplicates(true);
+ CommandContext context = new CommandContext("pid", "test",
null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
+ node.initialize(context, mgr, null);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(4), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(5), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(6), new Integer(2) })
+ };
+
+ helpProcess(mgr, node, context, expected);
+ }
+
+ private GroupingNode getExampleGroupingNode() {
+ GroupingNode node = new GroupingNode(1);
+ List outputElements = new ArrayList();
+ ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
+ col1.setType(Integer.class);
+ ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
+ col2.setType(Integer.class);
+ outputElements.add(col1);
+ outputElements.add(new AggregateSymbol("countDist", "COUNT",
true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+ node.setElements(outputElements);
+
+ List groupingElements = new ArrayList();
+ groupingElements.add(new ElementSymbol("col1")); //$NON-NLS-1$
+ node.setGroupingElements(groupingElements);
+ return node;
+ }
+
}