Class ExpressionFactory

    • Field Detail

      • variableLengthParamSuffix

        public static final String variableLengthParamSuffix
        Used to denote a variable length parameter.
        See Also:
        Constant Field Values
      • variableForEachSep

        public static final char variableForEachSep
        The character used to denote the start of a for each lambda expression
        See Also:
        Constant Field Values
      • variableForEachParam

        public static final char variableForEachParam
        The character used to denote the looped parameter in the for each lambda expression
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExpressionFactory

        public ExpressionFactory​(IndexSchema schema)
    • Method Detail

      • getSchema

        public IndexSchema getSchema()
        Get the index schema used by this factory.
        Returns:
        the index schema
      • startRequest

        public void startRequest()
        Prepare the factory to start building the request.
      • startGrouping

        public void startGrouping()
        Prepare the factory to start building the next grouping.
        NOTE: MUST be called before each new grouping.
      • addSystemFunction

        public ExpressionFactory addSystemFunction​(String functionName,
                                                   ExpressionFactory.CreatorFunction functionCreator)
                                            throws org.apache.solr.common.SolrException
        Add a system function to the expression factory. This will be treated as a native function and not a variable function.
        Parameters:
        functionName - the unique name for the function
        functionCreator - the creator function to generate an expression
        Returns:
        this factory, to easily chain function adds
        Throws:
        org.apache.solr.common.SolrException - if the functionName is not unique
      • addSystemVariableFunction

        public ExpressionFactory addSystemVariableFunction​(String functionName,
                                                           String functionParams,
                                                           String returnSignature)
                                                    throws org.apache.solr.common.SolrException
        Add a variable function that will be treated like a system function.
        Parameters:
        functionName - the function's name
        functionParams - the comma separated and ordered parameters of the function (e.g. "a,b" )
        returnSignature - the return signature of the variable function (e.g. div(sum(a,b),count(b)) )
        Returns:
        this factory, to easily chain function adds
        Throws:
        org.apache.solr.common.SolrException - if the name of the function is not unique or the syntax of either signature is incorrect
      • addUserDefinedVariableFunction

        public ExpressionFactory addUserDefinedVariableFunction​(String functionSignature,
                                                                String returnSignature)
                                                         throws org.apache.solr.common.SolrException
        Add a variable function that was defined in an analytics request.
        Parameters:
        functionSignature - the function signature of the variable function (e.g. func(a,b) )
        returnSignature - the return signature of the variable function (e.g. div(sum(a,b),count(b)) )
        Returns:
        this factory, to easily chain function adds
        Throws:
        org.apache.solr.common.SolrException - if the name of the function is not unique or the syntax of either signature is incorrect
      • createReductionManager

        public ReductionCollectionManager createReductionManager​(boolean isCloudCollection)
        Create a reduction manager to manage the collection of all expressions that have been created since startRequest() was called.
        Parameters:
        isCloudCollection - whether the request is a distributed request
        Returns:
        a reduction manager
      • createGroupingReductionManager

        public ReductionCollectionManager createGroupingReductionManager​(boolean isCloudCollection)
        Create a reduction manager to manage the collection of all expressions that have been created since startGrouping() was called.
        Parameters:
        isCloudCollection - whether the request is a distributed request
        Returns:
        a reduction manager
      • createExpression

        public AnalyticsValueStream createExpression​(String expressionStr)
                                              throws org.apache.solr.common.SolrException
        Parse and build an expression from the given expression string.
        Parameters:
        expressionStr - string that represents the desired expression
        Returns:
        the object representation of the expression
        Throws:
        org.apache.solr.common.SolrException - if an error occurs while constructing the expression
      • addSystemFunctions

        public void addSystemFunctions()
        Add the natively supported functionality.