@API(value=MAINTAINED) public class SplitKeyExpression extends BaseKeyExpression implements AtomKeyExpression, KeyExpressionWithoutChildren
Key.Evaluated
containing several of the values.
For example, 12
values with splitSize
3
turns into 4
Key.Evaluated
.
The same result can be achieved more transparently by having a repeated nested submessage with the several fields
in it; this is for the sake of clients with poorer type systems that only allow for lists of primitive types.BaseKeyExpression.IllegalSubKeyException, BaseKeyExpression.UnsplittableKeyExpressionException
KeyExpression.DeserializationException, KeyExpression.FanType, KeyExpression.InvalidExpressionException, KeyExpression.InvalidResultException, KeyExpression.NoSuchArgumentException, KeyExpression.SerializationException
Constructor and Description |
---|
SplitKeyExpression(KeyExpression joined,
int splitSize) |
SplitKeyExpression(RecordMetaDataProto.Split split) |
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.
|
boolean |
equals(Object o) |
boolean |
equalsAtomic(AtomKeyExpression other) |
<M extends Message> |
evaluateMessage(FDBRecord<M> record,
Message message)
Evaluate this expression against a record or a Protobuf message.
|
int |
getColumnSize()
Returns the number of items in each KeyValue that will be returned.
|
KeyExpression |
getJoined() |
GroupingKeyExpression |
groupBy(KeyExpression groupByFirst,
KeyExpression... groupByRest) |
int |
hashCode() |
boolean |
hasRecordTypeKey()
Check whether a key expression uses record type key in some way.
|
KeyExpression |
normalizeForPlanner(Source source,
List<String> fieldNamePrefix)
Normalize this key expression into another key expression that pushes all nesting and fan-out to
ElementKeyExpression s at the leaves. |
List<KeyExpression> |
normalizeKeyForPositions()
Get key in normalized form for comparing field-by-field.
|
int |
planHash()
Return a hash similar to
hashCode , but with the additional guarantee that is is stable across JVMs. |
RecordMetaDataProto.KeyExpression |
toKeyExpression() |
RecordMetaDataProto.Split |
toProto() |
String |
toString() |
GroupingKeyExpression |
ungrouped()
Get this entire split as a group without any grouping keys.
|
List<Descriptors.FieldDescriptor> |
validate(Descriptors.Descriptor descriptor)
Validate this expression against a given record type descriptor.
|
int |
versionColumns()
Returns the number of version columns produced by this key expression.
|
getSubKey, getSubKeyImpl, isPrefixKey
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
evaluate, evaluateSingleton, flattenForPlanner, fromProto, getSubKey, hasProperInterfaces, isPrefixKey
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHashUnordered, stringHashUnordered
public SplitKeyExpression(KeyExpression joined, int splitSize)
public SplitKeyExpression(@Nonnull RecordMetaDataProto.Split split) throws KeyExpression.DeserializationException
@Nonnull public <M extends Message> List<Key.Evaluated> evaluateMessage(@Nullable FDBRecord<M> record, @Nullable Message message)
KeyExpression
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.evaluateMessage
in interface KeyExpression
M
- the type of recordrecord
- the recordmessage
- the Protobuf message to evaluate againstKeyExpression.evaluate(com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
public boolean createsDuplicates()
KeyExpression
FanType.FanOut
set (either directly
or indirectly).createsDuplicates
in interface KeyExpression
true
if this expression can evaluate to multiple values and false
otherwisepublic List<Descriptors.FieldDescriptor> validate(@Nonnull Descriptors.Descriptor descriptor)
KeyExpression
validate
in interface KeyExpression
descriptor
- the descriptor for the record type or submessagepublic int getColumnSize()
KeyExpression
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.getColumnSize
in interface KeyExpression
@Nonnull public RecordMetaDataProto.Split toProto() throws KeyExpression.SerializationException
toProto
in interface KeyExpression
KeyExpression.SerializationException
@Nonnull public RecordMetaDataProto.KeyExpression toKeyExpression()
toKeyExpression
in interface KeyExpression
@Nonnull public List<KeyExpression> normalizeKeyForPositions()
KeyExpression
normalizeKeyForPositions
in interface KeyExpression
@Nonnull public KeyExpression normalizeForPlanner(@Nonnull Source source, @Nonnull List<String> fieldNamePrefix)
KeyExpression
ElementKeyExpression
s at the leaves.
By default, a key expression is a complicated nested structure that can be difficult to work with. This method
pushes much of the complexity, including nested structures and fan-out of repeated fields, to special key
expressions that track these relationship using the Source
abstraction. This pre-processing makes
planning nested and repeated structures much simpler.
This normalization process requires tracking some state since the name of a nested field is available
only at the relevant FieldKeyExpression
, but that information is necessary to construct the
ElementKeyExpression
at the leaves of the sub-tree rooted at the NestingKeyExpression
. This
extra information is tracked in the fieldNamePrefix
.
normalizeForPlanner
in interface KeyExpression
source
- the source representing the input stream of the key expressionfieldNamePrefix
- the (non-repeated) field names on the path from the most recent source to this part of the key expressionElementKeyExpression
s at its leavespublic int versionColumns()
KeyExpression
versionColumns
in interface KeyExpression
public boolean hasRecordTypeKey()
KeyExpression
hasRecordTypeKey
in interface KeyExpression
true
if record type key is used@Nonnull public KeyExpression getJoined()
@Nonnull public GroupingKeyExpression ungrouped()
@Nonnull public GroupingKeyExpression groupBy(@Nonnull KeyExpression groupByFirst, @Nonnull KeyExpression... groupByRest)
public int planHash()
PlanHashable
hashCode
, but with the additional guarantee that is is stable across JVMs.planHash
in interface PlanHashable
public boolean equalsAtomic(AtomKeyExpression other)
equalsAtomic
in interface AtomKeyExpression