mondrian.olap.fun
Class CrossJoinFunDef

java.lang.Object
  extended by org.eigenbase.xom.XMLUtil
      extended by org.eigenbase.xom.XOMUtil
          extended by mondrian.olap.Util
              extended by mondrian.olap.fun.FunUtil
                  extended by mondrian.olap.fun.FunDefBase
                      extended by mondrian.olap.fun.CrossJoinFunDef
All Implemented Interfaces:
FunDef
Direct Known Subclasses:
NonEmptyCrossJoinFunDef

public class CrossJoinFunDef
extends FunDefBase

Definition of the CrossJoin MDX function.

Since:
Mar 23, 2006
Author:
jhyde
 

Nested Class Summary
 class CrossJoinFunDef.BaseImmutableList
           
(package private)  class CrossJoinFunDef.BaseListCalc
           
(package private)  class CrossJoinFunDef.BaseMemberArrayMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.BaseMemberArrayMemberIterCalc
           
(package private)  class CrossJoinFunDef.BaseMemberMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.BaseMemberMemberIterCalc
           
 class CrossJoinFunDef.BaseMutableList
          A BaseMutableList can be sorted, its elements rearranged, but its size can not be changed (the add or remove methods are not supported).
(package private)  class CrossJoinFunDef.ImmutableListMemberArrayListMemberArrayListCalc
           
(package private)  class CrossJoinFunDef.ImmutableListMemberArrayListMemberListCalc
           
(package private)  class CrossJoinFunDef.ImmutableListMemberListMemberArrayListCalc
           
(package private)  class CrossJoinFunDef.ImmutableListMemberListMemberListCalc
           
(package private)  class CrossJoinFunDef.IterMemberArrayIterMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberArrayIterMemberIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberArrayListMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberArrayListMemberIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberIterMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberIterMemberIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberListMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.IterMemberListMemberIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberArrayIterMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberArrayIterMemberIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberArrayListMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberArrayListMemberIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberIterMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberIterMemberIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberListMemberArrayIterCalc
           
(package private)  class CrossJoinFunDef.ListMemberListMemberIterCalc
           
(package private)  class CrossJoinFunDef.MutableListMemberArrayListMemberArrayListCalc
           
(package private)  class CrossJoinFunDef.MutableListMemberArrayListMemberListCalc
           
(package private)  class CrossJoinFunDef.MutableListMemberListMemberArrayListCalc
           
(package private)  class CrossJoinFunDef.MutableListMemberListMemberListCalc
           
 
Nested classes/interfaces inherited from class mondrian.olap.fun.FunUtil
FunUtil.SetWrapper
 
Nested classes/interfaces inherited from class mondrian.olap.Util
Util.ErrorCellValue, Util.PropertyList
 
Field Summary
(package private) static ReflectiveMultiResolver Resolver
           
(package private) static mondrian.olap.fun.CrossJoinFunDef.StarCrossJoinResolver StarResolver
           
 
Fields inherited from class mondrian.olap.fun.FunDefBase
flags, parameterCategories, returnCategory, signature
 
Fields inherited from class mondrian.olap.fun.FunUtil
BooleanNull, DoubleEmpty, DoubleNull, emptyStringArray, IntegerNull, NullMember
 
Fields inherited from class mondrian.olap.Util
EmptyValue, JdbcVersion, nl, nullValue, PreJdk15, Retrowoven
 
Constructor Summary
CrossJoinFunDef(FunDef dummyFunDef)
           
 
Method Summary
 Calc compileCall(ResolvedFunCall call, ExpCompiler compiler)
          Converts a call to this function into executable objects.
protected  ListCalc compileCallImmutableList(ResolvedFunCall call, ExpCompiler compiler)
           
protected  IterCalc compileCallIterable(ResolvedFunCall call, ExpCompiler compiler)
           
protected  ListCalc compileCallMutableList(ResolvedFunCall call, ExpCompiler compiler)
           
static List<Member[]> crossJoin(List list1, List list2)
           
 Type getResultType(Validator validator, Exp[] args)
          Returns the type of a call to this function with a given set of arguments.

