summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-12-26 01:58:04 (EST)
committer mwu2011-12-26 01:58:04 (EST)
commit7a04efd74eb05c2cdf00f573fa532630f928a3e1 (patch)
treed1a4d4d0d4c151cb305eaa6c4424defd3a72c199
parentc67f627055738cc6e0a08f5a4e57684ba8aa2c25 (diff)
downloadorg.eclipse.birt-7a04efd74eb05c2cdf00f573fa532630f928a3e1.zip
org.eclipse.birt-7a04efd74eb05c2cdf00f573fa532630f928a3e1.tar.gz
org.eclipse.birt-7a04efd74eb05c2cdf00f573fa532630f928a3e1.tar.bz2
Checkin: Enhance Step By Step Query Execution on xTab
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeIVTest.java250
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter1.txt9
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter2.txt7
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java9
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/filter/AggregationFilterHelper.java2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionUtil.java45
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java3
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java59
8 files changed, 357 insertions, 27 deletions
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeIVTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeIVTest.java
index feb17e3..a35216d 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeIVTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeIVTest.java
@@ -1863,5 +1863,255 @@ public class CubeIVTest extends BaseTestCase
return output;
}
+ public void testIVWithIncrementNoAggrUpdateFilter1( ) throws Exception
+ {
+ ICubeQueryDefinition cqd = new CubeQueryDefinition( cubeName);
+ IEdgeDefinition columnEdge = cqd.createEdge( ICubeQueryDefinition.COLUMN_EDGE );
+ IEdgeDefinition rowEdge = cqd.createEdge( ICubeQueryDefinition.ROW_EDGE );
+ IDimensionDefinition dim1 = columnEdge.createDimension( "dimension1" );
+ IHierarchyDefinition hier1 = dim1.createHierarchy( "dimension1" );
+ hier1.createLevel( "level11" );
+ hier1.createLevel( "level12" );
+ hier1.createLevel( "level13" );
+
+ IDimensionDefinition dim2 = rowEdge.createDimension( "dimension2" );
+ IHierarchyDefinition hier2 = dim2.createHierarchy( "dimension2" );
+ hier2.createLevel( "level21" );
+
+ cqd.createMeasure( "measure1" );
+
+ IBinding binding1 = new Binding( "edge1level1");
+
+ binding1.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level11\"]") );
+ cqd.addBinding( binding1 );
+
+ IBinding binding2 = new Binding( "edge1level2");
+
+ binding2.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level12\"]") );
+ cqd.addBinding( binding2 );
+
+ IBinding binding3 = new Binding( "edge1level3");
+
+ binding3.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level13\"]") );
+ cqd.addBinding( binding3 );
+
+ IBinding binding4 = new Binding( "edge2level1");
+
+ binding4.setExpression( new ScriptExpression("dimension[\"dimension2\"][\"level21\"]") );
+ cqd.addBinding( binding4 );
+
+ IBinding binding5 = new Binding( "measure1" );
+ binding5.setExpression( new ScriptExpression("measure[\"measure1\"]") );
+ binding5.setAggrFunction("SUM");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level11\"]");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level12\"]");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level13\"]");
+ binding5.addAggregateOn("dimension[\"dimension2\"][\"level21\"]");
+ cqd.addBinding( binding5 );
+
+ cqd.setCacheQueryResults( true );
+ FileArchiveWriter writter = new FileArchiveWriter( documentPath + "testTemp" );
+ DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.MODE_GENERATION,
+ null,
+ null,
+ writter );
+ context.setTmpdir( this.getTempDir( ) );
+ DataEngineImpl engine = (DataEngineImpl)DataEngine.newDataEngine( context );
+ this.createCube( writter, engine );
+
+ IPreparedCubeQuery pcq = engine.prepare( cqd, null );
+ ICubeQueryResults queryResults = pcq.execute( null );
+ CubeCursor cursor = queryResults.getCubeCursor( );
+
+
+ //Load from cache.
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ writter.finish( );
+ engine.shutdown( );
+
+ List columnEdgeBindingNames = new ArrayList();
+ columnEdgeBindingNames.add( "edge1level1" );
+ columnEdgeBindingNames.add( "edge1level2" );
+ columnEdgeBindingNames.add( "edge1level3" );
+
+ FileArchiveReader reader = new FileArchiveReader( documentPath + "testTemp" );
+ ArchiveWriter writer = new ArchiveWriter( new ArchiveFile(documentPath + "testTemp", "rw+") );
+
+ ICubeQueryDefinition savedQuery = CubeQueryDefinitionIOUtil.load( queryResults.getID( ), DataEngineContext.newInstance( DataEngineContext.MODE_UPDATE,
+ null,
+ reader,
+ writer ) );
+
+ engine = (DataEngineImpl) DataEngine.newDataEngine( DataEngineContext.newInstance( DataEngineContext.MODE_UPDATE,
+ null,
+ reader,
+ writer ) );
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ ConditionalExpression expression = new ConditionalExpression( "data[\"measure1\"]",
+ IConditionalExpression.OP_GT,
+ "\"18\"" );
+ ( (ScriptExpression) expression.getOperand1( ) ).setConstantValue( "18" );
+ ( (ScriptExpression) expression.getOperand1( ) ).setConstant( true );
+
+ FilterDefinition fd = new CubeFilterDefinition(expression );
+ fd.setUpdateAggregation(false);
+ cqd.addFilter(fd);
+
+ //this query should be applied increment execution
+ IncrementExecutionHint ieh = CubeQueryDefinitionUtil.getIncrementExecutionHint( savedQuery, cqd );
+
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ reader.close( );
+ writer.finish( );
+ engine.shutdown( );
+
+ //Load from RD
+ reader = new FileArchiveReader( documentPath + "testTemp" );
+ engine = (DataEngineImpl) DataEngine.newDataEngine( DataEngineContext.newInstance( DataEngineContext.MODE_PRESENTATION,
+ null,
+ reader,
+ null ) );
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ this.printCube( cursor, columnEdgeBindingNames, "edge2level1", "measure1" );
+
+ engine.shutdown( );
+ }
+
+ public void testIVWithIncrementNoAggrUpdateFilter2( ) throws Exception
+ {
+ ICubeQueryDefinition cqd = new CubeQueryDefinition( cubeName);
+ IEdgeDefinition columnEdge = cqd.createEdge( ICubeQueryDefinition.COLUMN_EDGE );
+ IEdgeDefinition rowEdge = cqd.createEdge( ICubeQueryDefinition.ROW_EDGE );
+ IDimensionDefinition dim1 = columnEdge.createDimension( "dimension1" );
+ IHierarchyDefinition hier1 = dim1.createHierarchy( "dimension1" );
+ hier1.createLevel( "level11" );
+ hier1.createLevel( "level12" );
+ hier1.createLevel( "level13" );
+
+ IDimensionDefinition dim2 = rowEdge.createDimension( "dimension2" );
+ IHierarchyDefinition hier2 = dim2.createHierarchy( "dimension2" );
+ hier2.createLevel( "level21" );
+
+ cqd.createMeasure( "measure1" );
+
+ IBinding binding1 = new Binding( "edge1level1");
+
+ binding1.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level11\"]") );
+ cqd.addBinding( binding1 );
+
+ IBinding binding2 = new Binding( "edge1level2");
+
+ binding2.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level12\"]") );
+ cqd.addBinding( binding2 );
+
+ IBinding binding3 = new Binding( "edge1level3");
+
+ binding3.setExpression( new ScriptExpression("dimension[\"dimension1\"][\"level13\"]") );
+ cqd.addBinding( binding3 );
+
+ IBinding binding4 = new Binding( "edge2level1");
+
+ binding4.setExpression( new ScriptExpression("dimension[\"dimension2\"][\"level21\"]") );
+ cqd.addBinding( binding4 );
+
+ IBinding binding5 = new Binding( "measure1" );
+ binding5.setExpression( new ScriptExpression("measure[\"measure1\"]") );
+ binding5.setAggrFunction("SUM");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level11\"]");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level12\"]");
+ binding5.addAggregateOn("dimension[\"dimension1\"][\"level13\"]");
+ binding5.addAggregateOn("dimension[\"dimension2\"][\"level21\"]");
+ cqd.addBinding( binding5 );
+
+ cqd.setCacheQueryResults( true );
+ FileArchiveWriter writter = new FileArchiveWriter( documentPath + "testTemp" );
+ DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.MODE_GENERATION,
+ null,
+ null,
+ writter );
+ context.setTmpdir( this.getTempDir( ) );
+ DataEngineImpl engine = (DataEngineImpl)DataEngine.newDataEngine( context );
+ this.createCube( writter, engine );
+
+ IPreparedCubeQuery pcq = engine.prepare( cqd, null );
+ ICubeQueryResults queryResults = pcq.execute( null );
+ CubeCursor cursor = queryResults.getCubeCursor( );
+
+
+ //Load from cache.
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ writter.finish( );
+ engine.shutdown( );
+
+ List columnEdgeBindingNames = new ArrayList();
+ columnEdgeBindingNames.add( "edge1level1" );
+ columnEdgeBindingNames.add( "edge1level2" );
+ columnEdgeBindingNames.add( "edge1level3" );
+
+ FileArchiveReader reader = new FileArchiveReader( documentPath + "testTemp" );
+ ArchiveWriter writer = new ArchiveWriter( new ArchiveFile(documentPath + "testTemp", "rw+") );
+
+ ICubeQueryDefinition savedQuery = CubeQueryDefinitionIOUtil.load( queryResults.getID( ), DataEngineContext.newInstance( DataEngineContext.MODE_UPDATE,
+ null,
+ reader,
+ writer ) );
+
+ engine = (DataEngineImpl) DataEngine.newDataEngine( DataEngineContext.newInstance( DataEngineContext.MODE_UPDATE,
+ null,
+ reader,
+ writer ) );
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ ConditionalExpression expression = new ConditionalExpression( "data[\"edge2level1\"]",
+ IConditionalExpression.OP_GT,
+ "\"1999\"" );
+ ( (ScriptExpression) expression.getOperand1( ) ).setConstantValue( "1999" );
+ ( (ScriptExpression) expression.getOperand1( ) ).setConstant( true );
+
+ FilterDefinition fd = new CubeFilterDefinition(expression );
+ fd.setUpdateAggregation(false);
+ ((CubeFilterDefinition)fd).setTargetLevel(cqd.getEdge(ICubeQueryDefinition.ROW_EDGE).getDimensions().get(0).getHierarchy().get(0).getLevels().get(0));
+ cqd.addFilter(fd);
+
+ //this query should be applied increment execution
+ IncrementExecutionHint ieh = CubeQueryDefinitionUtil.getIncrementExecutionHint( savedQuery, cqd );
+
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ reader.close( );
+ writer.finish( );
+ engine.shutdown( );
+
+ //Load from RD
+ reader = new FileArchiveReader( documentPath + "testTemp" );
+ engine = (DataEngineImpl) DataEngine.newDataEngine( DataEngineContext.newInstance( DataEngineContext.MODE_PRESENTATION,
+ null,
+ reader,
+ null ) );
+ cqd.setQueryResultsID( queryResults.getID( ) );
+ pcq = engine.prepare( cqd, null );
+ queryResults = pcq.execute( null );
+ cursor = queryResults.getCubeCursor( );
+
+ this.printCube( cursor, columnEdgeBindingNames, "edge2level1", "measure1" );
+
+ engine.shutdown( );
+ }
}
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter1.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter1.txt
new file mode 100644
index 0000000..9887f34
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter1.txt
@@ -0,0 +1,9 @@
+
+ CN CN CN JP JP UN UN US US US
+ BJ SZ SZ IL TK LD LP CS LA NY
+ CP S1 S2 P1 F1 D1 E1 B1 A1 C1
+1998 null 21.0 26.0 61.0 56.0 46.0 51.0 36.0 31.0 41.0
+1999 null 22.0 27.0 62.0 57.0 47.0 52.0 37.0 32.0 42.0
+2000 null 23.0 28.0 63.0 58.0 48.0 53.0 38.0 33.0 43.0
+2001 19.0 24.0 29.0 65.0 59.0 49.0 54.0 39.0 34.0 44.0
+2002 20.0 25.0 30.0 65.0 60.0 50.0 55.0 40.0 35.0 45.0 \ No newline at end of file
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter2.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter2.txt
new file mode 100644
index 0000000..11c2eba
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeIVTest.testIVWithIncrementNoAggrUpdateFilter2.txt
@@ -0,0 +1,7 @@
+
+ CN CN CN CN CN CN JP JP UN UN US US US
+ BJ BJ SH SH SZ SZ IL TK LD LP CS LA NY
+ CP HD PD ZJ S1 S2 P1 F1 D1 E1 B1 A1 C1
+2000 18.0 13.0 3.0 8.0 23.0 28.0 63.0 58.0 48.0 53.0 38.0 33.0 43.0
+2001 19.0 14.0 4.0 9.0 24.0 29.0 65.0 59.0 49.0 54.0 39.0 34.0 44.0
+2002 20.0 15.0 5.0 10.0 25.0 30.0 65.0 60.0 50.0 55.0 40.0 35.0 45.0 \ No newline at end of file
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java
index ebbf953..aa90d35 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java
@@ -542,4 +542,13 @@ public class CachedAggregationResultSet implements IAggregationResultSet
this.ad = ad;
}
+ public IDiskArray getAggregationResultRows( )
+ {
+ return this.aggregationResultRow;
+ }
+
+ public void setAggregationResultRows( IDiskArray rows)
+ {
+ this.aggregationResultRow = rows;
+ }
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/filter/AggregationFilterHelper.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/filter/AggregationFilterHelper.java
index acc166b..b0fd23a 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/filter/AggregationFilterHelper.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/filter/AggregationFilterHelper.java
@@ -347,7 +347,7 @@ public class AggregationFilterHelper
public IAggregationResultSet[] generateFilteredAggregationResultSet ( IAggregationResultSet[] rs,List<Integer> affectedAggrResultSetIndex ) throws IOException, DataException
{
- IAggregationResultSet[] result = new AggregationResultSet[rs.length];
+ IAggregationResultSet[] result = new IAggregationResultSet[rs.length];
List levelFilterList = new ArrayList( );
for ( int i = 0; i < rs.length; i++ )
{
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionUtil.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionUtil.java
index a50f6ba..83a5de1 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionUtil.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionUtil.java
@@ -5,6 +5,7 @@
*******************************************************************************/
package org.eclipse.birt.data.engine.olap.impl.query;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -19,6 +20,7 @@ import org.eclipse.birt.data.engine.api.timefunction.ITimeFunction;
import org.eclipse.birt.data.engine.api.timefunction.ITimePeriod;
import org.eclipse.birt.data.engine.api.timefunction.TimePeriodType;
import org.eclipse.birt.data.engine.core.DataException;
+import org.eclipse.birt.data.engine.expression.ExpressionCompilerUtil;
import org.eclipse.birt.data.engine.impl.document.ExprUtil;
import org.eclipse.birt.data.engine.olap.api.query.IComputedMeasureDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeFilterDefinition;
@@ -31,6 +33,7 @@ import org.eclipse.birt.data.engine.olap.api.query.IEdgeDrillFilter;
import org.eclipse.birt.data.engine.olap.api.query.IHierarchyDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ILevelDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IMeasureDefinition;
+import org.eclipse.birt.data.engine.script.ScriptConstants;
import com.ibm.icu.util.ULocale;
@@ -153,21 +156,41 @@ public class CubeQueryDefinitionUtil
{
return null;
}
- Iterator<IFilterDefinition> itr1 = basedQuery.getFilters( ).iterator( );
- Iterator<IFilterDefinition> itr2 = newQuery.getFilters( ).iterator( );
- while ( itr1.hasNext( ) )
+ List baseFilters = basedQuery.getFilters();
+ List newFilters = newQuery.getFilters();
+
+ List<IFilterDefinition> resultFilters = new ArrayList<IFilterDefinition>();
+ for (int i = 0; i < newFilters.size(); i++)
{
- if ( !isEqual( itr1.next( ), itr2.next( )))
+ IFilterDefinition filter = (IFilterDefinition)newFilters.get(i);
+ boolean find = false;
+ for (int j = 0; j < baseFilters.size(); j++)
{
- return null;
+ if (isEqual((IFilterDefinition) newFilters.get(i),
+ (IFilterDefinition) baseFilters.get(j)))
+ {
+ find = true;
+ break;
+ }
}
+ if( !find )
+ {
+ if (!filter.updateAggregation())
+ {
+ if (ExpressionCompilerUtil.extractColumnExpression(
+ ((IFilterDefinition) filter).getExpression(),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE).size() > 0)
+ {
+ resultFilters.add(filter);
+ }
+ }
+ else
+ return null;
+ }
+
}
- if ( itr2.hasNext( ) )
- {
- //currently, can't apply increment execution for new added filters
- return null;
- }
- return new IFilterDefinition[0];
+
+ return resultFilters.toArray(new IFilterDefinition[0]);
}
private static ISortDefinition[] getIncrementSorts( ICubeQueryDefinition basedQuery,
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
index ac93ddc..bb40b45 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
@@ -293,7 +293,8 @@ public class CubeQueryExecutor
IFilterDefinition filter = (IFilterDefinition) filters.get( i );
if ( !filter.updateAggregation( ) )
{
- continue;
+ if ( ExpressionCompilerUtil.extractColumnExpression( filter.getExpression( ), ScriptConstants.DATA_BINDING_SCRIPTABLE ).size()>0 )
+ continue;
}
switch ( this.getFilterType( filter, dimLevelInCubeQuery ))
{
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
index 44aee6e..0bf5301 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
@@ -29,6 +29,7 @@ import org.eclipse.birt.data.engine.api.IFilterDefinition;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.core.security.FileSecurity;
import org.eclipse.birt.data.engine.executor.cache.CacheUtil;
+import org.eclipse.birt.data.engine.expression.ExpressionCompilerUtil;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.eclipse.birt.data.engine.impl.StopSign;
import org.eclipse.birt.data.engine.impl.document.stream.VersionManager;
@@ -57,6 +58,7 @@ import org.eclipse.birt.data.engine.olap.data.impl.aggregation.sort.AggrSortDefi
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.sort.ITargetSort;
import org.eclipse.birt.data.engine.olap.data.impl.dimension.Member;
import org.eclipse.birt.data.engine.olap.data.util.BufferedStructureArray;
+import org.eclipse.birt.data.engine.olap.data.util.CompareUtil;
import org.eclipse.birt.data.engine.olap.data.util.IDiskArray;
import org.eclipse.birt.data.engine.olap.driver.CubeResultSet;
import org.eclipse.birt.data.engine.olap.driver.IResultSet;
@@ -155,7 +157,7 @@ public class QueryExecutor
rs = populateRs( view, finalAggregation, cubeQueryExecutorHelper,
stopSign,
true, fetcher );
- rs = applyNoAggrUpdateFilters( executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ),executor, rs, cube, fetcher );
rs = processOperationOnQuery( view, stopSign, rs, aggrDefns );
break;
@@ -164,7 +166,7 @@ public class QueryExecutor
{
rs = populateRs( view, finalAggregation, cubeQueryExecutorHelper,
stopSign, false, fetcher );
- rs = applyNoAggrUpdateFilters( executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher );
rs = processOperationOnQuery( view, stopSign, rs, aggrDefns );
break;
@@ -190,7 +192,7 @@ public class QueryExecutor
else
{
rs = cubeQueryExecutorHelper.execute( finalAggregation, stopSign );
- rs = applyNoAggrUpdateFilters( executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters(getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
@@ -226,7 +228,7 @@ public class QueryExecutor
{
//need to re-execute the query.
rs = cubeQueryExecutorHelper.execute( finalAggregation, stopSign );
- rs = applyNoAggrUpdateFilters( executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters(getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
@@ -243,8 +245,17 @@ public class QueryExecutor
//Restore{@code AggregationDefinition} info first which are lost during saving aggregation result sets
initLoadedAggregationResultSets( rs, finalAggregation );
-
incrementExecute( rs, ieh );
+ if (ieh.getFilters() != null && ieh.getFilters().length > 0)
+ {
+ IFilterDefinition[] filters =ieh.getFilters();
+ List finalFilters = new ArrayList();
+ for(int j = 0 ; j < filters.length;j++)
+ {
+ finalFilters.add(filters[j]);
+ }
+ rs = applyNoAggrUpdateFilters(finalFilters,executor, rs, cube, fetcher);
+ }
}
if ( executor.getContext( ).getDocWriter( ) != null )
{
@@ -273,9 +284,8 @@ public class QueryExecutor
return new CubeResultSet( rs, view, cubeQueryExecutorHelper );
}
- private IAggregationResultSet[] applyNoAggrUpdateFilters ( CubeQueryExecutor executor , IAggregationResultSet[] rs , ICube cube, IBindingValueFetcher fetcher ) throws DataException, IOException
+ private IAggregationResultSet[] applyNoAggrUpdateFilters ( List finalFilters, CubeQueryExecutor executor , IAggregationResultSet[] rs , ICube cube, IBindingValueFetcher fetcher ) throws DataException, IOException
{
- List finalFilters = getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) );
if( !finalFilters.isEmpty( ) )
{
List aggrEvalList = new ArrayList<AggrMeasureFilterEvalHelper>( );
@@ -347,7 +357,7 @@ public class QueryExecutor
{
for (int i = 0; i < detailLevelKeys.length; i++)
{
- if (joinLevelKeys[0].equals( detailLevelKeys[i] ))
+ if (CompareUtil.compare(joinLevelKeys[0], detailLevelKeys[i] )==0)
{
return i;
}
@@ -382,7 +392,7 @@ public class QueryExecutor
{
break;
}
- if (joinLevelKeys[j - pos].equals( detailLevelKeys[j] ))
+ if (CompareUtil.compare(joinLevelKeys[j - pos], detailLevelKeys[j] )==0)
{
tmpMembers.add (members[j]);
}
@@ -391,8 +401,10 @@ public class QueryExecutor
detailMember.add( new Members(tmpMembers.toArray( new Member[]{} )) );
}
Collections.sort( detailMember );
-
- aggregationResultRows = ((AggregationResultSet)joinRS).getAggregationResultRows();
+ if( joinRS instanceof AggregationResultSet )
+ aggregationResultRows = ((AggregationResultSet)joinRS).getAggregationResultRows();
+ else if( joinRS instanceof CachedAggregationResultSet )
+ aggregationResultRows = ((CachedAggregationResultSet)joinRS).getAggregationResultRows();
IDiskArray newRsRows = new BufferedStructureArray(AggregationResultRow.getCreator( ), aggregationResultRows.size( ));
int result;
for (int index = 0; index < joinRS.length( ); index++)
@@ -405,7 +417,10 @@ public class QueryExecutor
newRsRows.add(aggregationResultRows.get( index ));
}
}
- ((AggregationResultSet)joinRS).setAggregationResultRows( newRsRows );
+ if( joinRS instanceof AggregationResultSet )
+ ((AggregationResultSet)joinRS).setAggregationResultRows(newRsRows);
+ else if( joinRS instanceof CachedAggregationResultSet )
+ ((CachedAggregationResultSet)joinRS).setAggregationResultRows(newRsRows);
detailMember.clear( );
}
@@ -441,7 +456,23 @@ public class QueryExecutor
for ( int i = 0; i < filters.size( ); i++ )
{
if ( !( (IFilterDefinition) filters.get( i ) ).updateAggregation( ) )
- NoAggrUpdateFilters.add( filters.get( i ) );
+ {
+ try
+ {
+ if (ExpressionCompilerUtil
+ .extractColumnExpression(
+ ((IFilterDefinition) filters.get(i))
+ .getExpression(),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE)
+ .size() > 0)
+ {
+ NoAggrUpdateFilters.add(filters.get(i));
+ }
+ }
+ catch (DataException e)
+ {
+ }
+ }
}
return NoAggrUpdateFilters;
}
@@ -730,7 +761,7 @@ public class QueryExecutor
CubeQueryExecutor executor = view.getCubeQueryExecutor( );
rs = cubeQueryExecutorHelper.execute( aggrDefns, executor.getSession( ).getStopSign( ) );
- rs = applyNoAggrUpdateFilters( executor, rs, view.getCube( ) , fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ),executor, rs, view.getCube( ) , fetcher );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
rs = moe.execute( rs, view, cubeQueryExecutorHelper );