@API(value=MAINTAINED) public interface KeyExpression extends PlanHashable
Modifier and Type | Interface and Description |
---|---|
static class |
KeyExpression.DeserializationException
Exception thrown when there is a problem deserializing a key expression.
|
static class |
KeyExpression.FanType
How should repeated fields be handled.
|
static class |
KeyExpression.InvalidExpressionException
Exception thrown when there is a problem with using a key expression in a certain context.
|
static class |
KeyExpression.InvalidResultException
This is a runtime exception (i.e.
|
static class |
KeyExpression.NoSuchArgumentException
Exception thrown when a function key expression does not have an argument.
|
static class |
KeyExpression.SerializationException
Exception thrown when there is a problem serializing a key expression.
|
Modifier and Type | Method and Description |
---|---|
boolean |
createsDuplicates()
This states whether the given expression type is capable of evaluating more to more than
one value when applied to a single record.
|
default <M extends Message> |
evaluate(FDBRecord<M> record)
Evaluate against a given record producing a list of evaluated keys.
|
<M extends Message> |
evaluateMessage(FDBRecord<M> record,
Message message)
Evaluate this expression against a record or a Protobuf message.
|
default <M extends Message> |
evaluateSingleton(FDBRecord<M> record)
Evaluate this expression with the expectation of getting exactly one result.
|
static KeyExpression |
fromProto(RecordMetaDataProto.KeyExpression expression) |
int |
getColumnSize()
Returns the number of items in each KeyValue that will be returned.
|
KeyExpression |
getSubKey(int start,
int end)
Returns a sub-set of the key expression.
|
default boolean |
hasProperInterfaces() |
default boolean |
hasRecordTypeKey()
Check whether a key expression uses record type key in some way.
|
boolean |
isPrefixKey(KeyExpression key)
Check whether a key is a prefix of another key.
|
default List<KeyExpression> |
normalizeKeyForPositions()
Get key in normalized form for comparing field-by-field.
|
RecordMetaDataProto.KeyExpression |
toKeyExpression() |
Message |
toProto() |
List<Descriptors.FieldDescriptor> |
validate(Descriptors.Descriptor descriptor)
Validate this expression against a given record type descriptor.
|
default int |
versionColumns()
Returns the number of version columns produced by this key expression.
|
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHash, planHashUnordered, stringHashUnordered
@Nonnull default <M extends Message> List<Key.Evaluated> evaluate(@Nullable FDBRecord<M> record)
evaluateMessage(com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>, com.google.protobuf.Message)
instead of this one, even if they do not deal with
Protobuf messages, so that they interact properly with expressions that do.M
- the type of recordrecord
- the recordKeyExpression.InvalidResultException
- if any returned result has some number of columns other
than the return value of getColumnSize()
@Nonnull default <M extends Message> Key.Evaluated evaluateSingleton(@Nullable FDBRecord<M> record)
M
- the type of recordrecord
- the record@Nonnull <M extends Message> List<Key.Evaluated> evaluateMessage(@Nullable FDBRecord<M> record, @Nullable Message message)
evaluateMessage
.
Under ordinary circumstances, if record
is null
, then message
will be null
.
Otherwise, message
will be record.getRecord()
or some submessage of that, possibly null
if
the corresponding field is missing.M
- the type of recordrecord
- the recordmessage
- the Protobuf message to evaluate againstevaluate(com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
boolean createsDuplicates()
FanType.FanOut
set (either directly
or indirectly).true
if this expression can evaluate to multiple values and false
otherwiseList<Descriptors.FieldDescriptor> validate(@Nonnull Descriptors.Descriptor descriptor)
descriptor
- the descriptor for the record type or submessageKeyExpression.InvalidExpressionException
- if the expression is not valid for the given descriptorint getColumnSize()
KeyExpression.FanType.Concatenate
, this will the count of non-nested lists, i.e. this will be value of
evaluate(r).get(i).toList().size() for any i or r.@Nonnull Message toProto() throws KeyExpression.SerializationException
@Nonnull RecordMetaDataProto.KeyExpression toKeyExpression()
@Nonnull default List<KeyExpression> normalizeKeyForPositions()
default int versionColumns()
default boolean hasRecordTypeKey()
true
if record type key is used@Nonnull KeyExpression getSubKey(int start, int end)
start
- starting positionend
- ending positionstart
and end
boolean isPrefixKey(@Nonnull KeyExpression key)
key
- the whole key to checktrue
if prefix
is a left subset of key
default boolean hasProperInterfaces()
@Nonnull static KeyExpression fromProto(RecordMetaDataProto.KeyExpression expression) throws KeyExpression.DeserializationException