Skip to content

Commit

Permalink
MONDRIAN-LAGUNITAS: Down to a mere 1227 test failures. Rename hierarc…
Browse files Browse the repository at this point in the history
…hies in

    NewFoodMart schema to be consistent with FoodMart 2005; e.g. the dimension
    is called 'Store', the hierarchy is 'Stores'. Lots of test & log changes for
    that.

[git-p4: depot-paths = "//open/mondrian-release/lagunitas/": change = 14589]
  • Loading branch information
julianhyde committed Sep 4, 2011
1 parent d0c2b13 commit e953659
Show file tree
Hide file tree
Showing 315 changed files with 25,135 additions and 24,256 deletions.
294 changes: 221 additions & 73 deletions demo/NewFoodMart.xml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/main/mondrian/olap/DimensionBase.java
Expand Up @@ -30,7 +30,7 @@ public abstract class DimensionBase
protected final String uniqueName;
protected final String description;
protected final List<Hierarchy> hierarchyList = new ArrayList<Hierarchy>();
protected DimensionType dimensionType;
protected final DimensionType dimensionType;

/**
* Creates a DimensionBase.
Expand All @@ -51,6 +51,7 @@ protected DimensionBase(
this.uniqueName = Util.makeFqName(name);
this.description = description;
this.dimensionType = dimensionType;
assert dimensionType != null;
}

public String getUniqueName() {
Expand Down
1 change: 1 addition & 0 deletions src/main/mondrian/olap/Hierarchy.java
Expand Up @@ -23,6 +23,7 @@ public interface Hierarchy extends OlapElement, Annotated {
* Returns the dimension this hierarchy belongs to.
*/
Dimension getDimension();

