Interface Combiner
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents an operation which combines two values that map to the same key.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
combine
(byte[] key, byte[] first, byte[] second) Return a combined value derived from the given key and value pair.default boolean
Returns false by default, indicating that when loads of the first key acquire a lock, it doesn't need to be held while a lock on the second key is acquired.static Combiner
discard()
Returns a Combiner that discards both values (always returns null).static Combiner
first()
Returns a Combiner that chooses the first value and discards the second value.default byte[]
loadDifference
(Transaction txn, byte[] key, View first, View second) IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in a difference.default byte[]
loadIntersection
(Transaction txn, byte[] key, View first, View second) IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in an intersection.default byte[]
loadUnion
(Transaction txn, byte[] key, View first, View second) IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in a union.default boolean
Returns true by default, indicating that the combine method always requires loaded value instances to be provided.static Combiner
second()
Returns a Combiner that chooses the second value and discards the first value.default byte[][]
separate
(byte[] key, byte[] value) Separates a combined result, for use when storing a value into a view which uses this combiner.
-
Method Details
-
first
Returns a Combiner that chooses the first value and discards the second value. -
second
Returns a Combiner that chooses the second value and discards the first value. -
discard
-
combine
Return a combined value derived from the given key and value pair. Null can be returned to completely discard both values.- Parameters:
key
- non-null associated keyfirst
- non-null first value in the pairsecond
- non-null second value in the pair- Returns:
- combined value or null to discard both values
- Throws:
IOException
-
requireValues
default boolean requireValues()Returns true by default, indicating that the combine method always requires loaded value instances to be provided.- Returns:
- true if loaded values must always be passed into the combine method
-
combineLocks
default boolean combineLocks()Returns false by default, indicating that when loads of the first key acquire a lock, it doesn't need to be held while a lock on the second key is acquired. This option is applicable when using theREAD_COMMITTED
lock mode or a null transaction. When storing into a view, acquired locks are always combined. -
loadUnion
IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in a union.- Throws:
IOException
-
loadIntersection
default byte[] loadIntersection(Transaction txn, byte[] key, View first, View second) throws IOException IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in an intersection.- Throws:
IOException
-
loadDifference
default byte[] loadDifference(Transaction txn, byte[] key, View first, View second) throws IOException IfrequireValues
always returns false, consider overriding this method and implement a more efficient load for two views in a difference.- Throws:
IOException
-
separate
Separates a combined result, for use when storing a value into a view which uses this combiner. Returns null by default, which then causes aViewConstraintException
to be thrown.- Parameters:
key
- non-null associated keyvalue
- non-null combined value- Returns:
- first and second value, neither of which can be null
- Throws:
IOException
-