Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Crossjoin Limit for individual Lists #1114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import mondrian.calc.*;
import mondrian.olap.*;
import mondrian.resource.MondrianResource;

import java.util.*;

Expand All @@ -24,6 +25,7 @@ public class ArrayTupleList extends AbstractEndToEndTupleList
{
private transient Member[] objectData;
private int size;
private static final int cjMaxSize = MondrianProperties.instance().ResultLimit.get();

/**
* Creates an empty ArrayTupleList with an initial capacity of 10 tuples.
Expand Down Expand Up @@ -247,6 +249,11 @@ private void ensureCapacity(int minCapacity) {
// Up to next multiple of arity.
final int rem = newCapacity % arity;
newCapacity += (arity - rem);
if (cjMaxSize > 0 && newCapacity > cjMaxSize) {
throw MondrianResource.instance().TotalMembersLimitExceeded.ex(
newCapacity, cjMaxSize);
}
Util.checkCJResultLimit(newCapacity);
objectData = Util.copyOf(objectData, newCapacity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ public TupleList evaluateList(Evaluator evaluator) {
ListCalc listCalc2 = (ListCalc) calcs[1];

TupleList l1 = listCalc1.evaluateList(evaluator);
// check if size of first list already exceeds limit
Util.checkCJResultLimit(l1.size());
TupleList l2 = listCalc2.evaluateList(evaluator);
// check if size of second list already exceeds limit
Util.checkCJResultLimit(l2.size());
// check crossjoin
Util.checkCJResultLimit(l1.size() * l2.size());

l1 = nonEmptyOptimizeList(evaluator, l1, call);
if (l1.isEmpty()) {
Expand Down
3 changes: 3 additions & 0 deletions mondrian/src/main/java/mondrian/rolap/RolapNativeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ protected TupleList executeList(final SqlTupleReader tr) {
dataSource, partialResult, newPartialResult);
}

// Check limit of result size already is too large
Util.checkCJResultLimit(result.size());

// Did not get as many members as expected - try to complete using
// less constraints
if (completeWithNullValues && result.size() < maxRows) {
Expand Down