/**
* Returns the levels in this hierarchy.
*
Expand Down
22 changes: 12 additions & 10 deletions src/main/mondrian/olap/HierarchyBase.java
Expand Up @@ -52,6 +52,7 @@ public abstract class HierarchyBase
protected HierarchyBase(
Dimension dimension,
String subName,
String uniqueName,
boolean visible,
String caption,
String description,
Expand Down Expand Up @@ -79,28 +80,29 @@ protected HierarchyBase(
this.name = subName;
// e.g. "[Time].[Weekly]" for dimension "Time", hierarchy "Weekly";
// "[Time]" for dimension "Time", hierarchy "Time".
this.uniqueName =
subName.equals(name)
? dimension.getUniqueName()
: Util.makeFqName(dimension, this.name);
// this.uniqueName =
// subName.equals(name) && false
// ? dimension.getUniqueName()
// : Util.makeFqName(dimension, this.name);
} else {
this.subName = subName;
if (this.subName != null) {
// e.g. "Time.Weekly"
this.name = name + "." + subName;
if (this.subName.equals(name)) {
this.uniqueName = dimension.getUniqueName();
} else {
// if (this.subName.equals(name)) {
// this.uniqueName = dimension.getUniqueName();
// } else {
// e.g. "[Time.Weekly]"
this.uniqueName = Util.makeFqName(this.name);
}
// this.uniqueName = Util.makeFqName(this.name);
// }
} else {
// e.g. "Time"
this.name = name;
// e.g. "[Time]"
this.uniqueName = dimension.getUniqueName();
// this.uniqueName = dimension.getUniqueName();
}
}
this.uniqueName = uniqueName;
}

/**
Expand Down
46 changes: 42 additions & 4 deletions src/main/mondrian/olap/Mondrian4.xml
Expand Up @@ -166,6 +166,10 @@ Revision is $Id$
<Doc>Child element of a Table.</Doc>
</Class>

<Class class="InlineTableElement">
<Doc>Child element of an InlineTable.</Doc>
</Class>

<!-- Schema ========================================================== -->
<Element type="Schema">
<Doc>
Expand Down Expand Up @@ -579,7 +583,7 @@ Revision is $Id$
return children().only(MeasureGroups.EMPTY).toList();
}
public NamedList<CalculatedMember> getCalculatedMembers() {
return children().filterNamed(CalculatedMember.class);
return children().only(CalculatedMembers.EMPTY).toList();
}
public NamedList<NamedSet> getNamedSets() {
return children().filterNamed(NamedSet.class);
Expand Down Expand Up @@ -1609,16 +1613,50 @@ Revision is $Id$

<Element type="InlineTable" class="Relation">
<attribute name="alias" required="true"/>
<Array name="children" type="InlineTableElement">
<Doc>
Child elements of this Table.

<p>ColumnDefs (required):
Array of columns of this table.
Columns may be present only if the table is part of a
PhysicalSchema. They may be regular or calculated.</p>

<p>Key (optional):
Array of references to the columns that form the primary key
of this table. </p>

<p>Rows (required):
Rows in table. Maybe empty.</p>
</Doc>
</Array>
<Object name="columnDefs" type="ColumnDefs" required="true"/>
<Object name="rows" type="Rows" required="true"/>
<Code><![CDATA[
public String getAlias() {
return alias;
}
private Children children() {
return new Children(
InlineTableElement.class,
children,
ColumnDefs.class,
Rows.class,
Key.class);
}
public List<RealOrCalcColumnDef> getColumnDefs() {
return children().only(ColumnDefs.EMPTY).toList();
}
public List<Row> getRows() {
return children().only(Rows.EMPTY).toList();
}
public Key getKey() {
return children().singleton(Key.class);
}
]]></Code>
</Element>

<Element type="ColumnDefs" class="TableElement">
<Element type="ColumnDefs" class="TableElement,InlineTableElement">
<Doc>
Holder for an array of RealOrCalcColumnDef elements.
</Doc>
Expand Down Expand Up @@ -1688,7 +1726,7 @@ Revision is $Id$
<Object name="expression" type="Expression" required="true"/>
</Element>

<Element type="Rows">
<Element type="Rows" class="InlineTableElement">
<Doc>
Holder for an array of Row elements.
</Doc>
Expand Down Expand Up @@ -1946,7 +1984,7 @@ Revision is $Id$
<Array name="columns" type="Column"/>
</Element>

<Element type="Key" class="Columns,TableElement,AttributeElement">
<Element type="Key" class="Columns,TableElement,InlineTableElement,AttributeElement">
<Doc>
Definition of the key of a dimension or table.
</Doc>
Expand Down
25 changes: 11 additions & 14 deletions src/main/mondrian/olap/NameResolver.java
Expand Up @@ -80,11 +80,12 @@ private OlapElement resolveInexact(
List<Namespace> namespaces)
{
OlapElement element = parent;
segmentLoop:
for (final IdentifierSegment segment : segments) {
assert element != null;
OlapElement child = null;
for (Namespace namespace : namespaces) {
child = namespace.lookupChild(element, segment, matchType);
OlapElement child =
namespace.lookupChild(element, segment, matchType);
if (child != null) {
switch (matchType) {
case EXACT:
Expand All @@ -101,13 +102,11 @@ private OlapElement resolveInexact(
}
break;
}
break;
element = child;
continue segmentLoop;
}
}
if (child == null) {
return null;
}
element = child;
return null;
}
return element;
}
Expand All @@ -120,19 +119,17 @@ private OlapElement resolveExact(
List<Namespace> namespaces)
{
OlapElement element = parent;
segmentLoop:
for (final IdentifierSegment segment : segments) {
assert element != null;
OlapElement child = null;
for (Namespace namespace : namespaces) {
child = namespace.lookupChild(element, segment);
OlapElement child = namespace.lookupChild(element, segment);
if (child != null) {
break;
element = child;
continue segmentLoop;
}
}
if (child == null) {
return null;
}
element = child;
return null;
}
return element;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/mondrian/olap/OlapElement.java
Expand Up @@ -68,11 +68,11 @@ OlapElement lookupChild(
*
* <p>Example 2:
* <blockquote><pre>
* order(except([Promotion Media].[Media Type].members,
* {[Promotion Media].[Media Type].[No Media]}),
* order(except([Promotion].[Media Type].members,
* {[Promotion].[Media Type].[No Media]}),
* [Measures].[Unit Sales], DESC)
* </pre></blockquote>
* has dimension [Promotion Media].</p>
* has dimension [Promotion].</p>
*
* <p>Example 3:
* <blockquote><pre>
Expand Down
67 changes: 45 additions & 22 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -121,7 +121,7 @@ public class Query extends QueryPart {
private boolean nativeCrossJoinVirtualCube;

/**
* Contains a list of stars
* Contains a list of measure groups.
*/
private List<RolapMeasureGroup> measureGroupList;

Expand Down Expand Up @@ -913,24 +913,6 @@ private static Object quickParse(
}
}

