Package mondrian.olap.fun
Class FunDefBase
- java.lang.Object
-
- org.eigenbase.xom.XMLUtil
-
- org.eigenbase.xom.XOMUtil
-
- mondrian.olap.Util
-
- mondrian.olap.fun.FunUtil
-
- mondrian.olap.fun.FunDefBase
-
- All Implemented Interfaces:
FunDef
- Direct Known Subclasses:
AbstractAggregateFunDef,AddCalculatedMembersFunDef,AncestorFunDef,AncestorsFunDef,AsFunDef,CacheFunDef,CalculatedChildFunDef,CaseMatchFunDef,CaseTestFunDef,CastFunDef,CoalesceEmptyFunDef,CovarianceFunDef,CrossJoinFunDef,DescendantsFunDef,DimensionDimensionFunDef,DimensionsNumericFunDef,DimensionsStringFunDef,DistinctFunDef,DrilldownLevelFunDef,DrilldownLevelTopBottomFunDef,DrilldownMemberFunDef,ExceptFunDef,ExistsFunDef,ExtractFunDef,FilterFunDef,FormatFunDef,GenerateFunDef,HeadTailFunDef,HierarchizeFunDef,HierarchyCurrentMemberFunDef,HierarchyDimensionFunDef,IifFunDef,IntersectFunDef,IsEmptyFunDef,IsFunDef,IsNullFunDef,JavaFunDef,LastPeriodsFunDef,LeadLagFunDef,LevelDimensionFunDef,LevelHierarchyFunDef,LevelMembersFunDef,LinReg,MemberDimensionFunDef,MemberHierarchyFunDef,MemberLevelFunDef,MemberOrderKeyFunDef,NamedSetCurrentFunDef,NamedSetCurrentOrdinalFunDef,NativizeSetFunDef,OpeningClosingPeriodFunDef,OrderFunDef,ParallelPeriodFunDef,ParameterFunDef,ParenthesesFunDef,PeriodsToDateFunDef,PropertiesFunDef,RangeFunDef,RankFunDef,SetFunDef,SetItemFunDef,SetToStrFunDef,StrToMemberFunDef,StrToSetFunDef,StrToTupleFunDef,SubsetFunDef,ToggleDrillStateFunDef,TopBottomCountFunDef,TopBottomPercentSumFunDef,TupleFunDef,TupleItemFunDef,TupleToStrFunDef,UnionFunDef,UnorderFunDef,ValidMeasureFunDef,ValueFunDef,VisualTotalsFunDef,XtdFunDef
public abstract class FunDefBase extends FunUtil implements FunDef
FunDefBaseis the default implementation ofFunDef.Signatures
A function is defined by the following:
TheParameter Meaning Example name Name of the function "Members" signature Signature of the function "<Dimension>.Members" description Description of the function "Returns the set of all members in a dimension." flags Encoding of the syntactic type, return type, and parameter types of this operator. The encoding is described below. "pxd" flagsfield is an string which encodes the syntactic type, return type, and parameter types of this operator.- The first character determines the syntactic type, as described by
FunUtil.decodeSyntacticType(String). - The second character determines the return type, as described by
FunUtil.decodeReturnCategory(String). - The third and subsequence characters determine the types of the
arguments arguments, as described by
FunUtil.decodeParameterCategories(String).
"pxd"means "an operator withpropertysyntax (p) which returns a set (x) and takes a dimension (d) as its argument". The arguments are always read from left to right, regardless of the syntactic type of the operator. For example, the"<Set>.Item(<Index>)"operator (signature"mmxn") has the syntax of a method-call, and takes two parameters: a set (x) and a numeric (n).- Since:
- 26 February, 2002
- Author:
- jhyde
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class mondrian.olap.fun.FunUtil
FunUtil.DescendingValueComparator, FunUtil.Flag, FunUtil.ObjIntPair<T>, FunUtil.OrderKey, FunUtil.Quicksorter<T>, FunUtil.SetWrapper, FunUtil.SortKeySpec, FunUtil.TupleExpMemoComparator
-
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
Fields Modifier and Type Field Description protected intflagsprotected int[]parameterCategoriesprotected intreturnCategory(package private) Stringsignature-
Fields inherited from class mondrian.olap.fun.FunUtil
BooleanNull, DoubleEmpty, DoubleNull, emptyStringArray, IntegerNull, NullMember
-
Fields inherited from class mondrian.olap.Util
DEBUG, EmptyValue, IBM_JVM, JdbcVersion, JVM_INSTANCE_UUID, nl, nullValue, Retrowoven
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFunDefBase(String name, String description, String flags)Creates an operator.protectedFunDefBase(String name, String signature, String description, String flags)Creates an operator with an explicit signature.(package private)FunDefBase(String name, String signature, String description, Syntax syntax, int returnCategory, int[] parameterCategories)Creates an operator.(package private)FunDefBase(Resolver resolver, int returnType, int[] parameterTypes)Convenience constructor when we are created by aResolver.(package private)FunDefBase(FunDef funDef)Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static TypecastType(Type type, int category)Converts a type to a different category, maintaining as much type information as possible.CalccompileCall(ResolvedFunCall call, ExpCompiler compiler)Converts a call to this function into executable objects.ExpcreateCall(Validator validator, Exp[] args)Creates an expression which represents a call to this function with a given set of arguments.StringgetDescription()Returns the description of this function.StringgetName()Returns the name of this function.int[]getParameterCategories()Returns the types of the arguments of this function.TypegetResultType(Validator validator, Exp[] args)Returns the type of a call to this function with a given set of arguments.intgetReturnCategory()Returns theCategorycode of the value returned by this function.StringgetSignature()Returns an English description of the signature of the function, for example "<Numeric Expression> / <Numeric Expression>".SyntaxgetSyntax()Returns the syntactic type of the function.voidunparse(Exp[] args, PrintWriter pw)Converts a function call into MDX source code.protected ExpvalidateArg(Validator validator, Exp[] args, int i, int category)Validates an argument to a call to this function.-
Methods inherited from class mondrian.olap.fun.FunUtil
addMembers, addMembers, addUnique, ancestor, appendTuple, avg, box, box, checkCompatible, checkIterListResultStyles, checkListResultStyles, compareHierarchically, compareSiblingMembers, compareValues, compareValues, correlation, count, cousin, covariance, createDummyFunDef, decodeCategory, decodeParameterCategories, decodeReturnCategory, decodeSyntacticType, equalTuple, evaluateMembers, evaluateSet, evaluateSet, evaluateTuples, getDimensionDefaultHierarchy, getLiteralArg, getLiteralArg, getNonEmptyLevelMembers, getNonEmptyMemberChildren, getNonEmptyMemberChildrenWithDetails, hierarchizeMemberList, hierarchizeTupleList, hierarchyMembers, isAncestorOf, levelMembers, makeNullMember, makeNullTuple, max, memberRange, min, newEvalException, newEvalException, newEvalException, parseMember, parseMemberList, parseTuple, parseTupleList, partiallySortMembers, partiallySortTuples, partialSort, percentile, periodsToDate, quartile, removeCalculatedMembers, removeCalculatedMembers, resolveFunArgs, sortMembers, sortMembers, sortTuples, sortTuples, stablePartialSort, stablePartialSort, stablePartialSortArray, stablePartialSortJulian, stablePartialSortMarc, stablePartialSortPedro, stdev, sum, sumDouble, sumDouble, toPercent, tupleContainsNullMember, tupleContainsNullMember, var, worthCaching
-
Methods inherited from class mondrian.olap.Util
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
-
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 Detail
-
flags
protected final int flags
-
signature
final String signature
-
returnCategory
protected final int returnCategory
-
parameterCategories
protected final int[] parameterCategories
-
-
Constructor Detail
-
FunDefBase
FunDefBase(String name, String signature, String description, Syntax syntax, int returnCategory, int[] parameterCategories)
Creates an operator.- Parameters:
name- Name of the function, for example "Members".signature- Signature of the function, for example "<Dimension>.Members".description- Description of the function, for example "Returns the set of all members in a dimension."syntax- Syntactic type of the operator (for example, function, method, infix operator)returnCategory- TheCategoryof the value returned by this operator.parameterCategories- An array ofCategorycodes, one for each parameter.
-
FunDefBase
protected FunDefBase(String name, String description, String flags)
Creates an operator.- Parameters:
name- Name of the function, for example "Members".description- Description of the function, for example "Returns the set of all members in a dimension."flags- Encoding of the syntactic type, return type, and parameter types of this operator. The "Members" operator has a syntactic type "pxd" which means "an operator withpropertysyntax (p) which returns a set (x) and takes a dimension (d) as its argument". SeeFunUtil.decodeSyntacticType(String),FunUtil.decodeReturnCategory(String),FunUtil.decodeParameterCategories(String).
-
FunDefBase
protected FunDefBase(String name, String signature, String description, String flags)
Creates an operator with an explicit signature.In most cases, the signature can be generated automatically, and you should use the constructor which creates an implicit signature,
FunDefBase(String, String, String, String)instead.- Parameters:
name- Name of the function, for example "Members".signature- Signature of the function, for example "<Dimension>.Members".description- Description of the function, for example "Returns the set of all members in a dimension."flags- Encoding of the syntactic type, return type, and parameter types of this operator. The "Members" operator has a syntactic type "pxd" which means "an operator withpropertysyntax (p) which returns a set (x) and takes a dimension (d) as its argument". SeeFunUtil.decodeSyntacticType(String),FunUtil.decodeReturnCategory(String),FunUtil.decodeParameterCategories(String).
-
FunDefBase
FunDefBase(Resolver resolver, int returnType, int[] parameterTypes)
Convenience constructor when we are created by aResolver.- Parameters:
resolver- ResolverreturnType- Return typeparameterTypes- Parameter types
-
FunDefBase
FunDefBase(FunDef funDef)
Copy constructor.- Parameters:
funDef- Function definition to copy
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:FunDefReturns the name of this function.
-
getDescription
public String getDescription()
Description copied from interface:FunDefReturns the description of this function.- Specified by:
getDescriptionin interfaceFunDef
-
getSyntax
public Syntax getSyntax()
Description copied from interface:FunDefReturns the syntactic type of the function.
-
getReturnCategory
public int getReturnCategory()
Description copied from interface:FunDefReturns theCategorycode of the value returned by this function.- Specified by:
getReturnCategoryin interfaceFunDef
-
getParameterCategories
public int[] getParameterCategories()
Description copied from interface:FunDefReturns the types of the arguments of this function. Values are the same as those returned byExp.getCategory(). The 0th argument of methods and properties are the object they are applied to. Infix operators have two arguments, and prefix operators have one argument.- Specified by:
getParameterCategoriesin interfaceFunDef
-
createCall
public Exp createCall(Validator validator, Exp[] args)
Description copied from interface:FunDefCreates an expression which represents a call to this function with a given set of arguments. The result is usually aResolvedFunCallbut not always.- Specified by:
createCallin interfaceFunDef
-
validateArg
protected Exp validateArg(Validator validator, Exp[] args, int i, int category)
Validates an argument to a call to this function.The default implementation of this method adds an implicit conversion to the correct type. Derived classes may override.
- Parameters:
validator- Validatorargs- Arguments to this functioni- Ordinal of argumentcategory- Expectedcategoryof argument- Returns:
- Validated argument
-
castType
static Type castType(Type type, int category)
Converts a type to a different category, maintaining as much type information as possible. For example, givenLevelType(dimension=Time, hierarchy=unknown, level=unkown)and category=Hierarchy, returnsHierarchyType(dimension=Time).- Parameters:
type- Typecategory- Desired category- Returns:
- Type after conversion to desired category
-
getResultType
public 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. 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.- Parameters:
validator- Validatorargs- 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:FunDefConverts 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:
compileCallin interfaceFunDef
-
getSignature
public String getSignature()
Description copied from interface:FunDefReturns an English description of the signature of the function, for example "<Numeric Expression> / <Numeric Expression>".- Specified by:
getSignaturein interfaceFunDef
-
unparse
public void unparse(Exp[] args, PrintWriter pw)
Description copied from interface:FunDefConverts a function call into MDX source code.
-
-