The default implementation makes the coarse assumption that the return type is in some way related to the type of the first argument.

protected
<T> List<T>
nonEmptyList(Evaluator evaluator, List<T> list, ResolvedFunCall call)
          This is the entry point to the crossjoin non-empty optimizer code.
protected  List nonEmptyOptimizeList(Evaluator evaluator, List list, ResolvedFunCall call)
           
 
Methods inherited from class mondrian.olap.fun.FunDefBase
castType, createCall, getDescription, getName, getParameterCategories, getReturnCategory, getSignature, getSyntax, unparse, validateArg
 
Methods inherited from class mondrian.olap.fun.FunUtil
addMembers, addMembers, addUnique, ancestor, appendTuple, avg, checkCompatible, checkFlag, checkIterListResultStyles, checkListResultStyles, compareHierarchically, compareSiblingMembers, compareValues, compareValues, compareValues, correlation, count, cousin, covariance, createDummyFunDef, decodeCategory, decodeParameterCategories, decodeReturnCategory, decodeSyntacticType, dimensionMembers, equalTuple, evaluateMembers, evaluateMembers, evaluateSet, evaluateSet, evaluateTuples, getLiteralArg, getLiteralArg, getNonEmptyLevelMembers, getNonEmptyMemberChildren, hierarchize, hierarchyMembers, isAncestorOf, isMemberType, levelMembers, makeNullMember, makeNullTuple, max, memberRange, min, newEvalException, newEvalException, percentile, periodsToDate, quartile, removeCalculatedMembers, resolveFunArgs, searchValuesDesc, sign, sortMembers, sortTuples, sortValuesDesc, stdev, sum, sumDouble, sumDouble, toPercent, tupleContainsNullMember, var
 
Methods inherited from class mondrian.olap.Util
addDatabaseTime, addLevelCalculatedMembers, areOccurencesEqual, assertPostcondition, assertPostcondition, assertPrecondition, assertPrecondition, assertTrue, assertTrue, badValue, camelToUpper, caseSensitiveCompareName, cast, cast, checkCJResultLimit, commaList, compareKey, compareName, convertStackToString, createExpr, createRandom, createSimpleValidator, createUdf, dbTimeMillis, deprecated, enumSetAllOf, enumSetNoneOf, enumSetOf, equal, equalName, equals, equals, getAnnotation, getErrorMessage, getErrorMessage, getFirstDescendantOnLevel, getMemberOrdinalInParent, hash, hash, hashArray, implode, isEmpty, isNull, isSorted, isValidProperty, lookup, lookup, lookup, lookup, lookupCompound, lookupCompound, lookupHierarchyLevel, lookupHierarchyRootMember, lookupHierarchyRootMember, lookupProperty, makeBigDecimalFromDouble, makeFqName, makeFqName, makeFqName, maskVersion, mdxEncodeString, needToImplement, newError, newError, newInternal, newInternal, nonDbTimeMillis, normalizeName, parseCommaList, parseConnectString, parseIdentifier, printMemory, printMemory, quoteForMdx, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quotePattern, readFully, readURL, readURL, readURL, readURL, replace, replace, replaceProperties, singleQuoteString, singleQuoteString, toMap, toURL, unexpected, union, union, uniquify, unparse, unparse, wildcardToRegexp
 
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

Resolver

static final ReflectiveMultiResolver Resolver

StarResolver

static final mondrian.olap.fun.CrossJoinFunDef.StarCrossJoinResolver StarResolver
Constructor Detail

CrossJoinFunDef

public CrossJoinFunDef(FunDef dummyFunDef)
Method Detail

getResultType

public Type getResultType(Validator validator,
                          Exp[] args)
Description copied from class: FunDefBase
Returns the type of a call to this function with a given set of arguments.

The default implementation makes the coarse assumption that the return type is in some way related to the type of the first argument. Operators whose arguments don't follow the requirements of this implementation should override this method.

If the function definition says it returns a literal type (numeric, string, symbol) then it's a fair guess that the function call returns the same kind of value.

If the function definition says it returns an object type (cube, dimension, hierarchy, level, member) then we check the first argument of the function. Suppose that the function definition says that it returns a hierarchy, and the first argument of the function happens to be a member. Then it's reasonable to assume that this function returns a member.

