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.

@FunctionalInterface public interface Combiner
Represents an operation which combines two values that map to the same key.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    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
    Returns a Combiner that discards both values (always returns null).
    static Combiner
    Returns a Combiner that chooses the first value and discards the second value.
    default byte[]
    loadDifference(Transaction txn, byte[] key, View first, View second)
    If requireValues 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)
    If requireValues 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)
    If requireValues 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
    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

      static Combiner first()
      Returns a Combiner that chooses the first value and discards the second value.
    • second

      static Combiner second()
      Returns a Combiner that chooses the second value and discards the first value.
    • discard

      static Combiner discard()
      Returns a Combiner that discards both values (always returns null). When used with a union, this causes it to compute the symmetric set difference.
    • combine

      byte[] combine(byte[] key, byte[] first, byte[] second) throws IOException
      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 key
      first - non-null first value in the pair
      second - 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 the READ_COMMITTED lock mode or a null transaction. When storing into a view, acquired locks are always combined.
    • loadUnion

      default byte[] loadUnion(Transaction txn, byte[] key, View first, View second) throws IOException
      If requireValues 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
      If requireValues 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
      If requireValues always returns false, consider overriding this method and implement a more efficient load for two views in a difference.
      Throws:
      IOException
    • separate

      default byte[][] separate(byte[] key, byte[] value) throws IOException
      Separates a combined result, for use when storing a value into a view which uses this combiner. Returns null by default, which then causes a ViewConstraintException to be thrown.
      Parameters:
      key - non-null associated key
      value - non-null combined value
      Returns:
      first and second value, neither of which can be null
      Throws:
      IOException