use of mondrian.olap.MondrianException in project mondrian by pentaho.
the class SegmentLoader method load.
/**
* Loads data for all the segments of the GroupingSets. If the grouping sets
* list contains more than one Grouping Set then data is loaded using the
* GROUP BY GROUPING SETS sql. Else if only one grouping set is passed in
* the list data is loaded without using GROUP BY GROUPING SETS sql. If the
* database does not support grouping sets
* {@link mondrian.spi.Dialect#supportsGroupingSets()} then
* grouping sets list should always have only one element in it.
*
* <p>For example, if list has 2 grouping sets with columns A, B, C and B, C
* respectively, then the SQL will be
* "GROUP BY GROUPING SETS ((A, B, C), (B, C))".
*
* <p>Else if the list has only one grouping set then sql would be without
* grouping sets.
*
* <p>The <code>groupingSets</code> list should be topological order, with
* more detailed higher-level grouping sets occurring first. In other words,
* the first element of the list should always be the detailed grouping
* set (default grouping set), followed by grouping sets which can be
* rolled-up on this detailed grouping set.
* In the example (A, B, C) is the detailed grouping set and (B, C) is
* rolled-up using the detailed.
*
* <p>Grouping sets are removed from the {@code groupingSets} list as they
* are loaded.</p>
*
* @param cellRequestCount Number of missed cells that led to this request
* @param groupingSets List of grouping sets whose segments are loaded
* @param compoundPredicateList Compound predicates
* @param segmentFutures List of futures wherein each statement will place
* a list of the segments it has loaded, when it
* completes
*/
public void load(int cellRequestCount, List<GroupingSet> groupingSets, List<StarPredicate> compoundPredicateList, List<Future<Map<Segment, SegmentWithData>>> segmentFutures) {
if (!MondrianProperties.instance().DisableCaching.get()) {
for (GroupingSet groupingSet : groupingSets) {
for (Segment segment : groupingSet.getSegments()) {
final SegmentCacheIndex index = cacheMgr.getIndexRegistry().getIndex(segment.star);
index.add(segment.getHeader(), new SegmentBuilder.StarSegmentConverter(segment.measure, compoundPredicateList), true);
// Make sure that we are registered as a client of
// the segment by invoking getFuture.
Util.discard(index.getFuture(Locus.peek().execution, segment.getHeader()));
}
}
}
try {
segmentFutures.add(cacheMgr.sqlExecutor.submit(new SegmentLoadCommand(Locus.peek(), this, cellRequestCount, groupingSets, compoundPredicateList)));
} catch (Exception e) {
throw new MondrianException(e);
}
}
use of mondrian.olap.MondrianException in project mondrian by pentaho.
the class CodeSetTest method testSucces_CodeSetContainsCodeForBothPostgresAndPostgresqlDialects.
/**
* ISSUE MONDRIAN-2335 If SqlQuery.CodeSet contains sql code
* for both dialect="postgres" and dialect="postgresql",
* the code for dialect="postgres"should be chosen. No error should be thrown
*
* @throws Exception
*/
public void testSucces_CodeSetContainsCodeForBothPostgresAndPostgresqlDialects() throws Exception {
PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
codeSet = new SqlQuery.CodeSet();
codeSet.put(POSTGRES_DIALECT, SQL_CODE_FOR_POSTGRES_DIALECT);
codeSet.put(POSTGRESQL_DIALECT, SQL_CODE_FOR_POSTGRESQL_DIALECT);
try {
String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
assertEquals(SQL_CODE_FOR_POSTGRES_DIALECT, chooseQuery);
} catch (MondrianException mExc) {
fail("Not expected any MondrianException but it occured: " + mExc.getLocalizedMessage());
}
}
use of mondrian.olap.MondrianException in project mondrian by pentaho.
the class SchemaVersionTest method testSchema4noVersion.
public void testSchema4noVersion() {
TestContext testContext = TestContext.instance().withSchema(SCHEMA_4_NVHEADER + SCHEMA_4_BODY);
Util.PropertyList connectInfo = testContext.getConnectionProperties();
try {
Connection conn = DriverManager.getConnection(connectInfo, null);
conn.close();
Assert.fail("No exception thrown for version 4 schema.");
} catch (MondrianException e) {
assertTrue(e.getMessage().contains("Schema version"));
}
}
use of mondrian.olap.MondrianException in project mondrian by pentaho.
the class MondrianServerImpl method addStatement.
@Override
public synchronized void addStatement(Statement statement) {
if (shutdown) {
throw new MondrianException("Server already shutdown.");
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("addStatement " + ", id=" + id + ", statements=" + statementMap.size() + ", connections=" + connectionMap.size());
}
statementMap.put(statement.getId(), statement);
final RolapConnection connection = statement.getMondrianConnection();
monitor.sendEvent(new StatementStartEvent(System.currentTimeMillis(), connection.getServer().getId(), connection.getId(), statement.getId()));
}
use of mondrian.olap.MondrianException in project mondrian by pentaho.
the class MondrianServerImpl method removeStatement.
@Override
public synchronized void removeStatement(Statement statement) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("removeStatement " + ", id=" + id + ", statements=" + statementMap.size() + ", connections=" + connectionMap.size());
}
if (shutdown) {
throw new MondrianException("Server already shutdown.");
}
statementMap.remove(statement.getId());
final RolapConnection connection = statement.getMondrianConnection();
monitor.sendEvent(new StatementEndEvent(System.currentTimeMillis(), connection.getServer().getId(), connection.getId(), statement.getId()));
}
Aggregations