Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
   Revised RolapResult evaluation algorithm and the CrossJoin non-empty
   optimization algorithm.
   The CrossJoin change was to make the optimizer less optimistic so that
   it would include values that occur in corner cases. It also
   cached information between invocations.
   Added ability for Calc's to cache evaluation data in the Query object.
   Made the ResultLimit check also work when an Iterable, rather than a
   List, is used to generate the RolapAxis object.
   Enable test RolapResultTest.java testD2

[git-p4: depot-paths = "//open/mondrian/": change = 8900]
  • Loading branch information
Richard Emberson committed Mar 20, 2007
1 parent 6f13de8 commit 493ae4a
Show file tree
Hide file tree
Showing 12 changed files with 1,159 additions and 363 deletions.
21 changes: 0 additions & 21 deletions doc/configuration.html
Expand Up @@ -359,27 +359,6 @@ <h3>1.1 Property list<a name="Property_list">&nbsp;</a></h3>
will never be applied.
</td>
</tr>
<tr>
<td>
<code>
<a href="api/mondrian/olap/MondrianProperties.html#UseImplicitMembers">mondrian.rolap.RolapResult.useImplicitMembers</a></code></td>
<td>boolean</td>
<td>true</td>
<td>
The crossjoin optimizer is flawed. It evaluates potential cells
using default members when a member is not explicitly set in
the particular axis. This works unless another axis, normal or
slicer, uses a member other than the default.
Setting this property to <code>true</code> will enable the
RolapResult to collect these implied members and if any are
found, then re-evaluate using the discovered members.
<p>
If you do not enable this property, then the crossjoin optimizer,
if used, can produce errors. Bad results are produced for some
queries and some data sets - its a combination of both so the
error does not manifest itself all the time.
</td>
</tr>
<tr>
<td colspan="4">

Expand Down
6 changes: 5 additions & 1 deletion src/main/mondrian/calc/impl/GenericCalc.java
Expand Up @@ -73,7 +73,11 @@ public String evaluateString(Evaluator evaluator) {
}

public int evaluateInteger(Evaluator evaluator) {
return ((Number) evaluate(evaluator)).intValue();
Object o = evaluate(evaluator);
final Number number = (Number) o;
return number == null ?
FunUtil.IntegerNull :
number.intValue();
}

public double evaluateDouble(Evaluator evaluator) {
Expand Down
24 changes: 5 additions & 19 deletions src/main/mondrian/olap/MondrianProperties.java
Expand Up @@ -495,10 +495,10 @@ public Property getPropertyDefinition(String path) {
* The <code>density</code> is <code>actual / possible</code>.
*
* <p>We use a sparse representation if
* <code>(possible -
* {@link #SparseSegmentCountThreshold countThreshold}) *
* {@link #SparseSegmentDensityThreshold densityThreshold} &gt;
* actual</code>
* <code>possible -
* {@link #SparseSegmentCountThreshold countThreshold} *
* actual &gt;
* {@link #SparseSegmentDensityThreshold densityThreshold}</code>
*
* <p>For example, at the default values
* ({@link #SparseSegmentCountThreshold countThreshold} = 1000,
Expand Down Expand Up @@ -920,23 +920,9 @@ public Property getPropertyDefinition(String path) {
*/
public final IntegerProperty CrossJoinOptimizerSize = new IntegerProperty(
this, "mondrian.olap.fun.crossjoin.optimizer.size", 0);

/**
* The crossjoin optimizer is flawed. It evaluates potential cells
* using default members when a member is not explicitly set in
* the particular axis. This works unless another axis, normal or
* slicer, uses a member other than the default.
* Setting this property to <code>true</code> will enable the
* RolapResult to collect these implied members and if any are
* found, then re-evaluate using the discovered members.
* <p>
* If you do not enable this property, then the crossjoin optimizer,
* if used, can produce errors. Bad results are produced for some
* queries and some data sets - its a combination of both so the
* error does not manifest itself all the time.
*/
public final BooleanProperty UseImplicitMembers = new BooleanProperty(
this, "mondrian.rolap.RolapResult.useImplicitMembers", true);

}

// End MondrianProperties.java
43 changes: 36 additions & 7 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -170,6 +170,9 @@ public class Query extends QueryPart {
private ResultStyle resultStyle = (Util.PreJdk15)
? ResultStyle.LIST : ResultStyle.ITERABLE;


private Map<String, Object> evalCache = new HashMap<String, Object>();

/**
* Creates a Query.
*/
Expand Down Expand Up @@ -1015,26 +1018,23 @@ public void addMeasuresMembers(OlapElement olapElement)
* @return set of members from the measures dimension referenced within
* this query
*/
public Set<Member> getMeasuresMembers()
{
return measuresMembers;
public Set<Member> getMeasuresMembers() {
return Collections.unmodifiableSet(measuresMembers);
}

/**
* Indicates that the query cannot use native cross joins to process
* this virtual cube
*/
public void setVirtualCubeNonNativeCrossJoin()
{
public void setVirtualCubeNonNativeCrossJoin() {
nativeCrossJoinVirtualCube = false;
}

/**
* @return true if the query can use native cross joins on a virtual
* cube
*/
public boolean nativeCrossJoinVirtualCube()
{
public boolean nativeCrossJoinVirtualCube() {
return nativeCrossJoinVirtualCube;
}

Expand Down Expand Up @@ -1095,6 +1095,35 @@ public Object accept(MdxVisitor visitor) {
return o;
}

/**
* Put an Object value into the evaluation cache with given key.
* This is used by Calc's to store information between iterations
* (rather than re-generate each time).
*
* @param key the cache key
* @param value the cache value
*/
public void putEvalCache(String key, Object value) {
evalCache.put(key, value);
}

/**
* Get the Object associated with the value.
*
* @param key the cache key
* @return the cached value or null.
*/
public Object getEvalCache(String key) {
return evalCache.get(key);
}

/**
* Remove all entries in the evaluation cache
*/
public void clearEvalCache() {
evalCache.clear();
}

/**
* Default implementation of {@link Validator}.
*
Expand Down

0 comments on commit 493ae4a

Please sign in to comment.