Skip to content

Commit

Permalink
MONDRIAN: Non empty function running for high cardinality
Browse files Browse the repository at this point in the history
dimensions (bug 1998598)

[git-p4: depot-paths = "//open/mondrian/": change = 11219]
  • Loading branch information
Luis F. Canals committed Jun 26, 2008
1 parent c1ac043 commit 016b72e
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 14 deletions.
8 changes: 7 additions & 1 deletion src/main/mondrian/util/ConcatenableList.java
Expand Up @@ -24,6 +24,7 @@ public class ConcatenableList<T> extends AbstractList<T> {
private Iterator<T> getIterator = null;
private int previousIndex = -200;
private T previousElement = null;
private T prePreviousElement = null;

public ConcatenableList() {
this.lists = new ArrayList<List<T>>();
Expand Down Expand Up @@ -74,6 +75,7 @@ public T get(final int index) {
} else if(this.previousIndex+1==index && this.getIterator!=null) {
this.previousIndex = index;
if(this.getIterator.hasNext()) {
this.prePreviousElement = this.previousElement;
this.previousElement = this.getIterator.next();
return this.previousElement;
} else {
Expand All @@ -84,6 +86,8 @@ public T get(final int index) {
}
} else if(this.previousIndex==index) {
return this.previousElement;
} else if(this.previousIndex-1==index) {
return this.prePreviousElement;
} else {
this.previousIndex = -200;
this.getIterator = null;
Expand All @@ -97,9 +101,11 @@ public T get(final int index) {
throw new IndexOutOfBoundsException("Index " + index
+ " out of concatenable list range");
}
it.next();
this.prePreviousElement = it.next();
}
this.previousElement = it.next();
this.previousIndex = index;
this.getIterator = it;
return this.previousElement;
}
} else {
Expand Down
123 changes: 110 additions & 13 deletions testsrc/main/mondrian/rolap/HighDimensionsTest.java
Expand Up @@ -45,7 +45,6 @@ public HighDimensionsTest(String name) {
super(name);
}


public void testBug1971406() throws Exception {
final Connection connection = TestContext.instance()
.getFoodMartConnection();
Expand All @@ -69,26 +68,30 @@ public void testBug1971406() throws Exception {
public void testPromotionsTwoDimensions() throws Exception {
execHighCardTest("select {[Measures].[Unit Sales]} on columns,\n"
+ "{[Promotions].[Promotion Name].Members} on rows\n"
+ "from [Sales Ragged]", 1, "Promotions");
+ "from [Sales Ragged]", 1, "Promotions",
highCardResults);
}

/*
public void testNonEmpty() throws Exception {

public void testHead() throws Exception {
execHighCardTest("select {[Measures].[Unit Sales]} on columns,\n"
+ "non empty {[Promotions].[Promotion Name].Members} "
+ "on rows from [Sales Ragged]", 1, "Promotions");
+ "head({[Promotions].[Promotion Name].Members},40) "
+ "on rows from [Sales Ragged]", 1, "Promotions",
first40HighCardResults);
}
*/

public void testHead() throws Exception {

public void testNonEmpty() throws Exception {
execHighCardTest("select {[Measures].[Unit Sales]} on columns,\n"
+ "head({[Promotions].[Promotion Name].Members},51) "
+ "on rows from [Sales Ragged]", 1, "Promotions");
+ "non empty {[Promotions].[Promotion Name].Members} "
+ "on rows from [Sales Ragged]", 1, "Promotions",
nonEmptyHighCardResults);
}





//
// Private Stuff --------------------------------------------
//
Expand All @@ -98,7 +101,8 @@ public void testHead() throws Exception {
* into an axis from the results.
*/
private void execHighCardTest(final String queryString, final int axisIndex,
final String highDimensionName) throws Exception {
final String highDimensionName, final String results)
throws Exception {
final int old = MondrianProperties.instance()
.ResultLimit.get();
try {
Expand Down Expand Up @@ -133,7 +137,7 @@ private void execHighCardTest(final String queryString, final int axisIndex,
softReferences.add(new SoftReference(o.get(0)));
buffer.append(o.get(0).toString());
}
assertEquals(buffer.toString(), highCardResults);
assertEquals(buffer.toString(), results);
buffer = null;

// Tests that really results over ResultLimit are erased from
Expand Down Expand Up @@ -163,6 +167,100 @@ private void execHighCardTest(final String queryString, final int axisIndex,
}


private static final String first40HighCardResults =
"[Promotions].[All Promotions].[Bag Stuffers]"
+ "[Promotions].[All Promotions].[Best Savings]"
+ "[Promotions].[All Promotions].[Big Promo]"
+ "[Promotions].[All Promotions].[Big Time Discounts]"
+ "[Promotions].[All Promotions].[Big Time Savings]"
+ "[Promotions].[All Promotions].[Bye Bye Baby]"
+ "[Promotions].[All Promotions].[Cash Register Lottery]"
+ "[Promotions].[All Promotions].[Coupon Spectacular]"
+ "[Promotions].[All Promotions].[Dimes Off]"
+ "[Promotions].[All Promotions].[Dollar Cutters]"
+ "[Promotions].[All Promotions].[Dollar Days]"
+ "[Promotions].[All Promotions].[Double Down Sale]"
+ "[Promotions].[All Promotions].[Double Your Savings]"
+ "[Promotions].[All Promotions].[Fantastic Discounts]"
+ "[Promotions].[All Promotions].[Free For All]"
+ "[Promotions].[All Promotions].[Go For It]"
+ "[Promotions].[All Promotions].[Green Light Days]"
+ "[Promotions].[All Promotions].[Green Light Special]"
+ "[Promotions].[All Promotions].[High Roller Savings]"
+ "[Promotions].[All Promotions].[I Cant Believe It Sale]"
+ "[Promotions].[All Promotions].[Money Grabbers]"
+ "[Promotions].[All Promotions].[Money Savers]"
+ "[Promotions].[All Promotions].[Mystery Sale]"
+ "[Promotions].[All Promotions].[No Promotion]"
+ "[Promotions].[All Promotions].[One Day Sale]"
+ "[Promotions].[All Promotions].[Pick Your Savings]"
+ "[Promotions].[All Promotions].[Price Cutters]"
+ "[Promotions].[All Promotions].[Price Destroyers]"
+ "[Promotions].[All Promotions].[Price Savers]"
+ "[Promotions].[All Promotions].[Price Slashers]"
+ "[Promotions].[All Promotions].[Price Smashers]"
+ "[Promotions].[All Promotions].[Price Winners]"
+ "[Promotions].[All Promotions].[Sale Winners]"
+ "[Promotions].[All Promotions].[Sales Days]"
+ "[Promotions].[All Promotions].[Sales Galore]"
+ "[Promotions].[All Promotions].[Save-It Sale]"
+ "[Promotions].[All Promotions].[Saving Days]"
+ "[Promotions].[All Promotions].[Savings Galore]"
+ "[Promotions].[All Promotions].[Shelf Clearing Days]"
+ "[Promotions].[All Promotions].[Shelf Emptiers]";


private static final String nonEmptyHighCardResults =
"[Promotions].[All Promotions].[Bag Stuffers]"
+ "[Promotions].[All Promotions].[Best Savings]"
+ "[Promotions].[All Promotions].[Big Promo]"
+ "[Promotions].[All Promotions].[Big Time Discounts]"
+ "[Promotions].[All Promotions].[Big Time Savings]"
+ "[Promotions].[All Promotions].[Bye Bye Baby]"
+ "[Promotions].[All Promotions].[Cash Register Lottery]"
+ "[Promotions].[All Promotions].[Dimes Off]"
+ "[Promotions].[All Promotions].[Dollar Cutters]"
+ "[Promotions].[All Promotions].[Dollar Days]"
+ "[Promotions].[All Promotions].[Double Down Sale]"
+ "[Promotions].[All Promotions].[Double Your Savings]"
+ "[Promotions].[All Promotions].[Free For All]"
+ "[Promotions].[All Promotions].[Go For It]"
+ "[Promotions].[All Promotions].[Green Light Days]"
+ "[Promotions].[All Promotions].[Green Light Special]"
+ "[Promotions].[All Promotions].[High Roller Savings]"
+ "[Promotions].[All Promotions].[I Cant Believe It Sale]"
+ "[Promotions].[All Promotions].[Money Savers]"
+ "[Promotions].[All Promotions].[Mystery Sale]"
+ "[Promotions].[All Promotions].[No Promotion]"
+ "[Promotions].[All Promotions].[One Day Sale]"
+ "[Promotions].[All Promotions].[Pick Your Savings]"
+ "[Promotions].[All Promotions].[Price Cutters]"
+ "[Promotions].[All Promotions].[Price Destroyers]"
+ "[Promotions].[All Promotions].[Price Savers]"
+ "[Promotions].[All Promotions].[Price Slashers]"
+ "[Promotions].[All Promotions].[Price Smashers]"
+ "[Promotions].[All Promotions].[Price Winners]"
+ "[Promotions].[All Promotions].[Sale Winners]"
+ "[Promotions].[All Promotions].[Sales Days]"
+ "[Promotions].[All Promotions].[Sales Galore]"
+ "[Promotions].[All Promotions].[Save-It Sale]"
+ "[Promotions].[All Promotions].[Saving Days]"
+ "[Promotions].[All Promotions].[Savings Galore]"
+ "[Promotions].[All Promotions].[Shelf Clearing Days]"
+ "[Promotions].[All Promotions].[Shelf Emptiers]"
+ "[Promotions].[All Promotions].[Super Duper Savers]"
+ "[Promotions].[All Promotions].[Super Savers]"
+ "[Promotions].[All Promotions].[Super Wallet Savers]"
+ "[Promotions].[All Promotions].[Three for One]"
+ "[Promotions].[All Promotions].[Tip Top Savings]"
+ "[Promotions].[All Promotions].[Two Day Sale]"
+ "[Promotions].[All Promotions].[Two for One]"
+ "[Promotions].[All Promotions].[Unbeatable Price Savers]"
+ "[Promotions].[All Promotions].[Wallet Savers]"
+ "[Promotions].[All Promotions].[Weekend Markdown]"
+ "[Promotions].[All Promotions].[You Save Days]";


private static final String highCardResults =
"[Promotions].[All Promotions].[Bag Stuffers]"
+ "[Promotions].[All Promotions].[Best Savings]"
Expand Down Expand Up @@ -216,5 +314,4 @@ private void execHighCardTest(final String queryString, final int axisIndex,
+ "[Promotions].[All Promotions].[Weekend Markdown]"
+ "[Promotions].[All Promotions].[You Save Days]";


}

0 comments on commit 016b72e

Please sign in to comment.