mondrian.rolap
Class RolapUtil

java.lang.Object
  extended by mondrian.rolap.RolapUtil

public class RolapUtil
extends Object

Utility methods for classes in the mondrian.rolap package.

Since:
22 December, 2001
Author:
jhyde
 

Nested Class Summary
(package private) static interface RolapUtil.ExecuteQueryHook
           
(package private) static class RolapUtil.Semaphore
          A Semaphore is a primitive for process synchronization.
static class RolapUtil.TeeWriter
          Writes to a string and also to an underlying writer.
 
Field Summary
(package private) static org.apache.log4j.Logger LOGGER
           
static org.apache.log4j.Logger MDX_LOGGER
           
static String mdxNullLiteral
          Runtime NullMemberRepresentation property change not taken into consideration
static org.apache.log4j.Logger SQL_LOGGER
           
static String sqlNullLiteral
           
static Comparable sqlNullValue
          Special value represents a null key.
(package private) static ThreadLocal<RolapUtil.ExecuteQueryHook> threadHooks
          Hook to run when a query is executed.
static Object valueNotReadyException
          Special cell value indicates that the value is not in cache yet.
 
Constructor Summary
RolapUtil()
           
 
Method Summary
(package private) static
<T> T[]
addElement(T[] a, T o)
          Adds an object to the end of an array.
(package private) static
<T> T[]
addElements(T[] a, T[] b)
          Adds an array to the end of an array.
static void alertNonNative(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 MondrianDef.Relation convertInlineTableToRelation(MondrianDef.InlineTable inlineTable, SqlQuery.Dialect dialect)
           
static ExpCompiler createDependencyTestingCompiler(ExpCompiler compiler)
          Creates a compiler which will generate programs which will test whether the dependencies declared via Calc.dependsOn(mondrian.olap.Dimension) are accurate.
static Evaluator createEvaluator(Query query)
          Creates a dummy evaluator.
static SqlStatement executeQuery(DataSource dataSource, String sql, int maxRows, String component, String message, int resultSetType, int resultSetConcurrency)
          Executes a query.
static SqlStatement executeQuery(DataSource dataSource, String sql, String component, String message)
          Executes a query, printing to the trace log if tracing is enabled.
static Member findBestMemberMatch(List<? extends Member> members, RolapMember parent, RolapLevel level, Id.Segment searchName, MatchType matchType, boolean caseInsensitive)
          Locates a member specified by its member name, from an array of members.
(package private) static RolapUtil.Semaphore getQuerySemaphore()
          Gets the semaphore which controls how many people can run queries simultaneously.
static void loadDrivers(String jdbcDrivers)
          Loads a set of JDBC drivers.
(package private) static RolapMember lookupMember(MemberReader reader, List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
           
(package private) static RolapMember[] toArray(List<RolapMember> v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MDX_LOGGER

public static final org.apache.log4j.Logger MDX_LOGGER

SQL_LOGGER

public static final org.apache.log4j.Logger SQL_LOGGER

LOGGER

static final org.apache.log4j.Logger LOGGER

valueNotReadyException

public static final Object valueNotReadyException
Special cell value indicates that the value is not in cache yet.


threadHooks

static final ThreadLocal<RolapUtil.ExecuteQueryHook> threadHooks
Hook to run when a query is executed.


sqlNullValue

public static final Comparable sqlNullValue
Special value represents a null key.


mdxNullLiteral

public static final String mdxNullLiteral
Runtime NullMemberRepresentation property change not taken into consideration


sqlNullLiteral

public static final String sqlNullLiteral
See Also:
Constant Field Values
Constructor Detail

RolapUtil

public RolapUtil()
Method Detail

toArray

static RolapMember[] toArray(List<RolapMember> v)

lookupMember

static RolapMember lookupMember(MemberReader reader,
                                List<Id.Segment> uniqueNameParts,
                                boolean failIfNotFound)

addElement

static <T> T[] addElement(T[] a,
                          T o)
Adds an object to the end of an array. The resulting array is of the same type (e.g. String[]) as the input array.


addElements

static <T> T[] addElements(T[] a,
                           T[] b)
Adds an array to the end of an array. The resulting array is of the same type (e.g. String[]) as the input array.


executeQuery

public static SqlStatement executeQuery(DataSource dataSource,
                                        String sql,
                                        String component,
                                        String message)
Executes a query, printing to the trace log if tracing is enabled.

If the query fails, it wraps the SQLException in a runtime exception with message as description, and closes the result set.

If it succeeds, the caller must call the SqlStatement.close() method of the returned SqlStatement.

Parameters:
dataSource - DataSource
sql - SQL string
component - Description of a the component executing the query, generally a method name, e.g. "SqlTupleReader.readTuples"
message - Description of the purpose of this statement, to be printed if there is an error
Returns:
ResultSet

executeQuery

public static SqlStatement executeQuery(DataSource dataSource,
                                        String sql,
                                        int maxRows,
                                        String component,
                                        String message,
                                        int resultSetType,
                                        int resultSetConcurrency)
Executes a query.

If the query fails, it wraps the SQLException in a runtime exception with message as description, and closes the result set.

If it succeeds, the caller must call the SqlStatement.close() method of the returned SqlStatement.

Parameters:
dataSource - DataSource
sql - SQL string
maxRows - Row limit, or -1 if no limit
component - Description of a the component executing the query, generally a method name, e.g. "SqlTupleReader.readTuples"
message - Description of the purpose of this statement, to be printed if there is an error
resultSetType - Result set type, or -1 to use default
resultSetConcurrency - 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.)

Throws:
NativeEvaluationUnsupportedException
Parameters:
functionName - name of function for which native evaluation was skipped
reason - reason why native evaluation was skipped

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 via Calc.dependsOn(mondrian.olap.Dimension) are accurate.


findBestMemberMatch

public static Member findBestMemberMatch(List<? extends Member> members,
                                         RolapMember parent,
                                         RolapLevel level,
                                         Id.Segment searchName,
                                         MatchType matchType,
                                         boolean caseInsensitive)
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 from
parent - parent member corresponding to the member being searched for
level - level of the member
searchName - member name
matchType - match type
caseInsensitive - if true, use case insensitive search (if applicable) when when doing exact searches
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,
                                                                SqlQuery.Dialect dialect)

getQuerySemaphore

static RolapUtil.Semaphore getQuerySemaphore()
Gets the semaphore which controls how many people can run queries simultaneously.


createEvaluator

public static Evaluator createEvaluator(Query query)
Creates a dummy evaluator.


SourceForge.net_Logo