Class Function


  • public final class Function
    extends java.lang.Object
    Query functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Function()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Expression abs​(Expression operand)
      Creates an ABS(expr) function that returns the absolute value of the given numeric expression.
      static Expression acos​(Expression operand)
      Creates an ACOS(expr) function that returns the inverse cosine of the given numeric expression.
      static Expression asin​(Expression operand)
      Creates an ASIN(expr) function that returns the inverse sin of the given numeric expression.
      static Expression atan​(Expression operand)
      Creates an ATAN(expr) function that returns the inverse tangent of the numeric expression.
      static Expression atan2​(Expression y, Expression x)
      Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
      static Expression avg​(Expression operand)
      Creates an AVG(expr) function expression that returns the average of all the number values in the group of the values expressed by the given expression.
      static Expression ceil​(Expression operand)
      Creates a CEIL(expr) function that returns the ceiling value of the given numeric expression.
      static Expression contains​(Expression operand, Expression substring)
      Creates a CONTAINS(expr, substr) function that evaluates whether the given string expression conatins the given substring expression or not.
      static Expression cos​(Expression operand)
      Creates a COS(expr) function that returns the cosine of the given numeric expression.
      static Expression cosineDistance​(Expression expression1, Expression expression2)
      ENTERPRISE EDITION API

      static Expression count​(Expression operand)
      Creates a COUNT(expr) function expression that returns the count of all values in the group of the values expressed by the given expression.
      static Expression degrees​(Expression operand)
      Creates a DEGREES(expr) function that returns the degrees value of the given radiants value expression.
      static Expression e()
      Creates a E() function that return the value of the mathematical constant 'e'.
      static Expression euclideanDistance​(Expression expression1, Expression expression2)
      ENTERPRISE EDITION API

      static Expression exp​(Expression operand)
      Creates a EXP(expr) function that returns the value of 'e' power by the given numeric expression.
      static Expression floor​(Expression operand)
      Creates a FLOOR(expr) function that returns the floor value of the given numeric expression.
      static Expression length​(Expression operand)
      Creates a LENGTH(expr) function that returns the length of the given string expression.
      static Expression ln​(Expression operand)
      Creates a LN(expr) function that returns the natural log of the given numeric expression.
      static Expression log​(Expression operand)
      Creates a LOG(expr) function that returns the base 10 log of the given numeric expression.
      static Expression lower​(Expression operand)
      Creates a LOWER(expr) function that returns the lowercase string of the given string expression.
      static Expression ltrim​(Expression operand)
      Creates a LTRIM(expr) function that removes the whitespace from the beginning of the given string expression.
      static Expression max​(Expression operand)
      Creates a MAX(expr) function expression that returns the maximum value in the group of the values expressed by the given expression.
      static Expression millisToString​(Expression operand)
      Creates a MILLIS_TO_STR(expr) function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in the device local time zone.
      static Expression millisToUTC​(Expression operand)
      Creates a MILLIS_TO_UTC(expr) function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in UTC time.
      static Expression min​(Expression operand)
      Creates a MIN(expr) function expression that returns the minimum value in the group of the values expressed by the given expression.
      static Expression pi()
      Creates a PI() function that returns the mathematical constant Pi.
      static Expression power​(Expression base, Expression exp)
      Creates a POWER(base, exponent) function that returns the value of the given base expression power the given exponent expression.
      static PredictionFunction prediction​(java.lang.String model, Expression input)
      ENTERPRISE EDITION API

      static Expression radians​(Expression operand)
      Creates a RADIANS(expr) function that returns the radians value of the given degrees value expression.
      static Expression round​(Expression operand)
      Creates a ROUND(expr) function that returns the rounded value of the given numeric expression.
      static Expression round​(Expression operand, Expression digits)
      Creates a ROUND(expr, digits) function that returns the rounded value to the given number of digits of the given numeric expression.
      static Expression rtrim​(Expression operand)
      Creates a RTRIM(expr) function that removes the whitespace from the end of the given string expression.
      static Expression sign​(Expression operand)
      Creates a SIGN(expr) function that returns the sign (1: positive, -1: negative, 0: zero) of the given numeric expression.
      static Expression sin​(Expression operand)
      Creates a SIN(expr) function that returns the sin of the given numeric expression.
      static Expression sqrt​(Expression operand)
      Creates a SQRT(expr) function that returns the square root of the given numeric expression.
      static Expression squaredEuclideanDistance​(Expression expression1, Expression expression2)
      ENTERPRISE EDITION API

      static Expression stringToMillis​(Expression operand)
      Creates a STR_TO_MILLIS(expr) that will convert an ISO8601 datetime string into the number of milliseconds since the unix epoch.
      static Expression stringToUTC​(Expression operand)
      Creates a STR_TO_UTC(expr) that will convert an ISO8601 datetime string into a full ISO8601 UTC datetime string.
      static Expression sum​(Expression operand)
      Creates a SUM(expr) function expression that return the sum of all number values in the group of the values expressed by the given expression.
      static Expression tan​(Expression operand)
      Creates a TAN(expr) function that returns the tangent of the given numeric expression.
      static Expression trim​(Expression operand)
      Creates a TRIM(expr) function that removes the whitespace from the beginning and the end of the given string expression.
      static Expression trunc​(Expression operand)
      Creates a TRUNC(expr) function that truncates all of the digits after the decimal place of the given numeric expression.
      static Expression trunc​(Expression operand, Expression digits)
      Creates a TRUNC(expr, digits) function that truncates the number of the digits after the decimal place of the given numeric expression.
      static Expression upper​(Expression operand)
      Creates a UPPER(expr) function that returns the uppercase string of the given string expression.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Function

        public Function()
    • Method Detail

      • prediction

        @NonNull
        public static PredictionFunction prediction​(@NonNull
                                                    java.lang.String model,
                                                    @NonNull
                                                    Expression input)
        ENTERPRISE EDITION API

        Creates prediction function with the given model name and input. When running a query with the prediction function, the corresponding predictive model registered to CouchbaseLite Database class will be called with the given input to predict the result.

        The prediction result returned by the predictive model will be in a form dictionary object. To create an expression that refers to a property in the prediction result, the propertyPath(path) method of the created PredictionFunction object can be used.

        Parameters:
        model - The predictive model name registered to the CouchbaseLite Database.
        input - The expression evaluated to a dictionary.
        Returns:
        A PredictionFunction object.
      • euclideanDistance

        @NonNull
        public static Expression euclideanDistance​(@NonNull
                                                   Expression expression1,
                                                   @NonNull
                                                   Expression expression2)
        ENTERPRISE EDITION API

        Creates a function that returns the euclidean distance between the two input vectors. The result is a non-negative floating-point number. The expression1 and expression2 must be arrays of numbers, and must be the same length.

        Parameters:
        expression1 - The expression evaluated to an arrays of numbers.
        expression2 - The expression evaluated to an arrays of numbers.
        Returns:
        The euclidean distance between two given input vectors.
      • squaredEuclideanDistance

        @NonNull
        public static Expression squaredEuclideanDistance​(@NonNull
                                                          Expression expression1,
                                                          @NonNull
                                                          Expression expression2)
        ENTERPRISE EDITION API

        Creates a function that returns the squared euclidean distance between the two input vectors. The result is a non-negative floating-point number. The expression1 and expression2 must be arrays of numbers, and must be the same length.

        Parameters:
        expression1 - The expression evaluated to an arrays of numbers.
        expression2 - The expression evaluated to an arrays of numbers.
        Returns:
        The squared euclidean distance between two given input vectors.
      • cosineDistance

        @NonNull
        public static Expression cosineDistance​(@NonNull
                                                Expression expression1,
                                                @NonNull
                                                Expression expression2)
        ENTERPRISE EDITION API

        Creates a function that returns the cosine distance which one minus the cosine similarity between the two input vectors. The result is a floating-point number ranges from −1.0 to 1.0. The expression1 and expression2 must be arrays of numbers, and must be the same length.

        Parameters:
        expression1 - The expression evaluated to an arrays of numbers.
        expression2 - The expression evaluated to an arrays of numbers.
        Returns:
        The cosine distance between two given input vectors.
      • avg

        @NonNull
        public static Expression avg​(@NonNull
                                     Expression operand)
        Creates an AVG(expr) function expression that returns the average of all the number values in the group of the values expressed by the given expression.

        The expression.

        Returns:
        The AVG(expr) function.
      • count

        @NonNull
        public static Expression count​(@NonNull
                                       Expression operand)
        Creates a COUNT(expr) function expression that returns the count of all values in the group of the values expressed by the given expression. Null expression is count *
        Parameters:
        operand - The expression.
        Returns:
        The COUNT(expr) function.
      • min

        @NonNull
        public static Expression min​(@NonNull
                                     Expression operand)
        Creates a MIN(expr) function expression that returns the minimum value in the group of the values expressed by the given expression.
        Parameters:
        operand - The expression.
        Returns:
        The MIN(expr) function.
      • max

        @NonNull
        public static Expression max​(@NonNull
                                     Expression operand)
        Creates a MAX(expr) function expression that returns the maximum value in the group of the values expressed by the given expression.
        Parameters:
        operand - The expression.
        Returns:
        The MAX(expr) function.
      • sum

        @NonNull
        public static Expression sum​(@NonNull
                                     Expression operand)
        Creates a SUM(expr) function expression that return the sum of all number values in the group of the values expressed by the given expression.
        Parameters:
        operand - The expression.
        Returns:
        The SUM(expr) function.
      • abs

        @NonNull
        public static Expression abs​(@NonNull
                                     Expression operand)
        Creates an ABS(expr) function that returns the absolute value of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The ABS(expr) function.
      • acos

        @NonNull
        public static Expression acos​(@NonNull
                                      Expression operand)
        Creates an ACOS(expr) function that returns the inverse cosine of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The ACOS(expr) function.
      • asin

        @NonNull
        public static Expression asin​(@NonNull
                                      Expression operand)
        Creates an ASIN(expr) function that returns the inverse sin of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The ASIN(expr) function.
      • atan

        @NonNull
        public static Expression atan​(@NonNull
                                      Expression operand)
        Creates an ATAN(expr) function that returns the inverse tangent of the numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The ATAN(expr) function.
      • atan2

        @NonNull
        public static Expression atan2​(@NonNull
                                       Expression y,
                                       @NonNull
                                       Expression x)
        Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).
        Parameters:
        x - the abscissa coordinate
        y - the ordinate coordinate
        Returns:
        the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.
      • ceil

        @NonNull
        public static Expression ceil​(@NonNull
                                      Expression operand)
        Creates a CEIL(expr) function that returns the ceiling value of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The CEIL(expr) function.
      • cos

        @NonNull
        public static Expression cos​(@NonNull
                                     Expression operand)
        Creates a COS(expr) function that returns the cosine of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The COS(expr) function.
      • degrees

        @NonNull
        public static Expression degrees​(@NonNull
                                         Expression operand)
        Creates a DEGREES(expr) function that returns the degrees value of the given radiants value expression.
        Parameters:
        operand - The expression.
        Returns:
        The DEGREES(expr) function.
      • e

        @NonNull
        public static Expression e()
        Creates a E() function that return the value of the mathematical constant 'e'.
        Returns:
        The E() constant function.
      • exp

        @NonNull
        public static Expression exp​(@NonNull
                                     Expression operand)
        Creates a EXP(expr) function that returns the value of 'e' power by the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The EXP(expr) function.
      • floor

        @NonNull
        public static Expression floor​(@NonNull
                                       Expression operand)
        Creates a FLOOR(expr) function that returns the floor value of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The FLOOR(expr) function.
      • ln

        @NonNull
        public static Expression ln​(@NonNull
                                    Expression operand)
        Creates a LN(expr) function that returns the natural log of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The LN(expr) function.
      • log

        @NonNull
        public static Expression log​(@NonNull
                                     Expression operand)
        Creates a LOG(expr) function that returns the base 10 log of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The LOG(expr) function.
      • pi

        @NonNull
        public static Expression pi()
        Creates a PI() function that returns the mathematical constant Pi.
        Returns:
        The PI() constant function.
      • power

        @NonNull
        public static Expression power​(@NonNull
                                       Expression base,
                                       @NonNull
                                       Expression exp)
        Creates a POWER(base, exponent) function that returns the value of the given base expression power the given exponent expression.
        Parameters:
        base - The base expression.
        exp - The exponent expression.
        Returns:
        The POWER(base, exponent) function.
      • radians

        @NonNull
        public static Expression radians​(@NonNull
                                         Expression operand)
        Creates a RADIANS(expr) function that returns the radians value of the given degrees value expression.
        Parameters:
        operand - The expression.
        Returns:
        The RADIANS(expr) function.
      • round

        @NonNull
        public static Expression round​(@NonNull
                                       Expression operand)
        Creates a ROUND(expr) function that returns the rounded value of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The ROUND(expr) function.
      • round

        @NonNull
        public static Expression round​(@NonNull
                                       Expression operand,
                                       @NonNull
                                       Expression digits)
        Creates a ROUND(expr, digits) function that returns the rounded value to the given number of digits of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        digits - The number of digits.
        Returns:
        The ROUND(expr, digits) function.
      • sign

        @NonNull
        public static Expression sign​(@NonNull
                                      Expression operand)
        Creates a SIGN(expr) function that returns the sign (1: positive, -1: negative, 0: zero) of the given numeric expression.
        Parameters:
        operand - The expression.
        Returns:
        The SIGN(expr) function.
      • sin

        @NonNull
        public static Expression sin​(@NonNull
                                     Expression operand)
        Creates a SIN(expr) function that returns the sin of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        Returns:
        The SIN(expr) function.
      • sqrt

        @NonNull
        public static Expression sqrt​(@NonNull
                                      Expression operand)
        Creates a SQRT(expr) function that returns the square root of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        Returns:
        The SQRT(expr) function.
      • tan

        @NonNull
        public static Expression tan​(@NonNull
                                     Expression operand)
        Creates a TAN(expr) function that returns the tangent of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        Returns:
        The TAN(expr) function.
      • trunc

        @NonNull
        public static Expression trunc​(@NonNull
                                       Expression operand)
        Creates a TRUNC(expr) function that truncates all of the digits after the decimal place of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        Returns:
        The trunc function.
      • trunc

        @NonNull
        public static Expression trunc​(@NonNull
                                       Expression operand,
                                       @NonNull
                                       Expression digits)
        Creates a TRUNC(expr, digits) function that truncates the number of the digits after the decimal place of the given numeric expression.
        Parameters:
        operand - The numeric expression.
        digits - The number of digits to truncate.
        Returns:
        The TRUNC(expr, digits) function.
      • contains

        @NonNull
        public static Expression contains​(@NonNull
                                          Expression operand,
                                          @NonNull
                                          Expression substring)
        Creates a CONTAINS(expr, substr) function that evaluates whether the given string expression conatins the given substring expression or not.
        Parameters:
        operand - The string expression.
        substring - The substring expression.
        Returns:
        The CONTAINS(expr, substr) function.
      • length

        @NonNull
        public static Expression length​(@NonNull
                                        Expression operand)
        Creates a LENGTH(expr) function that returns the length of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The LENGTH(expr) function.
      • lower

        @NonNull
        public static Expression lower​(@NonNull
                                       Expression operand)
        Creates a LOWER(expr) function that returns the lowercase string of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The LOWER(expr) function.
      • ltrim

        @NonNull
        public static Expression ltrim​(@NonNull
                                       Expression operand)
        Creates a LTRIM(expr) function that removes the whitespace from the beginning of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The LTRIM(expr) function.
      • rtrim

        @NonNull
        public static Expression rtrim​(@NonNull
                                       Expression operand)
        Creates a RTRIM(expr) function that removes the whitespace from the end of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The RTRIM(expr) function.
      • trim

        @NonNull
        public static Expression trim​(@NonNull
                                      Expression operand)
        Creates a TRIM(expr) function that removes the whitespace from the beginning and the end of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The TRIM(expr) function.
      • upper

        @NonNull
        public static Expression upper​(@NonNull
                                       Expression operand)
        Creates a UPPER(expr) function that returns the uppercase string of the given string expression.
        Parameters:
        operand - The string expression.
        Returns:
        The UPPER(expr) function.
      • millisToString

        @NonNull
        public static Expression millisToString​(@NonNull
                                                Expression operand)
        Creates a MILLIS_TO_STR(expr) function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in the device local time zone.
        Parameters:
        operand - The string expression.
        Returns:
        The MILLIS_TO_STR(expr) function.
      • millisToUTC

        @NonNull
        public static Expression millisToUTC​(@NonNull
                                             Expression operand)
        Creates a MILLIS_TO_UTC(expr) function that will convert a numeric input representing milliseconds since the Unix epoch into a full ISO8601 date and time string in UTC time.
        Parameters:
        operand - The string expression.
        Returns:
        The MILLIS_TO_UTC(expr) function.
      • stringToMillis

        @NonNull
        public static Expression stringToMillis​(@NonNull
                                                Expression operand)
        Creates a STR_TO_MILLIS(expr) that will convert an ISO8601 datetime string into the number of milliseconds since the unix epoch. Valid date strings must start with a date in the form YYYY-MM-DD (time only strings are not supported).

        Times can be of the form HH:MM, HH:MM:SS, or HH:MM:SS.FFF. Leading zero is not optional (i.e. 02 is ok, 2 is not). Hours are in 24-hour format. FFF represents milliseconds, and *trailing* zeros are optional (i.e. 5 == 500).

        Time zones can be in one of three forms: (+/-)HH:MM (+/-)HHMM Z (which represents UTC)

        Parameters:
        operand - The string expression.
        Returns:
        The STR_TO_MILLIS(expr) function.
      • stringToUTC

        @NonNull
        public static Expression stringToUTC​(@NonNull
                                             Expression operand)
        Creates a STR_TO_UTC(expr) that will convert an ISO8601 datetime string into a full ISO8601 UTC datetime string. Valid date strings must start with a date in the form YYYY-MM-DD (time only strings are not supported).

        Times can be of the form HH:MM, HH:MM:SS, or HH:MM:SS.FFF. Leading zero is not optional (i.e. 02 is ok, 2 is not). Hours are in 24-hour format. FFF represents milliseconds, and *trailing* zeros are optional (i.e. 5 == 500).

        Time zones can be in one of three forms: (+/-)HH:MM (+/-)HHMM Z (which represents UTC)

        Parameters:
        operand - The string expression.
        Returns:
        The STR_TO_UTC(expr) function.