|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.xom.XMLUtil org.eigenbase.xom.XOMUtil mondrian.olap.Util mondrian.olap.fun.FunUtil
public class FunUtil
FunUtil
contains a set of methods useful within the
mondrian.olap.fun
package.
Nested Class Summary | |
---|---|
(package private) static class |
FunUtil.SetWrapper
|
Nested classes/interfaces inherited from class mondrian.olap.Util |
---|
Util.ErrorCellValue, Util.PropertyList |
Field Summary | |
---|---|
static boolean |
BooleanNull
Null value in three-valued boolean logic. |
static double |
DoubleEmpty
Special value which indicates that a double computation
has returned the MDX EMPTY value. |
static double |
DoubleNull
Special value which indicates that a double computation
has returned the MDX null value. |
(package private) static String[] |
emptyStringArray
|
static int |
IntegerNull
Special value which indicates that an int computation
has returned the MDX null value. |
static mondrian.olap.fun.FunUtil.NullMember |
NullMember
|
Fields inherited from class mondrian.olap.Util |
---|
EmptyValue, JdbcVersion, nl, nullValue, PreJdk15, Retrowoven |
Constructor Summary | |
---|---|
FunUtil()
|
Method Summary | ||
---|---|---|
(package private) static List<Member> |
addMembers(SchemaReader schemaReader,
List<Member> members,
Hierarchy hierarchy)
|
|
(package private) static List<Member> |
addMembers(SchemaReader schemaReader,
List<Member> members,
Level level)
|
|
(package private) static
|
addUnique(List<T> left,
List<T> right,
Set<Object> set)
Adds every element of right which is not in set
to both set and left . |
|
(package private) static Member |
ancestor(Evaluator evaluator,
Member member,
int distance,
Level targetLevel)
Returns the ancestor of member at the given level
or distance. |
|
(package private) static void |
appendTuple(StringBuilder buf,
Member[] members)
|
|
static Object |
avg(Evaluator evaluator,
List members,
Calc calc)
|
|
(package private) static void |
checkCompatible(Exp left,
Exp right,
FunDef funDef)
Throws an error if the expressions don't have the same hierarchy. |
|
(package private) static boolean |
checkFlag(int value,
int mask,
boolean strict)
Returns true if the mask in flag is set. |
|
static void |
checkIterListResultStyles(Calc calc)
|
|
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, if post 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(int i,
int j)
|
|
static int |
compareValues(Object value0,
Object value1)
Compares two cell values. |
|
(package private) static double |
correlation(Evaluator evaluator,
List memberList,
Calc exp1,
Calc exp2)
|
|
static int |
count(Evaluator evaluator,
Iterable iterable,
boolean includeEmpty)
|
|
(package private) static Member |
cousin(SchemaReader schemaReader,
Member member,
Member ancestorMember)
Returns the member under ancestorMember having the same relative position under member's parent. |
|
(package private) static Object |
covariance(Evaluator evaluator,
List members,
Calc exp1,
Calc exp2,
boolean biased)
|
|
(package private) static FunDef |
createDummyFunDef(Resolver resolver,
int returnCategory,
Exp[] args)
|
|
static int |
decodeCategory(String flags,
int offset)
Decodes the offset 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. |
|
(package private) static List<Member> |
dimensionMembers(Dimension dimension,
Evaluator evaluator,
boolean includeCalcMembers)
|
|
(package private) static boolean |
equalTuple(Member[] members0,
Member[] members1)
Returns whether two tuples are equal. |
|
(package private) static Map<Member,Object> |
evaluateMembers(Evaluator evaluator,
Calc exp,
List<Member> members,
boolean parentsToo)
For each member in a list, evaluate an expression and create a map from members to values. |
|
(package private) static Map<Member,Object> |
evaluateMembers(Evaluator evaluator,
List<Member> members,
boolean parentsToo)
|
|
(package private) static FunUtil.SetWrapper |
evaluateSet(Evaluator evaluator,
Iterable members,
Calc calc)
Evaluates exp (if defined) over members to
generate a List of FunUtil.SetWrapper objects, which contains
a Double value and meta information, unlike
evaluateMembers(mondrian.olap.Evaluator, mondrian.calc.Calc, java.util.List , which only produces values. |
|
(package private) static FunUtil.SetWrapper[] |
evaluateSet(Evaluator evaluator,
List members,
DoubleCalc[] calcs,
boolean isTuples)
Evaluates one or more expressions against the member list returning a SetWrapper array. |
|
(package private) static Map<Object,Object> |
evaluateTuples(Evaluator evaluator,
Calc exp,
List<Member[]> members)
For each tuple in a list, evaluates an expression and creates a map from tuples to values. |
|
(package private) static
|
getLiteralArg(ResolvedFunCall call,
int i,
E defaultValue,
Class<E> allowedValues)
Returns the ordinal of a literal argument. |
|
(package private) static String |
getLiteralArg(ResolvedFunCall call,
int i,
String defaultValue,
String[] allowedValues)
Returns an argument whose value is a literal. |
|
(package private) static List<Member> |
getNonEmptyLevelMembers(Evaluator evaluator,
Level level,
boolean includeCalcMembers)
Returns members of a level which are not empty (according to the criteria expressed by the evaluator). |
|
static List<Member> |
getNonEmptyMemberChildren(Evaluator evaluator,
Member member)
|
|
static void |
hierarchize(List members,
boolean post)
|
|
(package private) static List<Member> |
hierarchyMembers(Hierarchy hierarchy,
Evaluator evaluator,
boolean includeCalcMembers)
|
|
(package private) static boolean |
isAncestorOf(Member m0,
Member m1,
boolean strict)
Returns whether m0 is an ancestor of m1 . |
|
static boolean |
isMemberType(Calc calc)
|
|
(package private) static List<Member> |
levelMembers(Level level,
Evaluator evaluator,
boolean includeCalcMembers)
|
|
(package private) static Member |
makeNullMember(MemberType memberType)
|
|
static Member[] |
makeNullTuple(TupleType tupleType)
|
|
static Object |
max(Evaluator evaluator,
List members,
Calc exp)
|
|
(package private) static List<Member> |
memberRange(Evaluator evaluator,
Member startMember,
Member endMember)
|
|
static Object |
min(Evaluator evaluator,
List members,
Calc calc)
|
|
static RuntimeException |
newEvalException(FunDef funDef,
String message)
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. |
|
(package private) static double |
percentile(Evaluator evaluator,
List members,
Calc exp,
double p)
|
|
(package private) static List<Member> |
periodsToDate(Evaluator evaluator,
Level level,
Member member)
|
|
protected static double |
quartile(Evaluator evaluator,
List members,
Calc exp,
int range)
Returns the member which lies upon a particular quartile according to a given expression. |
|
(package private) static List<Member> |
removeCalculatedMembers(List<Member> memberList)
Removes every member from a list which is calculated. |
|
static FunDef |
resolveFunArgs(Validator validator,
Exp[] args,
Exp[] newArgs,
String name,
Syntax syntax)
Validates the arguments to a function and resolves the function. |
|
static int |
searchValuesDesc(Object[] values,
Object value)
Binary searches an array of values. |
|
(package private) static int |
sign(double d)
|
|
(package private) static void |
sortMembers(Evaluator evaluator,
List<Member> members,
Calc exp,
boolean desc,
boolean brk)
Helper function to sortMembers a list of members according to an expression. |
|
static void |
sortTuples(Evaluator evaluator,
List<Member[]> tuples,
Calc exp,
boolean desc,
boolean brk,
int arity)
Helper function to sortMembers a list of members according to an expression. |
|
static void |
sortValuesDesc(Object[] values)
Sorts an array of values. |
|
(package private) static Object |
stdev(Evaluator evaluator,
List members,
Calc exp,
boolean biased)
|
|
static Object |
sum(Evaluator evaluator,
List members,
Calc exp)
|
|
static double |
sumDouble(Evaluator evaluator,
Iterable iterable,
Calc exp)
|
|
static double |
sumDouble(Evaluator evaluator,
List members,
Calc exp)
|
|
(package private) static void |
toPercent(List members,
Map mapMemberToValue,
boolean isMember)
Turns the mapped values into relative values (percentages) for easy use by the general topOrBottom function. |
|
(package private) static boolean |
tupleContainsNullMember(Member[] tuple)
Returns whether one of the members in a tuple is null. |
|
(package private) static Object |
var(Evaluator evaluator,
List members,
Calc exp,
boolean biased)
|
Methods inherited from class org.eigenbase.xom.XOMUtil |
---|
addAll, addAll, addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, toList, toVector, wrapperToXml |
Methods inherited from class org.eigenbase.xom.XMLUtil |
---|
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final String[] emptyStringArray
public static final mondrian.olap.fun.FunUtil.NullMember NullMember
public static final double DoubleNull
double
computation
has returned the MDX null value. See DoubleCalc
.
public static final double DoubleEmpty
double
computation
has returned the MDX EMPTY value. See DoubleCalc
.
public static final int IntegerNull
int
computation
has returned the MDX null value. See IntegerCalc
.
public static final boolean BooleanNull
Constructor Detail |
---|
public FunUtil()
Method Detail |
---|
public static RuntimeException newEvalException(FunDef funDef, String message)
public static RuntimeException newEvalException(Throwable throwable)
public static boolean isMemberType(Calc calc)
public static void checkIterListResultStyles(Calc calc)
public static void checkListResultStyles(Calc calc)
static String getLiteralArg(ResolvedFunCall call, int i, String defaultValue, String[] allowedValues)
static <E extends Enum<E>> E getLiteralArg(ResolvedFunCall call, int i, E defaultValue, Class<E> allowedValues)
static void checkCompatible(Exp left, Exp right, FunDef funDef)
MondrianEvaluationException
- if expressions don't have the same
hierarchyleft
- right
- static boolean checkFlag(int value, int mask, boolean strict)
true
if the mask in flag
is set.
value
- The value to check.mask
- The mask within value to look for.strict
- If true
all the bits in mask must be set. If
false
the method will return true
if any of the
bits in mask
are set.
true
if the correct bits in mask
are set.static <T> void addUnique(List<T> left, List<T> right, Set<Object> set)
right
which is not in set
to both set
and left
.
static List<Member> addMembers(SchemaReader schemaReader, List<Member> members, Hierarchy hierarchy)
static List<Member> addMembers(SchemaReader schemaReader, List<Member> members, Level level)
static List<Member> removeCalculatedMembers(List<Member> memberList)
memberList
- Member list
static boolean isAncestorOf(Member m0, Member m1, boolean strict)
m0
is an ancestor of m1
.
strict
- if true, a member is not an ancestor of itselfstatic Map<Member,Object> evaluateMembers(Evaluator evaluator, Calc exp, List<Member> members, boolean parentsToo)
If the list contains tuples, use
evaluateTuples(mondrian.olap.Evaluator, mondrian.calc.Calc, java.util.List)
.
evaluator
- Evaluation contextexp
- Expression to evaluatemembers
- List of membersparentsToo
- If true, evaluate the expression for all ancestors
of the members as wellstatic Map<Object,Object> evaluateTuples(Evaluator evaluator, Calc exp, List<Member[]> members)
evaluator
- Evaluation contextexp
- Expression to evaluatemembers
- List of members (or List of Member[] tuples)static Map<Member,Object> evaluateMembers(Evaluator evaluator, List<Member> members, boolean parentsToo)
static void sortMembers(Evaluator evaluator, List<Member> members, Calc exp, boolean desc, boolean brk)
NOTE: This function does not preserve the contents of the validator.
public static void sortTuples(Evaluator evaluator, List<Member[]> tuples, Calc exp, boolean desc, boolean brk, int arity)
NOTE: This function does not preserve the contents of the validator.
public static void hierarchize(List members, boolean post)
static int sign(double d)
public static int compareValues(double d1, double d2)
MDX requires a total order:
-inf < NULL < ... < -1 < ... < 0 < ... < NaN < +infbut this is different than Java semantics, specifically with regard to
Double.NaN
.
public static int compareValues(int i, int j)
public static int compareValues(Object value0, Object value1)
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.
value0
- First cell valuevalue1
- Second cell value
static void toPercent(List members, Map mapMemberToValue, boolean isMember)
public static Syntax decodeSyntacticType(String flags)
flags
- A encoded string which represents an operator signature,
as used by the flags
parameter used to construct a
FunDefBase
.
Syntax
public static int decodeReturnCategory(String flags)
For example, decodeReturnType("fnx")
returns
, indicating this function has a
numeric return value.
Category.Numeric
flags
- The signature of an operator,
as used by the flags
parameter used to construct a
FunDefBase
.
Category
codes.public static int decodeCategory(String flags, int offset)
offset
th character of an encoded method
signature into a type category.
The codes are:
flags
- Encoded signature stringoffset
- 0-based offset of character within string
Category
public static int[] decodeParameterCategories(String flags)
Each character is decoded using decodeCategory(String, int)
.
For example, decodeParameterTypes("nx")
returns
{
.
Category.Numeric
, Category.Set
}
flags
- The signature of an operator,
as used by the flags
parameter used to construct a
FunDefBase
.
Category
codes.public static void sortValuesDesc(Object[] values)
public static int searchValuesDesc(Object[] values, Object value)
static double percentile(Evaluator evaluator, List members, Calc exp, double p)
protected static double quartile(Evaluator evaluator, List members, Calc exp, int range)
evaluator
- Evaluatormembers
- List of membersexp
- Expression to rank membersrange
- Quartile (1, 2 or 3)public static Object min(Evaluator evaluator, List members, Calc calc)
public static Object max(Evaluator evaluator, List members, Calc exp)
static Object var(Evaluator evaluator, List members, Calc exp, boolean biased)
static double correlation(Evaluator evaluator, List memberList, Calc exp1, Calc exp2)
static Object covariance(Evaluator evaluator, List members, Calc exp1, Calc exp2, boolean biased)
static Object stdev(Evaluator evaluator, List members, Calc exp, boolean biased)
public static Object avg(Evaluator evaluator, List members, Calc calc)
public static Object sum(Evaluator evaluator, List members, Calc exp)
public static double sumDouble(Evaluator evaluator, List members, Calc exp)
public static double sumDouble(Evaluator evaluator, Iterable iterable, Calc exp)
public static int count(Evaluator evaluator, Iterable iterable, boolean includeEmpty)
static FunUtil.SetWrapper evaluateSet(Evaluator evaluator, Iterable members, Calc calc)
exp
(if defined) over members
to
generate a List
of FunUtil.SetWrapper
objects, which contains
a Double
value and meta information, unlike
evaluateMembers(mondrian.olap.Evaluator, mondrian.calc.Calc, java.util.List, boolean)
, which only produces values.
static FunUtil.SetWrapper[] evaluateSet(Evaluator evaluator, List members, DoubleCalc[] calcs, boolean isTuples)
static List<Member> periodsToDate(Evaluator evaluator, Level level, Member member)
static List<Member> memberRange(Evaluator evaluator, Member startMember, Member endMember)
static Member cousin(SchemaReader schemaReader, Member member, Member ancestorMember)
For exmaple, cousin([Feb 2001], [Q3 2001]) is [August 2001].
schemaReader
- The reader to usemember
- The member for which we'll find the cousin.ancestorMember
- The cousin's ancestor.
ancestorMember
in the same position under
ancestorMember
as member
is under its parent.static Member ancestor(Evaluator evaluator, Member member, int distance, Level targetLevel)
member
at the given level
or distance. It is assumed that any error checking required
has been done prior to calling this function.
This method takes into consideration the fact that there
may be intervening hidden members between member
and the ancestor. If targetLevel
is not null, then
the method will only return a member if the level at
distance
from the member is actually the
targetLevel
specified.
evaluator
- The evaluation contextmember
- The member for which the ancestor is to be founddistance
- The distance up the chain the ancestor is to
be found.targetLevel
- The desired targetLevel of the ancestor. If null
,
then the distance completely determines the desired ancestor.
null
if no such
ancestor exists.public static int compareHierarchically(Member m1, Member m2, boolean post)
post
is true) walk
over a hierarchy.
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.
public static int compareSiblingMembers(Member m1, Member m2)
If the ordinals do not differ, compare using regular member comparison.
m1
- First memberm2
- Second member
static boolean tupleContainsNullMember(Member[] tuple)
public static Member[] makeNullTuple(TupleType tupleType)
static Member makeNullMember(MemberType memberType)
public static FunDef resolveFunArgs(Validator validator, Exp[] args, Exp[] newArgs, String name, Syntax syntax)
validator
- validator used to validate function arguments and
resolve the functionargs
- arguments to the functionnewArgs
- returns the resolved arguments to the functionname
- function namesyntax
- syntax style used to invoke function
static void appendTuple(StringBuilder buf, Member[] members)
static boolean equalTuple(Member[] members0, Member[] members1)
The members are allowed to be in different positions. For example,
([Gender].[M], [Store].[USA]) IS ([Store].[USA], [Gender].[M])
returns true
.
static FunDef createDummyFunDef(Resolver resolver, int returnCategory, Exp[] args)
public static List<Member> getNonEmptyMemberChildren(Evaluator evaluator, Member member)
static List<Member> getNonEmptyLevelMembers(Evaluator evaluator, Level level, boolean includeCalcMembers)
evaluator
- Evaluator, determines non-empty criterialevel
- LevelincludeCalcMembers
- Whether to include calculated membersstatic List<Member> levelMembers(Level level, Evaluator evaluator, boolean includeCalcMembers)
static List<Member> hierarchyMembers(Hierarchy hierarchy, Evaluator evaluator, boolean includeCalcMembers)
static List<Member> dimensionMembers(Dimension dimension, Evaluator evaluator, boolean includeCalcMembers)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |