Package mondrian.rolap
Class RolapUtil
- java.lang.Object
-
- mondrian.rolap.RolapUtil
-
public class RolapUtil extends Object
Utility methods for classes in themondrian.rolappackage.- Since:
- 22 December, 2001
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRolapUtil.ExecuteQueryHookstatic classRolapUtil.TeeWriterWrites to a string and also to an underlying writer.
-
Field Summary
Fields Modifier and Type Field Description static org.apache.logging.log4j.LoggerMDX_LOGGERstatic org.apache.logging.log4j.LoggerMONITOR_LOGGERstatic org.apache.logging.log4j.LoggerPROFILE_LOGGERstatic ComparatorROLAP_COMPARATORA comparator singleton instance which can handle the presence ofRolapUtil.RolapUtilComparableinstances in a collection.static org.apache.logging.log4j.LoggerSQL_LOGGERstatic StringsqlNullLiteralstatic Comparable<?>sqlNullValueSpecial value represents a null key.static ObjectvalueNotReadyExceptionSpecial cell value indicates that the value is not in cache yet.
-
Constructor Summary
Constructors Constructor Description RolapUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidalertNonNative(String functionName, String reason)Raises an alert that native SQL evaluation could not be used in a case where it might have been beneficial, but some limitation in Mondrian's implementation prevented it.static voidconstraintBitkeyForLimitedMembers(Evaluator evaluator, Member[] members, RolapCube cube, BitKey levelBitKey)Modifies a bitkey so that it includes the proper bits for members in an array which should be considered as a limited rollup member.static MondrianDef.RelationconvertInlineTableToRelation(MondrianDef.InlineTable inlineTable, Dialect dialect)static ExpCompilercreateDependencyTestingCompiler(ExpCompiler compiler)Creates a compiler which will generate programs which will test whether the dependencies declared viaCalc.dependsOn(Hierarchy)are accurate.static EvaluatorcreateEvaluator(Statement statement)Creates a dummy evaluator.static ExpCompilercreateProfilingCompiler(ExpCompiler compiler)static SqlStatementexecuteQuery(DataSource dataSource, String sql, List<SqlStatement.Type> types, int maxRowCount, int firstRowOrdinal, Locus locus, int resultSetType, int resultSetConcurrency, Util.Functor1<Void,Statement> callback)Executes a query.static SqlStatementexecuteQuery(DataSource dataSource, String sql, Locus locus)Executes a query, printing to the trace log if tracing is enabled.static MemberfindBestMemberMatch(List<? extends Member> members, RolapMember parent, RolapLevel level, Id.Segment searchName, MatchType matchType)Locates a member specified by its member name, from an array of members.static Util.Functor1<Void,Statement>getDefaultCallback(Locus locus)static RolapUtil.ExecuteQueryHookgetHook()Sets the query-execution hook used by tests.static voidloadDrivers(String jdbcDrivers)Loads a set of JDBC drivers.static SchemaReaderlocusSchemaReader(RolapConnection connection, SchemaReader schemaReader)Wraps a schema reader in a proxy so that each call to schema reader has a locus for profiling purposes.static List<String>makeRolapStarKey(String factTableName)Generates rolap star key based on the fact table name.static List<String>makeRolapStarKey(MondrianDef.Relation fact)Generates rolap star key based on the fact using fact alias and SQl filter data if this one is present in the factstatic StringmdxNullLiteral()static voidreloadNullLiteral()static voidsetHook(RolapUtil.ExecuteQueryHook hook)static RolapMemberstrip(RolapMember member)
-
-
-
Field Detail
-
MDX_LOGGER
public static final org.apache.logging.log4j.Logger MDX_LOGGER
-
SQL_LOGGER
public static final org.apache.logging.log4j.Logger SQL_LOGGER
-
MONITOR_LOGGER
public static final org.apache.logging.log4j.Logger MONITOR_LOGGER
-
PROFILE_LOGGER
public static final org.apache.logging.log4j.Logger PROFILE_LOGGER
-
valueNotReadyException
public static final Object valueNotReadyException
Special cell value indicates that the value is not in cache yet.
-
sqlNullValue
public static final Comparable<?> sqlNullValue
Special value represents a null key.
-
ROLAP_COMPARATOR
public static final Comparator ROLAP_COMPARATOR
A comparator singleton instance which can handle the presence ofRolapUtil.RolapUtilComparableinstances in a collection.
-
sqlNullLiteral
public static final String sqlNullLiteral
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultCallback
public static Util.Functor1<Void,Statement> getDefaultCallback(Locus locus)
-
locusSchemaReader
public static SchemaReader locusSchemaReader(RolapConnection connection, SchemaReader schemaReader)
Wraps a schema reader in a proxy so that each call to schema reader has a locus for profiling purposes.- Parameters:
connection- ConnectionschemaReader- Schema reader- Returns:
- Wrapped schema reader
-
getHook
public static RolapUtil.ExecuteQueryHook getHook()
Sets the query-execution hook used by tests. This method andsetHook(mondrian.rolap.RolapUtil.ExecuteQueryHook)are synchronized to ensure a memory barrier.- Returns:
- Query execution hook
-
setHook
public static void setHook(RolapUtil.ExecuteQueryHook hook)
-
mdxNullLiteral
public static String mdxNullLiteral()
-
reloadNullLiteral
public static void reloadNullLiteral()
-
executeQuery
public static SqlStatement executeQuery(DataSource dataSource, String sql, Locus locus)
Executes a query, printing to the trace log if tracing is enabled.If the query fails, it wraps the
SQLExceptionin a runtime exception withmessageas description, and closes the result set.If it succeeds, the caller must call the
SqlStatement.close()method of the returnedSqlStatement.- Parameters:
dataSource- DataSourcesql- SQL stringlocus- Locus of execution- Returns:
- ResultSet
-
executeQuery
public static SqlStatement executeQuery(DataSource dataSource, String sql, List<SqlStatement.Type> types, int maxRowCount, int firstRowOrdinal, Locus locus, int resultSetType, int resultSetConcurrency, Util.Functor1<Void,Statement> callback)
Executes a query.If the query fails, it wraps the
SQLExceptionin a runtime exception withmessageas description, and closes the result set.If it succeeds, the caller must call the
SqlStatement.close()method of the returnedSqlStatement.- Parameters:
dataSource- DataSourcesql- SQL stringtypes- Suggested types of columns, or null; if present, must have one element for each SQL column; each not-null entry overrides deduced JDBC type of the columnmaxRowCount- Maximum number of rows to retrieve, <= 0 if unlimitedfirstRowOrdinal- Ordinal of row to skip to (1-based), or 0 to start from beginninglocus- Execution context of this statementresultSetType- Result set type, or -1 to use defaultresultSetConcurrency- Result set concurrency, or -1 to use default- Returns:
- ResultSet
-
alertNonNative
public static void alertNonNative(String functionName, String reason) throws NativeEvaluationUnsupportedException
Raises an alert that native SQL evaluation could not be used in a case where it might have been beneficial, but some limitation in Mondrian's implementation prevented it. (Do not call this in cases where native evaluation would have been wasted effort.)- Parameters:
functionName- name of function for which native evaluation was skippedreason- reason why native evaluation was skipped- Throws:
NativeEvaluationUnsupportedException
-
loadDrivers
public static void loadDrivers(String jdbcDrivers)
Loads a set of JDBC drivers.- Parameters:
jdbcDrivers- A string consisting of the comma-separated names of JDBC driver classes. For example"sun.jdbc.odbc.JdbcOdbcDriver,com.mysql.jdbc.Driver".
-
createDependencyTestingCompiler
public static ExpCompiler createDependencyTestingCompiler(ExpCompiler compiler)
Creates a compiler which will generate programs which will test whether the dependencies declared viaCalc.dependsOn(Hierarchy)are accurate.
-
findBestMemberMatch
public static Member findBestMemberMatch(List<? extends Member> members, RolapMember parent, RolapLevel level, Id.Segment searchName, MatchType matchType)
Locates a member specified by its member name, from an array of members. If an exact match isn't found, but a matchType of BEFORE or AFTER is specified, then the closest matching member is returned.- Parameters:
members- array of members to search fromparent- parent member corresponding to the member being searched forlevel- level of the membersearchName- member namematchType- match type- Returns:
- matching member (if it exists) or the closest matching one in the case of a BEFORE or AFTER search
-
convertInlineTableToRelation
public static MondrianDef.Relation convertInlineTableToRelation(MondrianDef.InlineTable inlineTable, Dialect dialect)
-
strip
public static RolapMember strip(RolapMember member)
-
createProfilingCompiler
public static ExpCompiler createProfilingCompiler(ExpCompiler compiler)
-
createEvaluator
public static Evaluator createEvaluator(Statement statement)
Creates a dummy evaluator.
-
constraintBitkeyForLimitedMembers
public static void constraintBitkeyForLimitedMembers(Evaluator evaluator, Member[] members, RolapCube cube, BitKey levelBitKey)
Modifies a bitkey so that it includes the proper bits for members in an array which should be considered as a limited rollup member.
-
makeRolapStarKey
public static List<String> makeRolapStarKey(MondrianDef.Relation fact)
Generates rolap star key based on the fact using fact alias and SQl filter data if this one is present in the fact- Parameters:
fact- the fact based on which is generated the rolap star key- Returns:
- the rolap star key
-
-