Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
       The SqlMemberSource makeMember method creates a RolapMember
       given the parent RolapMember, child Level and Object value
       but the problem is there is no check that the new child
       member is a real, child member of the parent. The parent
       member [Time].[All Times].[2006] should not have a
       child member [Time].[All Times].[2006].[Q1 2004], as an
       example, but makeMembers returns it. Within
       the makeMember method there is not enough information
       to exclude such beasts (or at any rate I could not
       figure out how to filter them out). As a result there is
       what has to be a termed a hack in BuiltinFunTable 
       getNonEmptyMemberChildren method. I hope there is 
       enough information here to lead to a true fix.

[git-p4: depot-paths = "//open/mondrian/": change = 6837]
  • Loading branch information
Richard Emberson committed Jun 8, 2006
1 parent 977d980 commit b9ec175
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/main/mondrian/olap/fun/BuiltinFunTable.java
Expand Up @@ -2069,10 +2069,58 @@ public static BuiltinFunTable instance() {

protected Member[] getNonEmptyMemberChildren(Evaluator evaluator, Member member) {
SchemaReader sr = evaluator.getSchemaReader();
/*
RME: ORIGINAL CODE
if (evaluator.isNonEmpty()) {
return sr.getMemberChildren(member, evaluator);
}
return sr.getMemberChildren(member);
*/

// RME: This is a hack.
// The SqlMemberSource makeMember takes a parent member
// and all next level down elements and creates "children"
// of the parent member, i.e., with parent
// Time].[All Times].[2006] a child would be
// [Time].[All Times].[2006].[Q1 2004] which is clearly
// not a valid child member.
Member[] ms = null;
if (evaluator.isNonEmpty()) {
ms = sr.getMemberChildren(member, evaluator);
if (ms != null) {
org.eigenbase.util.property.IntegerProperty monLimit =
mondrian.olap.MondrianProperties.instance().ResultLimit;
int oldLimit = monLimit.get();
Member[] allms = null;
try {
monLimit.set(0);
allms = sr.getMemberChildren(member);
} finally {
monLimit.set(oldLimit);
}

// take intersection of both arrays
List l = new ArrayList();
for (int i = 0; i < ms.length; i++) {
Member m = ms[i];
boolean add = false;
for (int j = 0; j < allms.length; j++) {
Member x = allms[j];
if (m.getUniqueName().equals(x.getUniqueName())) {
add = true;
break;
}
}
if (add) {
l.add(m);
}
}
ms = (Member[]) l.toArray(new Member[0]);
}
} else {
ms = sr.getMemberChildren(member);
}
return ms;
}

/**
Expand Down

0 comments on commit b9ec175

Please sign in to comment.