Modifier and Type | Field and Description |
---|---|
static String |
MAP_KEY_FIELD
The name of the key field in Protobuf
map messages. |
static String |
MAP_VALUE_FIELD
The name of the value field in Protobuf
map messages. |
Modifier and Type | Method and Description |
---|---|
static ThenKeyExpression |
concat(KeyExpression first,
KeyExpression second,
KeyExpression... rest)
Concatenate multiple expressions together.
|
static ThenKeyExpression |
concat(List<KeyExpression> children)
Concatenate multiple expressions together.
|
static ThenKeyExpression |
concatenateFields(List<String> fields)
Concatenate multiple fields together.
|
static ThenKeyExpression |
concatenateFields(String first,
String second,
String... fields)
Shortuct for `concat(field(first), field(second), field(rest[0]), ...)`
|
static EmptyKeyExpression |
empty()
The empty key expression.
|
static FieldKeyExpression |
field(String name)
Create an expression of a single scalar (i.e.
|
static FieldKeyExpression |
field(String name,
KeyExpression.FanType fanType)
Creates an expression of a field.
|
static FieldKeyExpression |
field(String name,
KeyExpression.FanType fanType,
Key.Evaluated.NullStandin nullStandin)
Creates an expression of a field.
|
static FieldKeyExpression |
fromDescriptor(Descriptors.FieldDescriptor fieldDescriptor)
Convert a field descriptor into a expression.
|
static FunctionKeyExpression |
function(String name)
Create a function call with arguments that will result in a key expression.
|
static FunctionKeyExpression |
function(String name,
KeyExpression arguments)
Create a function call with arguments that will result in a key expression.
|
static boolean |
hasRecordTypePrefix(KeyExpression key)
Determine whether the given key expression has a record type key prefix.
|
static KeyWithValueExpression |
keyWithValue(KeyExpression child,
int splitPoint)
A
keyWithValue expression is a top level expression that takes as input an expression that
produces more than one column, and indicates that all columns before the specified splitPoint
should be used in the key of an index and all of the values starting at the splitPoint
are to be used as the value of the index. |
static ListKeyExpression |
list(KeyExpression... children)
Combine multiple expressions into a list.
|
static ListKeyExpression |
list(List<KeyExpression> children)
Combine multiple expressions into a list.
|
static NestingKeyExpression |
mapKeys(String name)
Index key from a
map . |
static NestingKeyExpression |
mapKeyValues(String name)
Index key and value from a
map . |
static NestingKeyExpression |
mapValueKeys(String name)
Index value and key from a
map . |
static NestingKeyExpression |
mapValues(String name)
Index value from a
map . |
static RecordTypeKeyExpression |
recordType()
The record type key expression, which indicates that a unique record type identifier should
be contained within the key.
|
static <T> LiteralKeyExpression<T> |
value(T value)
Create a static scalar value of type
T . |
static VersionKeyExpression |
version()
The version key expression, which indicates that a versionstamp should be contained within the key.
|
@Nonnull public static final String MAP_KEY_FIELD
map
messages.@Nonnull public static final String MAP_VALUE_FIELD
map
messages.@Nonnull public static FieldKeyExpression field(@Nonnull String name)
Key.Evaluated.NullStandin
to Key.Evaluated.NullStandin.NULL
. See field(String, KeyExpression.FanType, com.apple.foundationdb.record.metadata.Key.Evaluated.NullStandin)
for more details.name
- the name of the field to evaluatefield(String, KeyExpression.FanType, com.apple.foundationdb.record.metadata.Key.Evaluated.NullStandin)
@Nonnull public static FieldKeyExpression field(@Nonnull String name, @Nonnull KeyExpression.FanType fanType)
Key.Evaluated.NullStandin
to
Key.Evaluated.NullStandin.NULL
. See field(String, KeyExpression.FanType, com.apple.foundationdb.record.metadata.Key.Evaluated.NullStandin)
for more details.name
- the name of the field to evaluatefanType
- the way that repeated fields should be handledfield(String, KeyExpression.FanType, com.apple.foundationdb.record.metadata.Key.Evaluated.NullStandin)
@Nonnull public static FieldKeyExpression field(@Nonnull String name, @Nonnull KeyExpression.FanType fanType, @Nonnull Key.Evaluated.NullStandin nullStandin)
This also takes a Key.Evaluated.NullStandin
value to describe the field's behavior when it encounters an
unset field. If the value is NOT_NULL
, it will use the field's default
value instead of null
. If the value is NULL
, it will return the
value null
and disable any uniqueness checks (if the index is a unique
index). If the value is NULL_UNIQUE
, it will return null
and not disable any uniqueness checks. (In other words, it will treat null
just like any other value.)
Note that for most use cases, the same value should be used for the nullStandIn
every time the field
is referenced by any key expression or different indexes may have different ideas as to, for example,
whether a field can be null
or not. For this reason, there are plans to move this expression from
the field to meta-data on the RecordType
. See Issue #677
for more details.
name
- the name of the field to evaluatefanType
- the way that repeated fields should be handlednullStandin
- value to use in place of missing values,
determining whether it will contribute to unique indexes@Nonnull public static ThenKeyExpression concat(@Nonnull KeyExpression first, @Nonnull KeyExpression second, @Nonnull KeyExpression... rest)
first
- the first child expression to use in the indexsecond
- the second child expression to use in the indexrest
- this supports any number children (at least 2), this is the rest of them@Nonnull public static ThenKeyExpression concat(@Nonnull List<KeyExpression> children)
children
- child expressions@Nonnull public static ThenKeyExpression concatenateFields(@Nonnull String first, @Nonnull String second, @Nonnull String... fields)
first
- the name of the first field to use in the indexsecond
- the name of the second field to use in the indexfields
- this supports any number fields (at least 2), this is the rest of them@Nonnull public static ThenKeyExpression concatenateFields(@Nonnull List<String> fields)
fields
- names of the fields@Nonnull public static ListKeyExpression list(@Nonnull KeyExpression... children)
children
- child expressions@Nonnull public static ListKeyExpression list(@Nonnull List<KeyExpression> children)
children
- child expressions@Nonnull public static NestingKeyExpression mapKeyValues(@Nonnull String name)
map
.
A map can be an actual Protobuf 3 map
field or,
in Protobuf 2, a repeated
message field with fields named key
and value
.name
- name of the map fieldmap
field.@Nonnull public static NestingKeyExpression mapKeys(@Nonnull String name)
map
.
A map can be an actual Protobuf 3 map
field or,
in Protobuf 2, a repeated
message field with fields named key
and value
.name
- name of the map fieldmap
field.@Nonnull public static NestingKeyExpression mapValues(@Nonnull String name)
map
.
A map can be an actual Protobuf 3 map
field or,
in Protobuf 2, a repeated
message field with fields named key
and value
.name
- name of the map fieldmap
field.@Nonnull public static NestingKeyExpression mapValueKeys(@Nonnull String name)
map
.
Like mapKeyValues(java.lang.String)
, but with the key and value field order reversed. This allows queries
such as equality on the value and inequality on the key or equality on the value ordered by the key.
A map can be an actual Protobuf 3 map
field or,
in Protobuf 2, a repeated
message field with fields named key
and value
.name
- name of the map fieldmap
field.@Nonnull public static FunctionKeyExpression function(@Nonnull String name, @Nonnull KeyExpression arguments)
name
- the name of the functionarguments
- the arguments to the function@Nonnull public static FunctionKeyExpression function(@Nonnull String name)
name
- the name of the function@Nonnull public static <T> LiteralKeyExpression<T> value(@Nullable T value)
T
. The typical use case for this would be to
pass arguments to a function call (see FunctionKeyExpression
).T
- the type of the valuevalue
- the T
value@Nonnull public static KeyWithValueExpression keyWithValue(@Nonnull KeyExpression child, int splitPoint)
keyWithValue
expression is a top level expression that takes as input an expression that
produces more than one column, and indicates that all columns before the specified splitPoint
should be used in the key of an index and all of the values starting at the splitPoint
are to be used as the value of the index.child
- the key expression to splitsplitPoint
- the position in the key result to split
keys before this position are part of the key and keys after this position are part of the value@Nonnull public static EmptyKeyExpression empty()
EmptyKeyExpression
@Nonnull public static VersionKeyExpression version()
VersionKeyExpression
@Nonnull public static RecordTypeKeyExpression recordType()
RecordTypeKeyExpression
@Nonnull public static FieldKeyExpression fromDescriptor(@Nonnull Descriptors.FieldDescriptor fieldDescriptor)
fieldDescriptor
- a field in a record type.Field
to get the value of the given field descriptor.public static boolean hasRecordTypePrefix(@Nonnull KeyExpression key)
key
- key expression to checktrue
if the given key expression has a record type key prefix