public class FunUtil extends Util
FunUtil
contains a set of methods useful within the mondrian.olap.fun
package.Modifier and Type | Class and Description |
---|---|
static class |
FunUtil.DescendingValueComparator
Compares cell values, so that larger values compare first.
|
(package private) static class |
FunUtil.Flag
Enumeration of the flags allowed to the
ORDER MDX function. |
static class |
FunUtil.ObjIntPair<T>
Tuple consisting of an object and an integer.
|
static class |
FunUtil.OrderKey |
(package private) static class |
FunUtil.Quicksorter<T>
A functional for
partialSort(T[], java.util.Comparator<T>, int) . |
(package private) static class |
FunUtil.SetWrapper |
(package private) static class |
FunUtil.SortKeySpec |
(package private) static class |
FunUtil.TupleExpMemoComparator |
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
Modifier and Type | Field and Description |
---|---|
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 |
DEBUG, EmptyValue, IBM_JVM, JdbcVersion, JVM_INSTANCE_UUID, nl, nullValue, Retrowoven
Constructor and Description |
---|
FunUtil() |
Modifier and Type | Method and Description |
---|---|
(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 void |
addUnique(TupleList left,
TupleList right,
Set<List<Member>> 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,
TupleList members,
Calc calc) |
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.
|
(package private) static void |
checkCompatible(Exp left,
Exp right,
FunDef funDef)
Throws an error if the expressions don't have the same hierarchy.
|
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(Object value0,
Object value1)
Compares two cell values.
|
(package private) static double |
correlation(Evaluator evaluator,
TupleList memberList,
Calc exp1,
Calc exp2) |
static int |
count(Evaluator evaluator,
TupleIterable 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,
TupleList 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 boolean |
equalTuple(Member[] members0,
Member[] members1)
Returns whether two tuples are equal.
|
(package private) static Map<Member,Object> |
evaluateMembers(Evaluator evaluator,
Calc exp,
Iterable<Member> memberIter,
List<Member> memberList,
boolean parentsToo)
For each member in a list, evaluates an expression and creates a map
from members to values.
|
(package private) static FunUtil.SetWrapper |
evaluateSet(Evaluator evaluator,
TupleIterable 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.lang.Iterable<mondrian.olap.Member>, java.util.List<mondrian.olap.Member>, boolean) , which only produces values. |
(package private) static FunUtil.SetWrapper[] |
evaluateSet(Evaluator evaluator,
TupleList list,
DoubleCalc[] calcs)
Evaluates one or more expressions against the member list returning
a SetWrapper array.
|
(package private) static Map<List<Member>,Object> |
evaluateTuples(Evaluator evaluator,
Calc exp,
TupleList tuples)
For each tuple in a list, evaluates an expression and creates a map
from tuples to values.
|
static Hierarchy |
getDimensionDefaultHierarchy(Dimension dimension)
Returns the default hierarchy of a dimension, or null if there is no
default.
|
(package private) static <E extends Enum<E>> |
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 Map<Member,Access> |
getNonEmptyMemberChildrenWithDetails(Evaluator evaluator,
Member member) |
static void |
hierarchizeMemberList(List<Member> memberList,
boolean post)
Sorts a list of members into hierarchical order.
|
static TupleList |
hierarchizeTupleList(TupleList tupleList,
boolean post)
Sorts a list of tuples into hierarchical order.
|
(package private) static TupleList |
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 . |
(package private) static TupleList |
levelMembers(Level level,
Evaluator evaluator,
boolean includeCalcMembers) |
(package private) static Member |
makeNullMember(MemberType memberType) |
static Member[] |
makeNullTuple(TupleType tupleType) |
static Object |
max(Evaluator evaluator,
TupleList members,
Calc exp) |
(package private) static List<Member> |
memberRange(Evaluator evaluator,
Member startMember,
Member endMember) |
static Object |
min(Evaluator evaluator,
TupleList 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(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.
|
(package private) static Member |
parseMember(Evaluator evaluator,
String string,
Hierarchy hierarchy) |
(package private) static List<Member> |
parseMemberList(Evaluator evaluator,
String string,
Hierarchy hierarchy) |
(package private) static Member[] |
parseTuple(Evaluator evaluator,
String string,
List<Hierarchy> hierarchies)
Parses a tuple, such as "([Gender].[M], [Marital Status].[S])".
|
(package private) static TupleList |
parseTupleList(Evaluator evaluator,
String string,
List<Hierarchy> hierarchies) |
static List<Member> |
partiallySortMembers(Evaluator evaluator,
List<Member> list,
Calc exp,
int limit,
boolean desc)
Partially sorts a list of Members by the value of an applied expression.
|
static List<List<Member>> |
partiallySortTuples(Evaluator evaluator,
TupleList list,
Calc exp,
int limit,
boolean desc)
Partially sorts a list of Tuples by the value of an applied expression.
|
(package private) static <T> void |
partialSort(T[] items,
Comparator<T> comp,
int limit)
Partial Sort: sorts in place an array of Objects using a given Comparator,
but only enough so that the N biggest (or smallest) items are at the start
of the array.
|
(package private) static double |
percentile(Evaluator evaluator,
TupleList members,
Calc exp,
double p) |
(package private) static List<Member> |
periodsToDate(Evaluator evaluator,
Level level,
Member member) |
protected static double |
quartile(Evaluator evaluator,
TupleList 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.
|
(package private) static TupleList |
removeCalculatedMembers(TupleList memberList)
Removes every tuple from a list which is calculated.
|
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.
|
(package private) static List<Member> |
sortMembers(Evaluator evaluator,
Iterable<Member> memberIter,
List<Member> memberList,
Calc exp,
boolean desc,
boolean brk)
Helper function to sort a list of members according to an expression.
|
(package private) static List<Member> |
sortMembers(Evaluator evaluator,
Iterable<Member> memberIter,
List<Member> memberList,
List<FunUtil.SortKeySpec> keySpecList)
Sorts a list of members according to a list of SortKeySpecs.
|
static TupleList |
sortTuples(Evaluator evaluator,
TupleIterable tupleIterable,
TupleList tupleList,
Calc exp,
boolean desc,
boolean brk,
int arity)
Sorts a list of Tuples by the value of an applied expression.
|
(package private) static TupleList |
sortTuples(Evaluator evaluator,
TupleIterable tupleIter,
TupleList tupleList,
List<FunUtil.SortKeySpec> keySpecList,
int arity)
Helper function to sort a list of tuples according to a list
of expressions and a list of sorting flags.
|
static <T> List<T> |
stablePartialSort(List<T> list,
Comparator<T> comp,
int limit)
Stable partial sort of a list.
|
static <T> List<T> |
stablePartialSort(List<T> list,
Comparator<T> comp,
int limit,
int algorithm)
Stable partial sort of a list, using a specified algorithm.
|
static <T> List<T> |
stablePartialSortArray(List<T> list,
Comparator<T> comp,
int limit)
Partial sort an array by sorting it and returning the first
limit
elements. |
static <T> List<T> |
stablePartialSortJulian(List<T> list,
Comparator<T> comp,
int limit)
Julian's algorithm for stable partial sort.
|
static <T> List<T> |
stablePartialSortMarc(List<T> list,
Comparator<T> comp,
int limit)
Marc's original algorithm for stable partial sort of a list.
|
static <T> List<T> |
stablePartialSortPedro(List<T> list,
Comparator<T> comp,
int limit)
Pedro's algorithm for stably sorting the top
limit items in
a list. |
(package private) static Object |
stdev(Evaluator evaluator,
TupleList members,
Calc exp,
boolean biased) |
static Object |
sum(Evaluator evaluator,
TupleList members,
Calc exp) |
static double |
sumDouble(Evaluator evaluator,
TupleIterable iterable,
Calc exp) |
static double |
sumDouble(Evaluator evaluator,
TupleList members,
Calc exp) |
(package private) static void |
toPercent(TupleList members,
Map<List<Member>,Object> mapMemberToValue)
Turns the mapped values into relative values (percentages) for easy
use by the general topOrBottom function.
|
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.
|
(package private) static Object |
var(Evaluator evaluator,
TupleList members,
Calc exp,
boolean biased) |
static boolean |
worthCaching(Exp exp)
Returns whether an expression is worth wrapping in "Cache( ...
|
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, 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, 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, replace, replace, replaceProperties, safeGet, singleQuoteString, singleQuoteString, sort, sort, threadLocalRemove, toMap, toNullValuesMap, toOlap4j, toOlap4j, toOlap4j, toURL, trueFunctor, unexpected, uniquify, unparse, unparse, wildcardToRegexp
addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, wrapperToXml
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials
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
public static RuntimeException newEvalException(FunDef funDef, String message)
funDef
- Function being executedmessage
- Explanatory messagepublic static RuntimeException newEvalException(Throwable throwable)
throwable
- Exceptionpublic static RuntimeException newEvalException(String message, Throwable throwable)
message
- Explanatory messagethrowable
- Exceptionpublic 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
hierarchystatic void addUnique(TupleList left, TupleList right, Set<List<Member>> set)
right
which is not in set
to both set
and left
.public static Hierarchy getDimensionDefaultHierarchy(Dimension dimension)
dimension
- DimensionMondrianResource.CannotImplicitlyConvertDimensionToHierarchy
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 liststatic TupleList removeCalculatedMembers(TupleList memberList)
memberList
- Member liststatic 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, Iterable<Member> memberIter, List<Member> memberList, boolean parentsToo)
If the list contains tuples, use
evaluateTuples(mondrian.olap.Evaluator, mondrian.calc.Calc, mondrian.calc.TupleList)
.
evaluator
- Evaluation contextexp
- Expression to evaluatememberIter
- Iterable over the collection of membersmemberList
- List to be populated with members, or nullparentsToo
- If true, evaluate the expression for all ancestors
of the members as wellstatic Map<List<Member>,Object> evaluateTuples(Evaluator evaluator, Calc exp, TupleList tuples)
evaluator
- Evaluation contextexp
- Expression to evaluatetuples
- List of tuplesstatic List<Member> sortMembers(Evaluator evaluator, Iterable<Member> memberIter, List<Member> memberList, Calc exp, boolean desc, boolean brk)
NOTE: This function does not preserve the contents of the validator.
If you do not specify memberList
, the method
will build its own member list as it iterates over memberIter
.
It is acceptable if memberList
and memberIter
are the
same list object.
If you specify memberList
, the list is sorted in place, and
memberList is returned.
evaluator
- EvaluatormemberIter
- Iterable over membersmemberList
- List of membersexp
- Expression to sort ondesc
- Whether to sort descendingbrk
- Whether to breakstatic List<Member> sortMembers(Evaluator evaluator, Iterable<Member> memberIter, List<Member> memberList, List<FunUtil.SortKeySpec> keySpecList)
NOTE: Does not preserve the contents of the validator.
public static TupleList sortTuples(Evaluator evaluator, TupleIterable tupleIterable, TupleList tupleList, Calc exp, boolean desc, boolean brk, int arity)
Helper function for MDX functions TopCount, TopSum, TopPercent, BottomCount, BottomSum, BottomPercent, but not the MDX function Order.
NOTE: This function does not preserve the contents of the validator.
If you specify tupleList
, the list is sorted in place, and
tupleList is returned.
evaluator
- EvaluatortupleIterable
- Iterator over tuplestupleList
- List of tuples, if known, otherwise nullexp
- Expression to sort ondesc
- Whether to sort descendingbrk
- Whether to breakarity
- Number of members in each tuplepublic static List<Member> partiallySortMembers(Evaluator evaluator, List<Member> list, Calc exp, int limit, boolean desc)
Avoids sorting the whole list, finds only the ntop (or bottom) valued Members, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount.
NOTE: Does not preserve the contents of the validator.
list
- a list of membersexp
- a Calc applied to each member to find its sort-keyevaluator
- Evaluatorlimit
- maximum count of members to return.desc
- true to sort descending (and find TopCount), false to sort
ascending (and find BottomCount).static TupleList sortTuples(Evaluator evaluator, TupleIterable tupleIter, TupleList tupleList, List<FunUtil.SortKeySpec> keySpecList, int arity)
NOTE: This function does not preserve the contents of the validator.
public static List<List<Member>> partiallySortTuples(Evaluator evaluator, TupleList list, Calc exp, int limit, boolean desc)
Avoids sorting the whole list, finds only the n top (or bottom) valued Tuples, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount.
NOTE: Does not preserve the contents of the validator. The returned list is immutable.
evaluator
- Evaluatorlist
- a list of tuplesexp
- a Calc applied to each tuple to find its sort-keylimit
- maximum count of tuples to return.desc
- true to sort descending (and find TopCount),
false to sort ascending (and find BottomCount).public static void hierarchizeMemberList(List<Member> memberList, boolean post)
memberList
- List of memberspost
- Whether to sort in post order; if false, sorts in pre orderhierarchizeTupleList(mondrian.calc.TupleList, boolean)
public static TupleList hierarchizeTupleList(TupleList tupleList, boolean post)
tupleList
- List of tuplespost
- Whether to sort in post order; if false, sorts in pre orderhierarchizeMemberList(java.util.List, boolean)
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(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 valuestatic void toPercent(TupleList members, Map<List<Member>,Object> mapMemberToValue)
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 stringCategory
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 Double box(double d)
DoubleNull
becomes null.public static Integer box(int n)
IntegerNull
becomes null.protected static double quartile(Evaluator evaluator, TupleList members, Calc exp, int range)
evaluator
- Evaluatormembers
- List of membersexp
- Expression to rank membersrange
- Quartile (1, 2 or 3)static double correlation(Evaluator evaluator, TupleList memberList, Calc exp1, Calc exp2)
static Object covariance(Evaluator evaluator, TupleList members, Calc exp1, Calc exp2, boolean biased)
public static double sumDouble(Evaluator evaluator, TupleIterable iterable, Calc exp)
public static int count(Evaluator evaluator, TupleIterable iterable, boolean includeEmpty)
static FunUtil.SetWrapper evaluateSet(Evaluator evaluator, TupleIterable 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.lang.Iterable<mondrian.olap.Member>, java.util.List<mondrian.olap.Member>, boolean)
, which only produces values.static FunUtil.SetWrapper[] evaluateSet(Evaluator evaluator, TupleList list, DoubleCalc[] calcs)
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 memberpublic static boolean tupleContainsNullMember(Member[] tuple)
public static boolean tupleContainsNullMember(List<Member> tuple)
static Member makeNullMember(MemberType memberType)
public static FunDef resolveFunArgs(Validator validator, FunDef funDef, Exp[] args, Exp[] newArgs, String name, Syntax syntax)
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 functionstatic 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)
public static Map<Member,Access> getNonEmptyMemberChildrenWithDetails(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 TupleList levelMembers(Level level, Evaluator evaluator, boolean includeCalcMembers)
static TupleList hierarchyMembers(Hierarchy hierarchy, Evaluator evaluator, boolean includeCalcMembers)
static <T> void partialSort(T[] items, Comparator<T> comp, int limit)
items
- will be partially-sorted in placecomp
- a Comparator; null means use natural comparisonpublic static <T> List<T> stablePartialSort(List<T> list, Comparator<T> comp, int limit)
public static <T> List<T> stablePartialSort(List<T> list, Comparator<T> comp, int limit, int algorithm)
public static <T> List<T> stablePartialSortArray(List<T> list, Comparator<T> comp, int limit)
limit
elements. Fastest approach if limit is a significant fraction of the
list.public static <T> List<T> stablePartialSortMarc(List<T> list, Comparator<T> comp, int limit)
stablePartialSortJulian(java.util.List<T>, java.util.Comparator<T>, int)
.public static <T> List<T> stablePartialSortPedro(List<T> list, Comparator<T> comp, int limit)
limit
items in
a list.public static <T> List<T> stablePartialSortJulian(List<T> list, Comparator<T> comp, int limit)
limit
items seen.
The items on the priority queue have an ordinal field, so the queue
can be used to generate a list of stably sorted items. (Heap sort is
not normally stable.)T
- Element typelist
- List to sortcomp
- Comparatorlimit
- Maximum number of items to returnstatic TupleList parseTupleList(Evaluator evaluator, String string, List<Hierarchy> hierarchies)
static Member[] parseTuple(Evaluator evaluator, String string, List<Hierarchy> hierarchies)
evaluator
- Evaluator, provides a SchemaReader
and Cube
string
- String to parsehierarchies
- Hierarchies of the membersstatic List<Member> parseMemberList(Evaluator evaluator, String string, Hierarchy hierarchy)
public static boolean worthCaching(Exp exp)
exp
- Expression