Overrides:
getResultType in class FunDefBase
Parameters:
validator - Validator
args - Arguments to the call to this operator
Returns:
result type of a call this function

compileCall

public Calc compileCall(ResolvedFunCall call,
                        ExpCompiler compiler)
Description copied from interface: FunDef
Converts a call to this function into executable objects.

The result must implement the appropriate interface for the result type. For example, a function which returns an integer must return an object which implements IntegerCalc.

Specified by:
compileCall in interface FunDef
Overrides:
compileCall in class FunDefBase

compileCallIterable

protected IterCalc compileCallIterable(ResolvedFunCall call,
                                       ExpCompiler compiler)

compileCallImmutableList

protected ListCalc compileCallImmutableList(ResolvedFunCall call,
                                            ExpCompiler compiler)

compileCallMutableList

protected ListCalc compileCallMutableList(ResolvedFunCall call,
                                          ExpCompiler compiler)

nonEmptyOptimizeList

protected List nonEmptyOptimizeList(Evaluator evaluator,
                                    List list,
                                    ResolvedFunCall call)

crossJoin

public static List<Member[]> crossJoin(List list1,
                                       List list2)

nonEmptyList

protected <T> List<T> nonEmptyList(Evaluator evaluator,
                                   List<T> list,
                                   ResolvedFunCall call)
This is the entry point to the crossjoin non-empty optimizer code.

What one wants to determine is for each individual Member of the input parameter list, a 'List-Member', whether across a slice there is any data.

But what data?

For Members other than those in the list, the 'non-List-Members', one wants to consider all data across the scope of these other Members. For instance, if Time is not a List-Member, then one wants to consider data across All Time. Or, if Customer is not a List-Member, then look at data across All Customers. The theory here, is if there is no data for a particular Member of the list where all other Members not part of the list are span their complete hierarchy, then there is certainly no data for Members of that Hierarchy at a more specific Level (more on this below).

When a Member that is a non-List-Member is part of a Hierarchy that has an All Member (hasAll="true"), then its very easy to make sure that the All Member is used during the optimization. If a non-List-Member is part of a Hierarchy that does not have an All Member, then one must, in fact, iterate over all top-level Members of the Hierarchy!!! - otherwise a List-Member might be excluded because the optimization code was not looking everywhere.

Concerning default Members for those Hierarchies for the non-List-Members, ignore them. What is wanted is either the All Member or one must iterate across all top-level Members, what happens to be the default Member of the Hierarchy is of no relevant.

The Measures Hierarchy has special considerations. First, there is no All Measure. But, certainly one need only involve Measures that are actually in the query... yes and no. For Calculated Measures one must also get all of the non-Calculated Measures that make up each Calculated Measure. Thus, one ends up iterating across all Calculated and non-Calculated Measures that are explicitly mentioned in the query as well as all Calculated and non-Calculated Measures that are used to define the Calculated Measures in the query. Why all of these? because this represents the total scope of possible Measures that might yield a non-null value for the List-Members and that is what we what to find. It might be a super set, but thats ok; we just do not want to miss anything.

For other Members, the default Member is used, but for Measures one should look for that data for all Measures associated with the query, not just one Measure. For a dense dataset this may not be a problem or even apparent, but for a sparse dataset, the first Measure may, in fact, have not data but other Measures associated with the query might. Hence, the solution here is to identify all Measures associated with the query and then for each Member of the list, determine if there is any data iterating across all Measures until non-null data is found or the end of the Measures is reached.

This is a non-optimistic implementation. This means that an element of the input parameter List is only not included in the returned result List if for no combination of Measures, non-All Members (for Hierarchies that have no All Members) and evaluator default Members did the element evaluate to non-null.

This method can be applied to members or tuples. Accordingly, the type parameter T can be either Member or Member[].

Parameters:
evaluator - Evaluator
list - List of members or tuples
call - Calling ResolvedFunCall used to determine what Measures to use
Returns:
List of elements from the input parameter list that have evaluated to non-null.

SourceForge.net_Logo