/**
* Swaps the x- and y- axes.
* Does nothing if the number of axes != 2.
*/
public void swapAxes() {
if (axes.length == 2) {
Exp e0 = axes[0].getSet();
boolean nonEmpty0 = axes[0].isNonEmpty();
Exp e1 = axes[1].getSet();
boolean nonEmpty1 = axes[1].isNonEmpty();
axes[1].setSet(e0);
axes[1].setNonEmpty(nonEmpty0);
axes[0].setSet(e1);
axes[0].setNonEmpty(nonEmpty1);
// showSubtotals ???
}
}

/**
* Returns the parameters defined in this query.
*/
Expand Down Expand Up @@ -972,6 +954,10 @@ public Member lookupMemberFromCache(String memberUniqueName) {
if (Util.equalName(member.getUniqueName(), memberUniqueName)
|| Util.equalName(
getUniqueNameWithoutAll(member),
memberUniqueName)
|| !Bug.BugMondrian960Fixed
&& Util.equalName(
getUniqueNameWithoutDimension(member),
memberUniqueName))
{
return member;
Expand All @@ -980,7 +966,7 @@ public Member lookupMemberFromCache(String memberUniqueName) {
return null;
}

private String getUniqueNameWithoutAll(Member member) {
private static String getUniqueNameWithoutAll(Member member) {
// build unique string
Member parentMember = member.getParentMember();
if ((parentMember != null) && !parentMember.isAll()) {
Expand All @@ -992,6 +978,26 @@ private String getUniqueNameWithoutAll(Member member) {
}
}

// this method is a hack - remove when mondrian-960 fixed
public static String getUniqueNameWithoutDimension(Member member) {
assert !Bug.BugMondrian960Fixed;
// build unique string
Member parentMember = member.getParentMember();
if ((parentMember != null) && !parentMember.isAll()) {
return Util.makeFqName(
getUniqueNameWithoutAll(parentMember),
member.getName());
} else {
final Hierarchy hierarchy = member.getHierarchy();
if (hierarchy.getDimension().getName().equals(
hierarchy.getDimension().getName()))
{
return Util.makeFqName(member.getDimension(), member.getName());
}
return Util.makeFqName(hierarchy, member.getName());
}
}

/**
* Looks up a named set.
*/
Expand Down Expand Up @@ -1201,7 +1207,10 @@ public void renameFormula(String uniqueName, String newName) {
formula.rename(newName);
}

List<Member> getDefinedMembers() {
// REVIEW: should we apply access control BEFORE resolving names?
// This method is used several times during name resolution and is
// inefficient.
private List<Member> getDefinedMembers() {
List<Member> definedMembers = new ArrayList<Member>();
for (final Formula formula : formulas) {
if (formula.isMember()
Expand Down Expand Up @@ -1524,9 +1533,23 @@ private static boolean match(
segment = nameParts.get(nameParts.size() - 1);
}
if (segment.matches(member.getName())) {
final String imploded =
Util.implode(
nameParts.subList(
0,
nameParts.size() - 1));
if (!Bug.BugMondrian960Fixed
&& member.getHierarchy().getName().equals(
member.getDimension().getName())
&& Util.equalName(
member.getDimension().getUniqueName(),
imploded))
{
return true;
}
return Util.equalName(
member.getHierarchy().getUniqueName(),
Util.implode(nameParts.subList(0, nameParts.size() - 1)));
imploded);
} else if (member.isAll()) {
return Util.equalName(
member.getHierarchy().getUniqueName(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/ResultBase.java
Expand Up @@ -144,7 +144,7 @@ public Member getMember(int[] pos, Hierarchy hierarchy) {
}
}
}
return hierarchy.getHierarchy().getDefaultMember();
return hierarchy.getDefaultMember();
}

public void close() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/mondrian/olap/RoleImpl.java
Expand Up @@ -521,10 +521,10 @@ private static class HierarchyAccessImpl implements Role.HierarchyAccess {
this.access = access;
this.rollupPolicy = rollupPolicy;
this.topLevel = topLevel == null
? hierarchy.getLevels()[0]
? hierarchy.getLevelList().get(0)
: topLevel;
this.bottomLevel = bottomLevel == null
? hierarchy.getLevels()[hierarchy.getLevels().length - 1]
? Util.last(hierarchy.getLevelList())
: bottomLevel;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/fun/BuiltinFunTable.java
Expand Up @@ -150,7 +150,7 @@ Level nthLevel(Hierarchy hierarchy, int n) {
throw newEvalException(
this, "Index '" + n + "' out of bounds");
}
return levels.get(0);
return levels.get(n);
}
});

Expand Down

0 comments on commit e953659

Please sign in to comment.