Skip to content

Commit

Permalink
MONDRIAN: Fix for ClassCastException from Member[] to RolapMember[] c…
Browse files Browse the repository at this point in the history
…aused by high-card change (contributed by Timothy Lambert);

    Add support for running all tests with high-cardinality dimensions.

[git-p4: depot-paths = "//open/mondrian/": change = 11055]
  • Loading branch information
julianhyde committed May 13, 2008
1 parent 3b50bf1 commit 6597a07
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
36 changes: 17 additions & 19 deletions src/main/mondrian/rolap/HighCardSqlTupleReader.java
Expand Up @@ -15,7 +15,6 @@
import mondrian.rolap.sql.TupleConstraint;
import mondrian.util.*;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
Expand Down Expand Up @@ -160,13 +159,13 @@ public List<RolapMember[]> readTuples(

// List of tuples
final int n = targets.size();
final List<Member>[] lists = new List[n];
final List<RolapMember>[] lists = new List[n];
for (int i = 0; i < n; i++) {
lists[i] = (List) targets.get(i).close();
lists[i] = targets.get(i).close();
}

final List<Member[]> tupleList =
new TraversalList<Member>(lists, Member.class);
final List<RolapMember[]> tupleList =
new TraversalList<RolapMember>(lists, RolapMember.class);

// need to hierarchize the columns from the enumerated targets
// since we didn't necessarily add them in the order in which
Expand All @@ -175,7 +174,7 @@ public List<RolapMember[]> readTuples(
if (enumTargetCount > 0) {
FunUtil.hierarchize(tupleList, false);
}
return (List) tupleList;
return tupleList;
}

/**
Expand All @@ -187,24 +186,23 @@ public void noMoreRows() {

/**
* Reads next tuple notifing all internal targets.
*
* @return whether there are any more rows
*/
public boolean readNextTuple() {
if (!this.moreRows) {
return false;
} else {
try {
if (this.moreRows) {
this.moreRows = this.resultLoader.loadResult();
}
} catch (SQLException sqle) {
this.resultLoader.handle(sqle);
this.moreRows = false;
}
if (!this.moreRows) {
this.resultLoader.close();
}
return this.moreRows;
}
try {
this.moreRows = this.resultLoader.loadResult();
} catch (SQLException sqle) {
this.resultLoader.handle(sqle);
this.moreRows = false;
}
if (!this.moreRows) {
this.resultLoader.close();
}
return this.moreRows;
}

public void setMaxRows(int maxRows) {
Expand Down
44 changes: 43 additions & 1 deletion testsrc/main/mondrian/test/TestContext.java
Expand Up @@ -236,7 +236,17 @@ public synchronized final Connection getFoodMartConnection(
}

public Util.PropertyList getFoodMartConnectionProperties() {
return Util.parseConnectString(getDefaultConnectString());
final Util.PropertyList propertyList =
Util.parseConnectString(getDefaultConnectString());
if (MondrianProperties.instance().TestHighCardinalityDimensionList
.get() != null
&& propertyList.get(
RolapConnectionProperties.DynamicSchemaProcessor.name()) == null) {
propertyList.put(
RolapConnectionProperties.DynamicSchemaProcessor.name(),
HighCardDynamicSchemaProcessor.class.getName());
}
return propertyList;
}

/**
Expand Down Expand Up @@ -1371,6 +1381,38 @@ protected String filter(
return catalogContent;
}
}

/**
* Schema processor that flags dimensions as high-cardinality if they
* appear in the list of values in the
* {@link MondrianProperties#TestHighCardinalityDimensionList} property.
* It's a convenient way to run the whole suite against high-cardinality
* dimensions without modifying FoodMart.xml.
*/
public static class HighCardDynamicSchemaProcessor
extends FilterDynamicSchemaProcessor
{
protected String filter(
String schemaUrl, Util.PropertyList connectInfo, InputStream stream)
throws Exception
{
String s = super.filter(schemaUrl, connectInfo, stream);
final String highCardDimensionList =
MondrianProperties.instance()
.TestHighCardinalityDimensionList.get();
if (highCardDimensionList != null
&& !highCardDimensionList.equals(""))
{
for (String dimension : highCardDimensionList.split(",")) {
final String match =
"<Dimension name=\"" + dimension + "\"";
s = s.replaceAll(
match, match + " highCardinality=\"true\"");
}
}
return s;
}
}
}

// End TestContext.java

0 comments on commit 6597a07

Please sign in to comment.