use of mondrian.rolap.agg.CellRequestQuantumExceededException in project mondrian by pentaho.
the class RolapResult method executeStripe.
private void executeStripe(int axisOrdinal, RolapEvaluator revaluator, final int[] pos) {
if (axisOrdinal < 0) {
RolapAxis axis = (RolapAxis) slicerAxis;
TupleList tupleList = axis.getTupleList();
final Iterator<List<Member>> tupleIterator = tupleList.iterator();
if (tupleIterator.hasNext()) {
final List<Member> members = tupleIterator.next();
execution.checkCancelOrTimeout();
final int savepoint = revaluator.savepoint();
revaluator.setContext(members);
Object o;
try {
o = revaluator.evaluateCurrent();
} catch (MondrianEvaluationException e) {
LOGGER.warn("Mondrian: exception in executeStripe.", e);
o = e;
} finally {
revaluator.restore(savepoint);
}
CellInfo ci = null;
// Object.
try {
// This code is a combination of the code found in
// the old RolapResult
// <code>getCellNoDefaultFormatString</code> method and
// the old RolapCell <code>getFormattedValue</code> method.
// Create a CellInfo object for the given position
// integer array.
ci = cellInfos.create(point.getOrdinals());
String cachedFormatString = null;
// Determine if there is a CellFormatter registered for
// the current Cube's Measure's Dimension. If so,
// then find or create a CellFormatterValueFormatter
// for it. If not, then find or create a Locale based
// FormatValueFormatter.
final RolapCube cube = getCube();
Hierarchy measuresHierarchy = cube.getMeasuresHierarchy();
RolapMeasure m = (RolapMeasure) revaluator.getContext(measuresHierarchy);
ValueFormatter valueFormatter = m.getFormatter();
if (valueFormatter == null) {
cachedFormatString = revaluator.getFormatString();
Locale locale = statement.getMondrianConnection().getLocale();
valueFormatter = formatValueFormatters.get(locale);
if (valueFormatter == null) {
valueFormatter = new FormatValueFormatter(locale);
formatValueFormatters.put(locale, valueFormatter);
}
}
ci.formatString = cachedFormatString;
ci.valueFormatter = valueFormatter;
} catch (ResultLimitExceededException e) {
// Do NOT ignore a ResultLimitExceededException!!!
throw e;
} catch (CellRequestQuantumExceededException e) {
// We need to throw this so another phase happens.
throw e;
} catch (MondrianEvaluationException e) {
// ignore but warn
LOGGER.warn("Mondrian: exception in executeStripe.", e);
} catch (Error e) {
// Errors indicate fatal JVM problems; do not discard
throw e;
} catch (Throwable e) {
LOGGER.warn("Mondrian: exception in executeStripe.", e);
Util.discard(e);
}
if (o != RolapUtil.valueNotReadyException) {
ci.value = o;
}
}
} else {
RolapAxis axis = (RolapAxis) axes[axisOrdinal];
TupleList tupleList = axis.getTupleList();
// force materialize
Util.discard(tupleList.size());
if (isAxisHighCardinality(axisOrdinal, tupleList)) {
final int limit = MondrianProperties.instance().HighCardChunkSize.get();
if (positionsIterators.get(axisOrdinal) == null) {
final TupleCursor tupleCursor = tupleList.tupleCursor();
positionsIterators.put(axisOrdinal, tupleCursor);
positionsIndexes.put(axisOrdinal, 0);
final List<List<Member>> subPositions = new ArrayList<List<Member>>();
for (int i = 0; i < limit && tupleCursor.forward(); i++) {
subPositions.add(tupleCursor.current());
}
positionsCurrent.put(axisOrdinal, subPositions);
}
final TupleCursor tupleCursor = positionsIterators.get(axisOrdinal);
final int positionIndex = positionsIndexes.get(axisOrdinal);
List<List<Member>> subTuples = positionsCurrent.get(axisOrdinal);
if (subTuples == null) {
return;
}
int pi;
if (pos[axisOrdinal] > positionIndex + subTuples.size() - 1 && subTuples.size() == limit) {
pi = positionIndex + subTuples.size();
positionsIndexes.put(axisOrdinal, positionIndex + subTuples.size());
subTuples.subList(0, subTuples.size()).clear();
for (int i = 0; i < limit && tupleCursor.forward(); i++) {
subTuples.add(tupleCursor.current());
}
positionsCurrent.put(axisOrdinal, subTuples);
} else {
pi = positionIndex;
}
for (final List<Member> tuple : subTuples) {
point.setAxis(axisOrdinal, pi);
final int savepoint = revaluator.savepoint();
try {
revaluator.setContext(tuple);
execution.checkCancelOrTimeout();
executeStripe(axisOrdinal - 1, revaluator, pos);
} finally {
revaluator.restore(savepoint);
}
pi++;
}
} else {
for (List<Member> tuple : tupleList) {
List<Member> measures = new ArrayList<Member>(statement.getQuery().getMeasuresMembers());
for (Member measure : measures) {
if (measure instanceof RolapBaseCubeMeasure) {
RolapBaseCubeMeasure baseCubeMeasure = (RolapBaseCubeMeasure) measure;
if (baseCubeMeasure.getAggregator() == RolapAggregator.DistinctCount) {
processDistinctMeasureExpr(tuple, baseCubeMeasure);
}
}
}
}
int tupleIndex = 0;
for (final List<Member> tuple : tupleList) {
point.setAxis(axisOrdinal, tupleIndex);
final int savepoint = revaluator.savepoint();
try {
revaluator.setEvalAxes(true);
revaluator.setContext(tuple);
execution.checkCancelOrTimeout();
executeStripe(axisOrdinal - 1, revaluator, pos);
} finally {
revaluator.restore(savepoint);
}
tupleIndex++;
}
}
}
}
Aggregations