Package mondrian.olap.fun
Class FunUtil
java.lang.Object
org.eigenbase.xom.XMLUtil
org.eigenbase.xom.XOMUtil
mondrian.olap.Util
mondrian.olap.fun.FunUtil
- Direct Known Subclasses:
CacheFunDef.CacheFunResolver
,FunDefBase
,MultiResolver
FunUtil
contains a set of methods useful within the mondrian.olap.fun
package.- Since:
- 1.0
- Author:
- jhyde
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Compares cell values, so that larger values compare first.Nested classes/interfaces inherited from class mondrian.olap.Util
Util.AbstractFlatList<T>, Util.ByteMatcher, Util.ErrorCellValue, Util.Flat2List<T>, Util.Flat3List<T>, Util.Functor1<RT,
PT>, Util.GcIterator<T>, Util.MemoryInfo, Util.PropertyList, Util.SqlNullSafeComparator -
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Null value in three-valued boolean logic.static final double
Special value which indicates that adouble
computation has returned the MDX EMPTY value.static final double
Special value which indicates that adouble
computation has returned the MDX null value.static final int
Special value which indicates that anint
computation has returned the MDX null value.static final mondrian.olap.fun.FunUtil.NullMember
Fields inherited from class mondrian.olap.Util
DEBUG, EmptyValue, IBM_JVM, JdbcVersion, JVM_INSTANCE_UUID, nl, nullValue, Retrowoven
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
static Double
box
(double d) Converts a double (primitive) value to a Double.static Integer
box
(int n) Converts an int (primitive) value to an Integer.static void
static void
checkListResultStyles
(Calc calc) static int
compareHierarchically
(Member m1, Member m2, boolean post) Compares a pair of members according to their positions in a prefix-order (or postfix-order, ifpost
is true) walk over a hierarchy.static int
compareSiblingMembers
(Member m1, Member m2) Compares two members which are known to have the same parent.static int
compareValues
(double d1, double d2) Compares double-precision values according to MDX semantics.static int
compareValues
(Object value0, Object value1) Compares two cell values.static int
count
(Evaluator evaluator, TupleIterable iterable, boolean includeEmpty) static int
decodeCategory
(String flags, int offset) Decodes theoffset
th character of an encoded method signature into a type category.static int[]
decodeParameterCategories
(String flags) Decodes a string of parameter types into an array of type codes.static int
decodeReturnCategory
(String flags) Decodes the signature of a function into a category code which describes the return type of the operator.static Syntax
decodeSyntacticType
(String flags) Decodes the syntactic type of an operator.static Hierarchy
getDimensionDefaultHierarchy
(Dimension dimension) Returns the default hierarchy of a dimension, or null if there is no default.getNonEmptyMemberChildren
(Evaluator evaluator, Member member) getNonEmptyMemberChildrenWithDetails
(Evaluator evaluator, Member member) static boolean
isAncestorOf
(Member m0, Member m1, boolean strict) Returns whetherm0
is an ancestor ofm1
.static Member[]
makeNullTuple
(TupleType tupleType) static Object
static Object
static RuntimeException
newEvalException
(String message, Throwable throwable) Creates an exception which indicates that an error has occurred while executing a given function.static RuntimeException
newEvalException
(Throwable throwable) Creates an exception which indicates that an error has occurred while executing a given function.static RuntimeException
newEvalException
(FunDef funDef, String message) Creates an exception which indicates that an error has occurred while executing a given function.protected static double
Returns the member which lies upon a particular quartile according to a given expression.static FunDef
resolveFunArgs
(Validator validator, FunDef funDef, Exp[] args, Exp[] newArgs, String name, Syntax syntax) Validates the arguments to a function and resolves the function.static Object
static double
sumDouble
(Evaluator evaluator, TupleIterable iterable, Calc exp) static double
static boolean
tupleContainsNullMember
(List<Member> tuple) Returns whether one of the members in a tuple is null.static boolean
tupleContainsNullMember
(Member[] tuple) Returns whether one of the members in a tuple is null.static boolean
worthCaching
(Exp exp) Returns whether an expression is worth wrapping in "Cache( ...Methods inherited from class mondrian.olap.Util
addAppender, addDatabaseTime, addLevelCalculatedMembers, append, appendArrays, areOccurencesEqual, assertPostcondition, assertPostcondition, assertPrecondition, assertPrecondition, assertTrue, assertTrue, badValue, binarySearch, bitSetBetween, camelToUpper, canCast, cancelStatement, caseSensitiveCompareName, cast, cast, castToIterable, checkCJResultLimit, close, commaList, compare, compareIntegers, compareKey, compareName, compileScript, convert, convert, convertOlap4jConnectStringToNativeMondrian, convertStackToString, copyOf, copyOf, copyOf, copyOf, copyOf, createExpr, createRandom, createRootRole, createSimpleValidator, createUdf, dbTimeMillis, deprecated, deprecated, digestMd5, digestSha256, equal, equalName, equals, equals, explain, falseFunctor, filter, flatList, flatList, flatListCopy, generateUuidString, genericArray, getAnnotation, getClosestResource, getDimensionCube, getErrorMessage, getErrorMessage, getExecutorService, getFirstDescendantOnLevel, getMatchingCause, getMemberOrdinalInParent, getMemoryInfo, getScheduledExecutorService, hash, hash, hashArray, identityFunctor, implode, intersect, isBlank, isEmpty, isNull, isSorted, isValidProperty, last, lookup, lookup, lookup, lookup, lookup, lookupCompound, lookupCompound, lookupHierarchyLevel, lookupHierarchyRootMember, lookupHierarchyRootMember, lookupProperty, makeAppender, makeBigDecimalFromDouble, makeFqName, makeFqName, makeFqName, matches, matches, mdxEncodeString, needToImplement, newElementNotFoundException, newError, newError, newIdentityHashSet, newIdentityHashSetFake, newInternal, newInternal, newTimer, nonDbTimeMillis, normalizeName, only, parseCommaList, parseConnectString, parseIdentifier, parseInterval, parseLocale, printMemory, printMemory, quoteForMdx, quoteForMdx, quoteJavaString, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quotePattern, readFully, readFully, readURL, readURL, readURL, readVirtualFile, readVirtualFileAsString, removeAppender, replace, replace, replaceProperties, safeGet, setLevel, singleQuoteString, singleQuoteString, sort, sort, threadLocalRemove, toMap, toNullValuesMap, toOlap4j, toOlap4j, toOlap4j, toURL, trueFunctor, unexpected, uniquify, unparse, unparse, wildcardToRegexp
Methods inherited from class org.eigenbase.xom.XOMUtil
addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, wrapperToXml
Methods inherited from class org.eigenbase.xom.XMLUtil
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials
-
Field Details
-
NullMember
public static final mondrian.olap.fun.FunUtil.NullMember NullMember -
DoubleNull
public static final double DoubleNullSpecial value which indicates that adouble
computation has returned the MDX null value. SeeDoubleCalc
.- See Also:
-
DoubleEmpty
public static final double DoubleEmptySpecial value which indicates that adouble
computation has returned the MDX EMPTY value. SeeDoubleCalc
.- See Also:
-
IntegerNull
public static final int IntegerNullSpecial value which indicates that anint
computation has returned the MDX null value. SeeIntegerCalc
.- See Also:
-
BooleanNull
public static final boolean BooleanNullNull value in three-valued boolean logic. Actually, a placeholder until we actually implement 3VL.- See Also:
-
-
Constructor Details
-
FunUtil
public FunUtil()
-
-
Method Details
-
newEvalException
Creates an exception which indicates that an error has occurred while executing a given function.- Parameters:
funDef
- Function being executedmessage
- Explanatory message- Returns:
- Exception that can be used as a cell result
-
newEvalException
Creates an exception which indicates that an error has occurred while executing a given function.- Parameters:
throwable
- Exception- Returns:
- Exception that can be used as a cell result
-
newEvalException
Creates an exception which indicates that an error has occurred while executing a given function.- Parameters:
message
- Explanatory messagethrowable
- Exception- Returns:
- Exception that can be used as a cell result
-
checkIterListResultStyles
-
checkListResultStyles
-
getDimensionDefaultHierarchy
Returns the default hierarchy of a dimension, or null if there is no default.- Parameters:
dimension
- Dimension- Returns:
- Default hierarchy, or null
- See Also:
-
isAncestorOf
Returns whetherm0
is an ancestor ofm1
.- Parameters:
strict
- if true, a member is not an ancestor of itself
-
compareValues
public static int compareValues(double d1, double d2) Compares double-precision values according to MDX semantics.MDX requires a total order:
-inf < NULL < ... < -1 < ... < 0 < ... < NaN < +inf
but this is different than Java semantics, specifically with regard toDouble.NaN
. -
compareValues
Compares two cell values.Nulls compare last, exceptions (including the object which indicates the the cell is not in the cache yet) next, then numbers and strings are compared by value.
- Parameters:
value0
- First cell valuevalue1
- Second cell value- Returns:
- -1, 0, or 1, depending upon whether first cell value is less than, equal to, or greater than the second
-
decodeSyntacticType
Decodes the syntactic type of an operator.- Parameters:
flags
- A encoded string which represents an operator signature, as used by theflags
parameter used to construct aFunDefBase
.- Returns:
- A
Syntax
-
decodeReturnCategory
Decodes the signature of a function into a category code which describes the return type of the operator.For example,
decodeReturnType("fnx")
returns
, indicating this function has a numeric return value.Category.Numeric
- Parameters:
flags
- The signature of an operator, as used by theflags
parameter used to construct aFunDefBase
.- Returns:
- An array
Category
codes.
-
decodeCategory
Decodes theoffset
th character of an encoded method signature into a type category.The codes are:
- Parameters:
flags
- Encoded signature stringoffset
- 0-based offset of character within string- Returns:
- A
Category
-
decodeParameterCategories
Decodes a string of parameter types into an array of type codes.Each character is decoded using
decodeCategory(String, int)
. For example,decodeParameterTypes("nx")
returns{
.Category.Numeric
,Category.Set
}- Parameters:
flags
- The signature of an operator, as used by theflags
parameter used to construct aFunDefBase
.- Returns:
- An array
Category
codes.
-
box
Converts a double (primitive) value to a Double.DoubleNull
becomes null. -
box
Converts an int (primitive) value to an Integer.IntegerNull
becomes null. -
quartile
Returns the member which lies upon a particular quartile according to a given expression.- Parameters:
evaluator
- Evaluatormembers
- List of membersexp
- Expression to rank membersrange
- Quartile (1, 2 or 3)
-
min
-
max
-
avg
-
sum
-
sumDouble
-
sumDouble
-
count
-
compareHierarchically
Compares a pair of members according to their positions in a prefix-order (or postfix-order, ifpost
is true) walk over a hierarchy.- Parameters:
m1
- First memberm2
- Second memberpost
- Whether to sortMembers in postfix order. If true, a parent will sortMembers immediately after its last child. If false, a parent will sortMembers immediately before its first child.- Returns:
- -1 if m1 collates before m2, 0 if m1 equals m2, 1 if m1 collates after m2
-
compareSiblingMembers
Compares two members which are known to have the same parent.First, compare by ordinal. This is only valid now we know they're siblings, because ordinals are only unique within a parent. If the dimension does not use ordinals, both ordinals will be -1.
If the ordinals do not differ, compare using regular member comparison.
- Parameters:
m1
- First memberm2
- Second member- Returns:
- -1 if m1 collates less than m2, 1 if m1 collates after m2, 0 if m1 == m2.
-
tupleContainsNullMember
Returns whether one of the members in a tuple is null. -
tupleContainsNullMember
Returns whether one of the members in a tuple is null. -
makeNullTuple
-
resolveFunArgs
public static FunDef resolveFunArgs(Validator validator, FunDef funDef, Exp[] args, Exp[] newArgs, String name, Syntax syntax) Validates the arguments to a function and resolves the function.- Parameters:
validator
- Validator used to validate function arguments and resolve the functionfunDef
- Function definition, or null to deduce definition from name, syntax and argument typesargs
- Arguments to the functionnewArgs
- Output parameter for the resolved argumentsname
- Function namesyntax
- Syntax style used to invoke function- Returns:
- resolved function definition
-
getNonEmptyMemberChildren
-
getNonEmptyMemberChildrenWithDetails
-
worthCaching
Returns whether an expression is worth wrapping in "Cache( ... )".- Parameters:
exp
- Expression- Returns:
- Whether worth caching
-