Class Query


  • @API(STABLE)
    public class Query
    extends Object
    Holder class for creating querying expressions.
    • Method Detail

      • field

        @Nonnull
        public static Field field​(@Nonnull
                                  String name)
        Creates a new Field context. This has a variety of methods for asserting about the value of the associated field. Usable for any type field.
        Parameters:
        name - the name of the field
        Returns:
        a new Field ready for matching
      • and

        @Nonnull
        public static QueryComponent and​(@Nonnull
                                         List<? extends QueryComponent> operands)
        Check that a set of components all evaluate to true for a given record.
        Parameters:
        operands - assertions
        Returns:
        a new component that will return the record if all the children match
      • or

        @Nonnull
        public static QueryComponent or​(@Nonnull
                                        List<QueryComponent> operands)
        Check that a set of components all evaluate to true for a given record.
        Parameters:
        operands - assertions
        Returns:
        a new component that will return the record if any of the children match
      • not

        @Nonnull
        public static QueryComponent not​(@Nonnull
                                         QueryComponent operand)
        Negate a component test.
        Parameters:
        operand - assertion to be negated
        Returns:
        a new component that will return the record if the child does not match
      • rank

        @Nonnull
        public static QueryRecordFunction<Long> rank​(@Nonnull
                                                     GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record.
        Parameters:
        operand - the argument to rank
        Returns:
        a record function that evaluates the rank of the operand
      • rank

        @Nonnull
        public static QueryRecordFunction<Long> rank​(@Nonnull
                                                     String fieldName)
        A record function that can be used to determine or compare the rank value for a record.
        Parameters:
        fieldName - the argument to rank
        Returns:
        a record function that evaluates the rank of the operand
      • timeWindowRank

        @Nonnull
        public static QueryRecordFunction<Long> timeWindowRank​(int type,
                                                               long timestamp,
                                                               @Nullable
                                                               String typeParameter,
                                                               @Nullable
                                                               String timestampParameter,
                                                               @Nonnull
                                                               GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window.
        Parameters:
        type - the type of time window
        timestamp - the target timestamp
        typeParameter - the name of the time window type parameter if it is a parameter
        timestampParameter - the name of the timestamp parameter if it is a parameter
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • timeWindowRank

        @Nonnull
        public static QueryRecordFunction<Long> timeWindowRank​(int type,
                                                               long timestamp,
                                                               @Nonnull
                                                               GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window.
        Parameters:
        type - the type of time window
        timestamp - the target timestamp
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • timeWindowRank

        @Nonnull
        public static QueryRecordFunction<Long> timeWindowRank​(@Nonnull
                                                               String typeParameter,
                                                               @Nonnull
                                                               String timestampParameter,
                                                               @Nonnull
                                                               GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window.
        Parameters:
        typeParameter - the name of the time window type parameter
        timestampParameter - the name of the timestamp parameter
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • timeWindowRankAndEntry

        @Nonnull
        public static QueryRecordFunction<Tuple> timeWindowRankAndEntry​(@Nonnull
                                                                        TimeWindowForFunction timeWindow,
                                                                        @Nonnull
                                                                        GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window and the score entry that determined that rank. The result of evaluation will be null if the record has no entry within the specified time window or else a Tuple of rank, value, timestamp, and any other values in the specified operand's items.
        Parameters:
        timeWindow - the time window for which to get the rank
        operand - the argument to rank
        Returns:
        a record function that evaluates to a Tuple of the rank and the corresponding entry
      • timeWindowRankAndEntry

        @Nonnull
        public static QueryRecordFunction<Tuple> timeWindowRankAndEntry​(int type,
                                                                        long timestamp,
                                                                        @Nullable
                                                                        String typeParameter,
                                                                        @Nullable
                                                                        String timestampParameter,
                                                                        @Nonnull
                                                                        GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window and the score entry that determined that rank. The result of evaluation will be null if the record has no entry within the specified time window or else a Tuple of rank, value, timestamp, and any other values in the specified operand's items.
        Parameters:
        type - the type of time window
        timestamp - the target timestamp
        typeParameter - the name of the time window type parameter if it is a parameter
        timestampParameter - the name of the timestamp parameter if it is a parameter
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • timeWindowRankAndEntry

        @Nonnull
        public static QueryRecordFunction<Tuple> timeWindowRankAndEntry​(int type,
                                                                        long timestamp,
                                                                        @Nonnull
                                                                        GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window and the score entry that determined that rank. The result of evaluation will be null if the record has no entry within the specified time window or else a Tuple of rank, value, timestamp, and any other values in the specified operand's items.
        Parameters:
        type - the type of time window
        timestamp - the target timestamp
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • timeWindowRankAndEntry

        @Nonnull
        public static QueryRecordFunction<Tuple> timeWindowRankAndEntry​(@Nonnull
                                                                        String typeParameter,
                                                                        @Nonnull
                                                                        String timestampParameter,
                                                                        @Nonnull
                                                                        GroupingKeyExpression operand)
        A record function that can be used to determine or compare the rank value for a record for a time window and the score entry that determined that rank. The result of evaluation will be null if the record has no entry within the specified time window or else a Tuple of rank, value, timestamp, and any other values in the specified operand's items.
        Parameters:
        typeParameter - the name of the time window type parameter
        timestampParameter - the name of the timestamp parameter
        operand - the argument to rank
        Returns:
        a record function that evaluates to the rank of the operand
      • version

        @Nonnull
        public static QueryRecordFunction<FDBRecordVersion> version()
        A record function that can be used to determine the version of a record.
        Returns:
        a record function that evaluates the version of the record
      • isSingleFieldComparison

        public static boolean isSingleFieldComparison​(@Nonnull
                                                      QueryComponent component)