Class Parser


  • public class Parser
    extends Object
    • Constructor Detail

      • Parser

        public Parser()
    • Method Detail

      • lazyParse

        public static com.google.common.base.Supplier<Expr> lazyParse​(@Nullable
                                                                      String in,
                                                                      ExprMacroTable macroTable)
        Create a memoized lazy supplier to parse a string into a flattened Expr. There is some overhead to this, and these objects are all immutable, so this assists in the goal of re-using instead of re-creating whenever possible. Lazy form of parse(String, ExprMacroTable)
        Parameters:
        in - expression to parse
        macroTable - additional extensions to expression language
      • parse

        public static Expr parse​(String in,
                                 ExprMacroTable macroTable)
        Parse a string into a flattened Expr. There is some overhead to this, and these objects are all immutable, so re-use instead of re-creating whenever possible.
        Parameters:
        in - expression to parse
        macroTable - additional extensions to expression language
      • flatten

        public static Expr flatten​(Expr expr)
        Flatten an Expr, evaluating expressions on constants where possible to simplify the Expr.
      • applyUnappliedBindings

        public static Expr applyUnappliedBindings​(Expr expr,
                                                  Expr.BindingAnalysis bindingAnalysis,
                                                  List<String> bindingsToApply)
        Applies a transformation to an Expr given a list of known (or uknown) multi-value input columns that are used in a scalar manner, walking the Expr tree and lifting array variables into the LambdaExpr of ApplyFunctionExpr and transforming the arguments of FunctionExpr as necessary. This function applies a transformation for "map" style uses, such as column selectors, where the supplied expression will be transformed to return an array of results instead of the scalar result (or appropriately rewritten into existing apply expressions to produce correct results when referenced from a scalar context). This function and foldUnappliedBindings(Expr, Expr.BindingAnalysis, List, String) exist to handle "multi-valued" string dimensions, which exist in a superposition of both single and multi-valued during realtime ingestion, until they are written to a segment and become locked into either single or multi-valued. This also means that multi-valued-ness can vary for a column from segment to segment, so this family of transformation functions exist so that multi-valued strings can be expressed in either and array or scalar context, which is important because the writer of the query might not actually know if the column is definitively always single or multi-valued (and it might in fact not be).
        See Also:
        foldUnappliedBindings(Expr, Expr.BindingAnalysis, List, String)
      • foldUnappliedBindings

        public static Expr foldUnappliedBindings​(Expr expr,
                                                 Expr.BindingAnalysis bindingAnalysis,
                                                 List<String> bindingsToApply,
                                                 String accumulatorId)
        Applies a transformation to an Expr given a list of known (or uknown) multi-value input columns that are used in a scalar manner, walking the Expr tree and lifting array variables into the LambdaExpr of ApplyFunctionExpr and transforming the arguments of FunctionExpr as necessary. This function applies a transformation for "fold" style uses, such as aggregators, where the supplied expression will be transformed to accumulate the result of applying the expression to each value of the unapplied input (or appropriately rewritten into existing apply expressions to produce correct results when referenced from a scalar context). This rewriting assumes that there exists some accumulator variable, which is re-used as the accumulator for this fold rewrite, so that evaluating each expression can be accumulated into the larger external fold operation that an aggregator might be performing. This function and applyUnappliedBindings(Expr, Expr.BindingAnalysis, List) exist to handle "multi-valued" string dimensions, which exist in a superposition of both single and multi-valued during realtime ingestion, until they are written to a segment and become locked into either single or multi-valued. This also means that multi-valued-ness can vary for a column from segment to segment, so this family of transformation functions exist so that multi-valued strings can be expressed in either and array or scalar context, which is important because the writer of the query might not actually know if the column is definitively always single or multi-valued (and it might in fact not be).
        See Also:
        applyUnappliedBindings(Expr, Expr.BindingAnalysis, List)
      • validateExpr

        public static void validateExpr​(Expr expression,
                                        Expr.BindingAnalysis bindingAnalysis)
        Validate that an expression uses input bindings in a type consistent manner.