summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2012-03-29 02:40:17 (EDT)
committer mwu2012-03-29 02:40:17 (EDT)
commit4e15174baf5b82437e13cef9f0ee14a235a31580 (patch)
tree6a877417880f783f8c5ade794be737a77a349602
parentee4e5e1be8b57ad7442e96ba160a248dfe5e8b5d (diff)
downloadorg.eclipse.birt-4e15174baf5b82437e13cef9f0ee14a235a31580.zip
org.eclipse.birt-4e15174baf5b82437e13cef9f0ee14a235a31580.tar.gz
org.eclipse.birt-4e15174baf5b82437e13cef9f0ee14a235a31580.tar.bz2
In some case,filter on computed measure don't work [48324]
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/CachedAggregationResultSet.java5
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryResults.java10
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java102
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/BaseDimensionFilterEvalHelper.java12
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/DimensionFilterEvalHelper.java31
5 files changed, 109 insertions, 51 deletions
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 aa90d35..c2786a2 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
@@ -216,6 +216,11 @@ public class CachedAggregationResultSet implements IAggregationResultSet
return this.attributeDataTypes[levelIndex][getLevelAttributeIndex( level,
attributeName )];
}
+
+ public void setLength( int length)
+ {
+ this.length = length;
+ }
/*
* (non-Javadoc)
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryResults.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryResults.java
index 6b60e41..cfe43ef 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryResults.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryResults.java
@@ -384,6 +384,16 @@ public class CubeQueryResults implements ICubeQueryResults
{
if( cubeQuery.getQueryResultsID( )!= null && context.getMode( ) == DataEngineContext.MODE_PRESENTATION )
{
+ List filters = cubeQuery.getFilters( );
+ if ( filters != null && filters.size( ) > 0)
+ {
+ for ( int i = 0; i < filters.size( ); i++ )
+ {
+ IFilterDefinition def = (IFilterDefinition) filters.get( i );
+ if ( !def.updateAggregation( ) )
+ return false;
+ }
+ }
return true;
}
return false;
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 94d363d..3874cf0 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
@@ -38,6 +38,7 @@ import org.eclipse.birt.data.engine.executor.cache.CacheUtil;
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;
+import org.eclipse.birt.data.engine.olap.api.query.ICubeOperation;
import org.eclipse.birt.data.engine.olap.api.query.ICubeQueryDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeSortDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IEdgeDefinition;
@@ -67,6 +68,7 @@ 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;
+import org.eclipse.birt.data.engine.olap.impl.query.AddingNestAggregations;
import org.eclipse.birt.data.engine.olap.impl.query.CubeOperationsExecutor;
import org.eclipse.birt.data.engine.olap.impl.query.CubeQueryDefinitionIOUtil;
import org.eclipse.birt.data.engine.olap.impl.query.CubeQueryExecutor;
@@ -165,7 +167,7 @@ public class QueryExecutor
rs = populateRs( view, finalAggregation, cubeQueryExecutorHelper,
stopSign,
true, fetcher );
- rs = processOperationOnQuery( view, stopSign, rs, aggrDefns );
+ rs = processOperationOnQuery( executor, view, stopSign, rs, aggrDefns , fetcher );
break;
}
@@ -173,7 +175,7 @@ public class QueryExecutor
{
rs = populateRs( view, finalAggregation, cubeQueryExecutorHelper,
stopSign, false, fetcher );
- rs = processOperationOnQuery( view, stopSign, rs, aggrDefns );
+ rs = processOperationOnQuery( executor, view, stopSign, rs, aggrDefns , fetcher );
break;
}
@@ -189,26 +191,20 @@ public class QueryExecutor
cubeQueryExecutorHelper.getMemoryCacheSize( ) );
initLoadedAggregationResultSets( rs, finalAggregation );
- rs = processOperationOnQuery( view,
- stopSign,
- rs,
- aggrDefns );
+ rs = processOperationOnQuery( executor, view, stopSign, rs, aggrDefns , fetcher );
break;
}
else
{
rs = cubeQueryExecutorHelper.execute( finalAggregation, stopSign );
- rs = applyNoAggrUpdateFilters(getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher, false );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
rs = moe.execute( rs, view, cubeQueryExecutorHelper );
validateLimitSetting( view, rs );
- rs = processOperationOnQuery( view,
- stopSign,
- rs,
- aggrDefns );
+ rs = processOperationOnQuery( executor, view, stopSign, rs, aggrDefns ,fetcher );
break;
}
@@ -234,7 +230,7 @@ public class QueryExecutor
{
//need to re-execute the query.
rs = cubeQueryExecutorHelper.execute( finalAggregation, stopSign );
- rs = applyNoAggrUpdateFilters(getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ), executor, rs, cube, fetcher, false );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
@@ -260,7 +256,7 @@ public class QueryExecutor
{
finalFilters.add(filters[j]);
}
- rs = applyNoAggrUpdateFilters(finalFilters,executor, rs, cube, fetcher);
+ rs = applyNoAggrUpdateFilters( finalFilters,executor, rs, cube, fetcher, false );
}
}
if ( executor.getContext( ).getDocWriter( ) != null )
@@ -280,17 +276,15 @@ public class QueryExecutor
executor.setQueryResultsId( id );
}
- rs = processOperationOnQuery( view,
- stopSign,
- rs,
- aggrDefns );
+ rs = processOperationOnQuery( executor,view, stopSign, rs, aggrDefns , fetcher );
+
}
}
return new CubeResultSet( rs, view, cubeQueryExecutorHelper );
}
- private IAggregationResultSet[] applyNoAggrUpdateFilters ( List finalFilters, CubeQueryExecutor executor , IAggregationResultSet[] rs , ICube cube, IBindingValueFetcher fetcher ) throws DataException, IOException
+ private IAggregationResultSet[] applyNoAggrUpdateFilters ( List finalFilters, CubeQueryExecutor executor , IAggregationResultSet[] rs , ICube cube, IBindingValueFetcher fetcher,boolean fromCubeOperation ) throws DataException, IOException
{
if( !finalFilters.isEmpty( ) )
{
@@ -300,6 +294,31 @@ public class QueryExecutor
for ( int i = 0; i < finalFilters.size( ); i++ )
{
IFilterDefinition filter = (IFilterDefinition) finalFilters.get( i );
+ boolean find = false;
+ String bindingName = OlapExpressionCompiler.getReferencedScriptObject(filter.getExpression(), ScriptConstants.DATA_BINDING_SCRIPTABLE );
+ if(executor.getCubeQueryDefinition().getCubeOperations().length>0)
+ {
+ ICubeOperation[] operations = executor.getCubeQueryDefinition().getCubeOperations();
+ for( int j = 0 ; j < operations.length;j++)
+ {
+ if ( operations[j] instanceof AddingNestAggregations )
+ {
+ AddingNestAggregations aggr = (AddingNestAggregations)operations[i];
+ IBinding[] bindings = aggr.getNewBindings();
+ for(int k = 0 ; k<bindings.length;k++)
+ {
+ if(bindings[k].getBindingName().equals(bindingName))
+ {
+ find = true;
+ break;
+ }
+ }
+ }
+ }
+
+ }
+ if( find != fromCubeOperation )
+ continue;
int type = executor.getFilterType( filter,
executor.getDimLevelsDefinedInCubeQuery( ) );
@@ -373,7 +392,7 @@ public class QueryExecutor
{
edgeResultSet.add( rs[i] );
- if( edgeDrillFilterMap.isEmpty() )
+ if( edgeDrillFilterMap == null || edgeDrillFilterMap.isEmpty() )
continue;
filterEdgeAggrSet(edgeDrillFilterMap, rs[i]);
@@ -414,7 +433,10 @@ public class QueryExecutor
if( edgeAggrSet instanceof AggregationResultSet )
((AggregationResultSet)edgeAggrSet).setAggregationResultRows( newRs );
else if( edgeAggrSet instanceof CachedAggregationResultSet )
+ {
((CachedAggregationResultSet)edgeAggrSet).setAggregationResultRows( newRs );
+ ((CachedAggregationResultSet)edgeAggrSet).setLength(newRs.size());
+ }
}
/**
@@ -484,8 +506,13 @@ public class QueryExecutor
IDiskArray aggregationResultRows = null;
joinLevelKeys = joinRS.getLevelKeys( );
+
+ if( detailLevelKeys == null )
+ return;
int pos = getPos(joinLevelKeys, detailLevelKeys);
+ if( pos < 0 )
+ return;
for (int index = 0; index < detailRS.length( ); index++)
{
@@ -718,9 +745,9 @@ public class QueryExecutor
return false;
}
- private IAggregationResultSet[] processOperationOnQuery( BirtCubeView view,
+ private IAggregationResultSet[] processOperationOnQuery( CubeQueryExecutor executor,BirtCubeView view,
StopSign stopSign, IAggregationResultSet[] rs,
- AggregationDefinition[] aggrDefns ) throws DataException,
+ AggregationDefinition[] aggrDefns,IBindingValueFetcher fetcher ) throws DataException,
IOException, BirtException
{
//process drill operation
@@ -745,7 +772,38 @@ public class QueryExecutor
view.getCubeQueryExecutor( ).getScope( ),
view.getCubeQueryExecutor( ).getSession( ).getEngineContext( ).getScriptContext( ));
+ int rsLenBefore = rs.length;
rs = coe.execute( rs, stopSign );
+ int rsLenAfter = rs.length;
+
+ if (rsLenBefore != rsLenAfter)
+ {
+ IAggregationResultSet[] result = new IAggregationResultSet[rsLenAfter- rsLenBefore];
+
+ for (int i = 0; i < result.length; i++)
+ {
+ result[i] = rs[rsLenBefore + i];
+ }
+
+ result = applyNoAggrUpdateFilters(getNoAggrUpdateFilters(executor
+ .getCubeQueryDefinition().getFilters()), executor, result,
+ view.getCube(), fetcher, true);
+
+ for (int i = 0; i < result.length; i++)
+ {
+ rs[i + rsLenBefore] = result[i];
+ }
+
+ List<IAggregationResultSet> edgeResultSet = populateAndFilterEdgeResultSet(rs, null);
+
+ for (int i = 0; i < edgeResultSet.size(); i++)
+ {
+ for (int j = 0; j < result.length; j++)
+ {
+ this.applyJoin(edgeResultSet.get(i), result[j]);
+ }
+ }
+ }
return rs;
}
@@ -854,7 +912,7 @@ public class QueryExecutor
CubeQueryExecutor executor = view.getCubeQueryExecutor( );
rs = cubeQueryExecutorHelper.execute( aggrDefns, executor.getSession( ).getStopSign( ) );
- rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ),executor, rs, view.getCube( ) , fetcher );
+ rs = applyNoAggrUpdateFilters( getNoAggrUpdateFilters( executor.getCubeQueryDefinition( ).getFilters( ) ),executor, rs, view.getCube( ) , fetcher , false );
//process mirror operation
MirrorOperationExecutor moe = new MirrorOperationExecutor( );
rs = moe.execute( rs, view, cubeQueryExecutorHelper );
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/BaseDimensionFilterEvalHelper.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/BaseDimensionFilterEvalHelper.java
index 32120b9..c87337a 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/BaseDimensionFilterEvalHelper.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/BaseDimensionFilterEvalHelper.java
@@ -12,7 +12,6 @@
package org.eclipse.birt.data.engine.olap.util.filter;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -25,7 +24,6 @@ import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.eclipse.birt.data.engine.olap.api.query.CubeFilterDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeFilterDefinition;
-import org.eclipse.birt.data.engine.olap.api.query.ICubeOperation;
import org.eclipse.birt.data.engine.olap.api.query.ICubeQueryDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IDimensionDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IEdgeDefinition;
@@ -161,15 +159,7 @@ public abstract class BaseDimensionFilterEvalHelper extends DimensionJSEvalHelpe
private DimLevel[] getAggregateOnLevels( String bindingName )
throws DataException
{
- List<IBinding> bindingList = new ArrayList<IBinding>( );
- bindingList.addAll( queryDefn.getBindings( ) );
- ICubeOperation[] operations = queryDefn.getCubeOperations( );
- for( int i=0; i< operations.length; i++ )
- {
- IBinding[] b = queryDefn.getCubeOperations( )[i].getNewBindings( );
- bindingList.addAll( Arrays.asList( b ) );
- }
- for ( Iterator it = bindingList.iterator( ); it.hasNext( ); )
+ for ( Iterator it = queryDefn.getBindings( ).iterator( ); it.hasNext( ); )
{
IBinding binding = (IBinding) it.next( );
if ( binding.getBindingName( ).equals( bindingName ) )
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/DimensionFilterEvalHelper.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/DimensionFilterEvalHelper.java
index 0e89758..8742dd8 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/DimensionFilterEvalHelper.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/util/filter/DimensionFilterEvalHelper.java
@@ -46,17 +46,17 @@ BaseDimensionFilterEvalHelper implements IJSDimensionFilterHelper
}
- private boolean containsInAggrLevels( String level )
- {
- for ( DimLevel dimLevel : aggrLevels )
- {
- if ( dimLevel.getLevelName( ).equals( level ) )
- {
- return true;
- }
- }
- return false;
- }
+// private boolean containsInAggrLevels( String level )
+// {
+// for ( DimLevel dimLevel : aggrLevels )
+// {
+// if ( dimLevel.getLevelName( ).equals( level ) )
+// {
+// return true;
+// }
+// }
+// return false;
+// }
/* (non-Javadoc)
@@ -75,15 +75,10 @@ BaseDimensionFilterEvalHelper implements IJSDimensionFilterHelper
for ( int i = 0; i < axisLevels.length; i++ )
{
DimLevel level = new DimLevel( axisLevels[i] );
- if ( containsInAggrLevels( level.getLevelName( ) ) )
+ if ( CompareUtil.compare ( resultRow.getFieldValue(level.toString()), axisValues[i]) != 0)
{
- if ( CompareUtil.compare( resultRow.getFieldValue( level.toString( ) ),
- axisValues[i] ) != 0 )
- {
- return false;
- }
+ return false;
}
-
}
}
Object result = ScriptEvalUtil.evalExpr( expr, cx.newContext( scope ), ScriptExpression.defaultID, 0 );