|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmondrian.olap.QueryPart
mondrian.olap.Query
public class Query
Query
is an MDX query.
It is created by calling Connection.parseQuery(java.lang.String)
,
and executed by calling Connection.execute(mondrian.olap.Query)
,
to return a Result
.
Most queries are model citizens, executing quickly (often using cached results from previous queries), but some queries take more time, or more database resources, or more results, than is reasonable. Mondrian offers three ways to control rogue queries:
MondrianProperties.QueryTimeout
parameter. If the query
takes longer to execute than the value of this parameter, the system
will kill it.MondrianProperties.QueryLimit
parameter limits the number
of cells returned by a query.cancel()
method. The call to Connection.execute(Query)
will throw an exception.
Nested Class Summary | |
---|---|
static class |
Query.ScopedNamedSet
|
Field Summary | |
---|---|
(package private) java.util.Set<FunDef> |
alertedNonNativeFunDefs
Set of FunDefs for which alerts about non-native evaluation have already been posted. |
QueryAxis[] |
axes
public-private: This must be public because it is still accessed in rolap.RolapConnection |
Calc[] |
axisCalcs
|
Formula[] |
formulas
public-private: This must be public because it is still accessed in rolap.RolapCube |
QueryAxis |
slicerAxis
public-private: This must be public because it is still accessed in rolap.RolapResult |
Calc |
slicerCalc
|
Constructor Summary | |
---|---|
Query(Connection connection,
Cube mdxCube,
Formula[] formulas,
QueryAxis[] axes,
QueryAxis slicerAxis,
QueryPart[] cellProps,
Parameter[] parameters,
boolean load,
boolean strictValidation)
Creates a Query. |
|
Query(Connection connection,
Formula[] formulas,
QueryAxis[] axes,
java.lang.String cube,
QueryAxis slicerAxis,
QueryPart[] cellProps,
boolean load,
boolean strictValidation)
Creates a Query. |
Method Summary | |
---|---|
java.lang.Object |
accept(MdxVisitor visitor)
|
void |
addFormula(Formula formula)
Adds a new formula specifying a member or a set to an existing query; resolve is called after the formula has been added. |
void |
addFormula(Id id,
Exp exp)
Adds a new formula specifying a set to an existing query. |
void |
addFormula(Id id,
Exp exp,
MemberProperty[] memberProperties)
Adds a new formula specifying a member to an existing query. |
void |
addFormulas(Formula... additions)
Adds some number of new formulas specifying members or sets to an existing query; resolve is only called once, after all the new members have been added to the query. |
void |
addLevelToAxis(AxisOrdinal axis,
Level level)
Adds a level to an axis expression. |
void |
addMeasuresMembers(OlapElement olapElement)
Keeps track of references to members of the measures dimension |
void |
cancel()
Issues a cancel request on this Query object. |
boolean |
canRemoveFormula(java.lang.String uniqueName)
Returns whether a formula can safely be removed from the query. |
void |
checkCancelOrTimeout()
Checks if either a cancel request has been issued on the query or the execution time has exceeded the timeout value (if one has been set). |
void |
clearEvalCache()
Remove all entries in the evaluation cache |
Query |
clone()
|
Calc |
compileExpression(Exp exp,
boolean scalar,
ResultStyle resultStyle)
Compiles an expression, using a cached compiled expression if available. |
ExpCompiler |
createCompiler()
|
Query.ScopedNamedSet |
createScopedNamedSet(java.lang.String name,
QueryPart scope,
Exp expr)
Creates a named set defined by an alias. |
Validator |
createValidator()
Creates a validator for this query. |
Validator |
createValidator(FunTable functionTable,
boolean alwaysResolveFunDef)
Creates a validator for this query that uses a given function table and function validation policy. |
Formula |
findFormula(java.lang.String uniqueName)
Looks up a calculated member or set defined in this Query. |
QueryAxis[] |
getAxes()
Returns an array of this query's axes. |
java.util.List<RolapCube> |
getBaseCubes()
return the set of base cubes associated with the virtual cube referenced in this query |
java.lang.Object[] |
getChildren()
Returns an array of the object's children. |
Connection |
getConnection()
|
Cube |
getCube()
|
(package private) java.util.List<Member> |
getDefinedMembers()
|
java.lang.Object |
getEvalCache(java.lang.String key)
Gets the Object associated with the value. |
Formula[] |
getFormulas()
Returns an array of the formulas used in this query. |
Hierarchy[] |
getMdxHierarchiesOnAxis(AxisOrdinal axis)
Returns Hierarchy[] used on axis . |
java.util.Set<Member> |
getMeasuresMembers()
|
Parameter[] |
getParameters()
Returns the parameters defined in this query. |
long |
getQueryStartTime()
Gets the query start time |
ResultStyle |
getResultStyle()
|
SchemaReader |
getSchemaReader(boolean accessControlled)
Returns a schema reader. |
QueryAxis |
getSlicerAxis()
|
boolean |
hasCellProperty(java.lang.String propertyName)
Checks whether the property name is present in the query. |
boolean |
ignoreInvalidMembers()
|
boolean |
isCellPropertyEmpty()
Checks whether any cell property present in the query |
Member |
lookupMemberFromCache(java.lang.String memberUniqueName)
Looks up a member whose unique name is memberUniqueName
from cache. |
(package private) Query.ScopedNamedSet |
lookupScopedNamedSet(java.util.List<Id.Segment> nameParts,
ArrayStack<QueryPart> scopeList)
Looks up a named set defined by an alias. |
boolean |
nativeCrossJoinVirtualCube()
|
void |
putEvalCache(java.lang.String key,
java.lang.Object value)
Put an Object value into the evaluation cache with given key. |
void |
removeFormula(java.lang.String uniqueName,
boolean failIfUsedInQuery)
Remove a formula from the query. |
void |
renameFormula(java.lang.String uniqueName,
java.lang.String newName)
Finds formula by name and renames it to new name. |
void |
resolve()
Performs type-checking and validates internal consistency of a query, using the default resolver. |
void |
resolve(Validator validator)
Performs type-checking and validates internal consistency of a query. |
Query |
safeClone()
Deprecated. this method has been deprecated; please use clone() |
void |
setAxisShowEmptyCells(int axis,
boolean showEmpty)
Finds axis by index and sets flag to show empty cells on that axis. |
void |
setBaseCubes(java.util.List<RolapCube> baseCubes)
Saves away the base cubes related to the virtual cube referenced in this query |
(package private) void |
setOutOfMemory(java.lang.String msg)
|
void |
setParameter(java.lang.String parameterName,
java.lang.Object value)
Assigns a value to the parameter with a given name. |
void |
setQueryEndExecution()
Called when query execution has completed. |
void |
setQueryStartTime()
Sets the start time of query execution. |
void |
setQueryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout in milliseconds of this Query. |
void |
setResultStyle(ResultStyle resultStyle)
A Query's ResultStyle can only be one of the following: ResultStyle.ITERABLE ResultStyle.LIST ResultStyle.MUTABLE_LIST |
void |
setSlicerAxis(QueryAxis axis)
|
void |
setVirtualCubeNonNativeCrossJoin()
Indicates that the query cannot use native cross joins to process this virtual cube |
boolean |
shouldAlertForNonNative(FunDef funDef)
Determines whether an alert for non-native evaluation needs to be posted. |
void |
swapAxes()
Swaps the x- and y- axes. |
java.lang.String |
toString()
Returns the MDX query string. |
void |
unparse(java.io.PrintWriter pw)
Writes a string representation of this parse tree node to the given writer. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Formula[] formulas
public QueryAxis[] axes
public QueryAxis slicerAxis
public Calc[] axisCalcs
public Calc slicerCalc
java.util.Set<FunDef> alertedNonNativeFunDefs
Constructor Detail |
---|
public Query(Connection connection, Formula[] formulas, QueryAxis[] axes, java.lang.String cube, QueryAxis slicerAxis, QueryPart[] cellProps, boolean load, boolean strictValidation)
public Query(Connection connection, Cube mdxCube, Formula[] formulas, QueryAxis[] axes, QueryAxis slicerAxis, QueryPart[] cellProps, Parameter[] parameters, boolean load, boolean strictValidation)
Method Detail |
---|
public void setQueryTimeoutMillis(long queryTimeoutMillis)
Zero means no timeout.
queryTimeoutMillis
- Timeout in millisecondspublic boolean hasCellProperty(java.lang.String propertyName)
public boolean isCellPropertyEmpty()
public void addFormula(Id id, Exp exp)
public void addFormula(Id id, Exp exp, MemberProperty[] memberProperties)
id
- Name of memberexp
- Expression for membermemberProperties
- Properties of memberpublic void addFormula(Formula formula)
formula
- Formula to add to querypublic void addFormulas(Formula... additions)
additions
- Formulas to add to querypublic Validator createValidator()
public Validator createValidator(FunTable functionTable, boolean alwaysResolveFunDef)
functionTable
- Function tablealwaysResolveFunDef
- Whether to always resolve function
definitions (see Validator.alwaysResolveFunDef()
)
public Query safeClone()
clone()
public Query clone()
clone
in class java.lang.Object
public Connection getConnection()
public void cancel()
BasicQueryTest.testCancel
for an
example of usage of this method.
void setOutOfMemory(java.lang.String msg)
public void checkCancelOrTimeout()
public void setQueryStartTime()
public long getQueryStartTime()
public void setQueryEndExecution()
public boolean shouldAlertForNonNative(FunDef funDef)
funDef
- function type to alert for
public void resolve()
This method is called automatically when a query is created; you need to call this method manually if you have modified the query's expression tree in any way.
public boolean ignoreInvalidMembers()
public void setResultStyle(ResultStyle resultStyle)
resultStyle
- public ResultStyle getResultStyle()
public void resolve(Validator validator)
validator
- Validatorpublic void unparse(java.io.PrintWriter pw)
QueryPart
unparse
in class QueryPart
pw
- writerpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object[] getChildren()
Walkable
Walkable
are ignored.
getChildren
in interface Walkable
getChildren
in class QueryPart
public QueryAxis getSlicerAxis()
public void setSlicerAxis(QueryAxis axis)
public void addLevelToAxis(AxisOrdinal axis, Level level)
public void setParameter(java.lang.String parameterName, java.lang.Object value)
java.lang.RuntimeException
- if there is not parameter with the given namepublic void swapAxes()
public Parameter[] getParameters()
public Cube getCube()
public SchemaReader getSchemaReader(boolean accessControlled)
accessControlled
- If true, schema reader returns only elements
which are accessible to the connection's current role
public Member lookupMemberFromCache(java.lang.String memberUniqueName)
memberUniqueName
from cache. If the member is not in cache, returns null.
public Query.ScopedNamedSet createScopedNamedSet(java.lang.String name, QueryPart scope, Exp expr)
Query.ScopedNamedSet lookupScopedNamedSet(java.util.List<Id.Segment> nameParts, ArrayStack<QueryPart> scopeList)
nameParts
- Multi-part identifier for setscopeList
- Parse tree node where name is used (last in list) andpublic Formula[] getFormulas()
public QueryAxis[] getAxes()
public void removeFormula(java.lang.String uniqueName, boolean failIfUsedInQuery)
failIfUsedInQuery
is
true, checks and throws an error if formula is used somewhere in the
query.
public boolean canRemoveFormula(java.lang.String uniqueName)
uniqueName
- Unique name of the member or set defined by the formula
public Formula findFormula(java.lang.String uniqueName)
uniqueName
- Unique name of calculated member or set
public void renameFormula(java.lang.String uniqueName, java.lang.String newName)
java.util.List<Member> getDefinedMembers()
public void setAxisShowEmptyCells(int axis, boolean showEmpty)
public Hierarchy[] getMdxHierarchiesOnAxis(AxisOrdinal axis)
Hierarchy[]
used on axis
. It calls
collectHierarchies(mondrian.olap.Exp)
.
public Calc compileExpression(Exp exp, boolean scalar, ResultStyle resultStyle)
exp
- Expressionscalar
- Whether expression is scalarresultStyle
- Preferred result style; if null, use query's default
result style; ignored if expression is scalar
public ExpCompiler createCompiler()
public void addMeasuresMembers(OlapElement olapElement)
olapElement
- potential measure memberpublic java.util.Set<Member> getMeasuresMembers()
public void setVirtualCubeNonNativeCrossJoin()
public boolean nativeCrossJoinVirtualCube()
public void setBaseCubes(java.util.List<RolapCube> baseCubes)
baseCubes
- set of base cubespublic java.util.List<RolapCube> getBaseCubes()
public java.lang.Object accept(MdxVisitor visitor)
public void putEvalCache(java.lang.String key, java.lang.Object value)
key
- the cache keyvalue
- the cache valuepublic java.lang.Object getEvalCache(java.lang.String key)
key
- the cache key
public void clearEvalCache()
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |