}
if (MondrianProperties.instance().UseAggregates.get()
&& !hasCompoundPredicates)
{
final boolean[] rollup = {false};
AggStar aggStar = findAgg(star, levelBitKey, measureBitKey, rollup);
if (aggStar != null) {
// Got a match, hot damn
if (LOGGER.isDebugEnabled()) {
StringBuilder buf = new StringBuilder(256);
buf.append("MATCH: ");
buf.append(star.getFactTable().getAlias());
buf.append(Util.nl);
buf.append(" foreign=");
buf.append(levelBitKey);
buf.append(Util.nl);
buf.append(" measure=");
buf.append(measureBitKey);
buf.append(Util.nl);
buf.append(" aggstar=");
buf.append(aggStar.getBitKey());
buf.append(Util.nl);
buf.append("AggStar=");
buf.append(aggStar.getFactTable().getName());
buf.append(Util.nl);
for (AggStar.Table.Column column
: aggStar.getFactTable().getColumns())
{
buf.append(" ");
buf.append(column);
buf.append(Util.nl);
}
LOGGER.debug(buf.toString());
}
AggQuerySpec aggQuerySpec =
new AggQuerySpec(
aggStar, rollup[0], groupingSetsList);
Pair<String, List<Type>> sql = aggQuerySpec.generateSqlQuery();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"generateSqlQuery: sql="
+ sql.left);
}
return sql;
}
// No match, fall through and use fact table.
}
if (LOGGER.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("NO MATCH : ");
sb.append(star.getFactTable().getAlias());
sb.append(Util.nl);
sb.append("Foreign columns bit key=");
sb.append(levelBitKey);
sb.append(Util.nl);
sb.append("Measure bit key= ");
sb.append(measureBitKey);
sb.append(Util.nl);
sb.append("Agg Stars=[");
sb.append(Util.nl);
for (AggStar aggStar : star.getAggStars()) {
sb.append(aggStar.toString());
}
sb.append(Util.nl);
sb.append("]");
LOGGER.debug(sb.toString());
}