@API(value=MAINTAINED) public class ListKeyExpression extends BaseKeyExpression implements KeyExpressionWithChildren
Form a cross-product similar to ThenKeyExpression
, but producing lists containing each
child's evaluation result rather than concatenating.
When converted to a Tuple
, the nth child corresponds
to tuple.getNestedTuple(n)
, which is less compact on disk but easier to find the child boundaries in.
Consider the expressions
concat(field("child_1").nest(field("field_1")), field("child_2").nest(concat(field("field_1"), field("field_2")))
and
concat(field("child_1").nest(concat(field("field_1"), field("field_2"))), field("child_2").nest(field("field_1")))
.
These might produce values like [[1.1, 2.1, 2.2]]
and [[1.1, 1.2, 2.1]]
, respectively.
Recovering the first child's contribution means remembering it or at least its KeyExpression.getColumnSize()
, to know where the boundary is.
Contrast
list(field("child_1").nest(field("field_1")), field("child_2").nest(concat(field("field_1"), field("field_2")))
and
list(field("child_1").nest(concat(field("field_1"), field("field_2"))), field("child_2").nest(field("field_1")))
.
These would produce [[[1.1], [2.1, 2.2]]]
and [[[1.1, 1.2], [2.1]]]
, respectively.
BaseKeyExpression.IllegalSubKeyException, BaseKeyExpression.UnsplittableKeyExpressionException
KeyExpression.DeserializationException, KeyExpression.FanType, KeyExpression.InvalidExpressionException, KeyExpression.InvalidResultException, KeyExpression.NoSuchArgumentException, KeyExpression.SerializationException
Constructor and Description |
---|
ListKeyExpression(List<KeyExpression> exprs) |
ListKeyExpression(RecordMetaDataProto.List list) |
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) |
<M extends Message> |
evaluateMessage(FDBRecord<M> record,
Message message)
Evaluate this expression against a record or a Protobuf message.
|
List<KeyExpression> |
getChildren() |
int |
getColumnSize()
Returns the number of items in each KeyValue that will be returned.
|
KeyExpression |
getSubKeyImpl(int start,
int end) |
int |
hashCode() |
boolean |
hasRecordTypeKey()
Check whether a key expression uses record type key in some way.
|
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.List |
toProto() |
String |
toString() |
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, isPrefixKey
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
evaluate, evaluateSingleton, fromProto, getSubKey, hasProperInterfaces, isPrefixKey
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHashUnordered, stringHashUnordered
public ListKeyExpression(@Nonnull List<KeyExpression> exprs)
public ListKeyExpression(@Nonnull RecordMetaDataProto.List list) 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()
getColumnSize
in interface KeyExpression
@Nonnull public RecordMetaDataProto.List 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
public int versionColumns()
KeyExpression
versionColumns
in interface KeyExpression
public boolean hasRecordTypeKey()
KeyExpression
hasRecordTypeKey
in interface KeyExpression
true
if record type key is usedpublic KeyExpression getSubKeyImpl(int start, int end)
getSubKeyImpl
in class BaseKeyExpression
@Nonnull public List<KeyExpression> getChildren()
getChildren
in interface KeyExpressionWithChildren
public int planHash()
PlanHashable
hashCode
, but with the additional guarantee that is is stable across JVMs.planHash
in interface PlanHashable