Class Query
- java.lang.Object
-
- com.apple.foundationdb.record.query.expressions.Query
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Query.InvalidExpressionException
Exception thrown when a query expression is not valid in some context.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static QueryComponent
and(QueryComponent first, QueryComponent second, QueryComponent... operands)
Check that a set of components all evaluate to true for a given record.static QueryComponent
and(List<? extends QueryComponent> operands)
Check that a set of components all evaluate to true for a given record.static Field
field(String name)
Creates a new Field context.static boolean
isSingleFieldComparison(QueryComponent component)
static QueryKeyExpression
keyExpression(KeyExpression keyExpression)
Build query components using a key expression.static QueryComponent
not(QueryComponent operand)
Negate a component test.static QueryComponent
or(QueryComponent first, QueryComponent second, QueryComponent... operands)
Check that any of a set of components evaluate to true for a given record.static QueryComponent
or(List<QueryComponent> operands)
Check that a set of components all evaluate to true for a given record.static QueryRecordFunction<Long>
rank(GroupingKeyExpression operand)
A record function that can be used to determine or compare the rank value for a record.static QueryRecordFunction<Long>
rank(String fieldName)
A record function that can be used to determine or compare the rank value for a record.static QueryRecordFunction<Long>
timeWindowRank(int type, long timestamp, GroupingKeyExpression operand)
A record function that can be used to determine or compare the rank value for a record for a time window.static QueryRecordFunction<Long>
timeWindowRank(int type, long timestamp, String typeParameter, String timestampParameter, GroupingKeyExpression operand)
A record function that can be used to determine or compare the rank value for a record for a time window.static QueryRecordFunction<Long>
timeWindowRank(TimeWindowForFunction timeWindow, GroupingKeyExpression operand)
A record function that can be used to determine or compare the rank value for a record for a time window.static QueryRecordFunction<Long>
timeWindowRank(String typeParameter, String timestampParameter, GroupingKeyExpression operand)
A record function that can be used to determine or compare the rank value for a record for a time window.static QueryRecordFunction<Tuple>
timeWindowRankAndEntry(int type, long timestamp, 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.static QueryRecordFunction<Tuple>
timeWindowRankAndEntry(int type, long timestamp, String typeParameter, String timestampParameter, 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.static QueryRecordFunction<Tuple>
timeWindowRankAndEntry(TimeWindowForFunction timeWindow, 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.static QueryRecordFunction<Tuple>
timeWindowRankAndEntry(String typeParameter, String timestampParameter, 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.static QueryRecordFunction<FDBRecordVersion>
version()
A record function that can be used to determine the version of a record.
-
-
-
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 QueryComponent first, @Nonnull QueryComponent second, @Nonnull QueryComponent... operands)
Check that a set of components all evaluate to true for a given record.- Parameters:
first
- the first assertionsecond
- the second assertionoperands
- any other assertions- Returns:
- a new component that will return the record if all the children match
-
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 QueryComponent first, @Nonnull QueryComponent second, @Nonnull QueryComponent... operands)
Check that any of a set of components evaluate to true for a given record.- Parameters:
first
- the first assertionsecond
- the second assertionoperands
- any other assertions- Returns:
- a new component that will return the record if any of 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(@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.- Parameters:
timeWindow
- the time window for which to get the rankoperand
- 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, @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 windowtimestamp
- the target timestamptypeParameter
- the name of the time window type parameter if it is a parametertimestampParameter
- the name of the timestamp parameter if it is a parameteroperand
- 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 windowtimestamp
- the target timestampoperand
- 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 parametertimestampParameter
- the name of the timestamp parameteroperand
- 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 benull
if the record has no entry within the specified time window or else aTuple
of rank, value, timestamp, and any other values in the specified operand's items.- Parameters:
timeWindow
- the time window for which to get the rankoperand
- 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 benull
if the record has no entry within the specified time window or else aTuple
of rank, value, timestamp, and any other values in the specified operand's items.- Parameters:
type
- the type of time windowtimestamp
- the target timestamptypeParameter
- the name of the time window type parameter if it is a parametertimestampParameter
- the name of the timestamp parameter if it is a parameteroperand
- 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 benull
if the record has no entry within the specified time window or else aTuple
of rank, value, timestamp, and any other values in the specified operand's items.- Parameters:
type
- the type of time windowtimestamp
- the target timestampoperand
- 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 benull
if the record has no entry within the specified time window or else aTuple
of rank, value, timestamp, and any other values in the specified operand's items.- Parameters:
typeParameter
- the name of the time window type parametertimestampParameter
- the name of the timestamp parameteroperand
- 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
-
keyExpression
@Nonnull @API(EXPERIMENTAL) public static QueryKeyExpression keyExpression(@Nonnull KeyExpression keyExpression)
Build query components using a key expression.- Parameters:
keyExpression
- the key expression to compare with values- Returns:
- a
QueryKeyExpression
for matching
-
isSingleFieldComparison
public static boolean isSingleFieldComparison(@Nonnull QueryComponent component)
-
-