com.thinkaurelius.titan.diskstorage

## Class Mutation<E,K>

- java.lang.Object
- - com.thinkaurelius.titan.diskstorage.Mutation<E,K>

- Direct Known Subclasses:
    IndexMutation, KCVEntryMutation, KCVMutation, KVMutation

      public abstract class Mutation<E,K>
      extends Object

  Container for collection mutations against a data store. Mutations are either additions or deletions.
  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Mutation()`
    `Mutation(List<E> additions, List<K> deletions)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addition(E entry)` Adds a new entry as an addition to this mutation
    `abstract void` | `consolidate()`
    `<V> void` | `consolidate(com.google.common.base.Function<E,V> convertAdds, com.google.common.base.Function<K,V> convertDels)` Consolidates this mutation by removing redundant deletions.
    `void` | `deletion(K key)` Adds a new key as a deletion to this mutation
    `List<E>` | `getAdditions()` Returns the list of additions in this mutation
    `List<K>` | `getDeletions()` Returns the list of deletions in this mutation.
    `int` | `getTotalMutations()`
    `boolean` | `hasAdditions()` Whether this mutation has additions
    `boolean` | `hasDeletions()` Whether this mutation has deletions
    `abstract boolean` | `isConsolidated()`
    `<V> boolean` | `isConsolidated(com.google.common.base.Function<E,V> convertAdds, com.google.common.base.Function<K,V> convertDels)` Checks whether this mutation is consolidated in the sense of `consolidate(com.google.common.base.Function, com.google.common.base.Function)`.
    `boolean` | `isEmpty()`
    `void` | `merge(Mutation<E,K> m)` Merges another mutation into this mutation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Mutation

          public Mutation(List<E> additions,
                  List<K> deletions)

    - #### Mutation

          public Mutation()

  - ### Method Detail

    - #### hasAdditions

          public boolean hasAdditions()

      Whether this mutation has additions
      Returns:

    - #### hasDeletions

          public boolean hasDeletions()

      Whether this mutation has deletions
      Returns:

    - #### getAdditions

          public List<E> getAdditions()

      Returns the list of additions in this mutation
      Returns:

    - #### getDeletions

          public List<K> getDeletions()

      Returns the list of deletions in this mutation.
      Returns:

    - #### addition

          public void addition(E entry)

      Adds a new entry as an addition to this mutation
      Parameters:
        `entry` -

    - #### deletion

          public void deletion(K key)

      Adds a new key as a deletion to this mutation
      Parameters:
        `key` -

    - #### merge

          public void merge(Mutation<E,K> m)

      Merges another mutation into this mutation. Ensures that all additions and deletions are added to this mutation. Does not remove duplicates if such exist - this needs to be ensured by the caller.
      Parameters:
        `m` -

    - #### isEmpty

          public boolean isEmpty()

    - #### getTotalMutations

          public int getTotalMutations()

    - #### consolidate

          public <V> void consolidate(com.google.common.base.Function<E,V> convertAdds,
                             com.google.common.base.Function<K,V> convertDels)

      Consolidates this mutation by removing redundant deletions. A deletion is considered redundant if it is identical to some addition under the provided conversion functions since we consider additions to apply logically after deletions. Hence, such a deletion would be applied and immediately overwritten by an addition. To avoid this inefficiency, consolidation should be called. The provided conversion functions map additions and deletions into some object space V for comparison. An addition is considered identical to a deletion if both map to the same object (i.e. equals=true) with the respective conversion functions. It needs to be ensured that V objects have valid hashCode() and equals() implementations.
      Parameters:
        `convertAdds` - Function which maps additions onto comparison objects.
        `convertDels` - Function which maps deletions onto comparison objects.

    - #### consolidate

          public abstract void consolidate()

    - #### isConsolidated

          public <V> boolean isConsolidated(com.google.common.base.Function<E,V> convertAdds,
                                   com.google.common.base.Function<K,V> convertDels)

      Checks whether this mutation is consolidated in the sense of `consolidate(com.google.common.base.Function, com.google.common.base.Function)`. This should only be used in assertions and tests due to the performance penalty.
      Type Parameters:
        `V` -
      Parameters:
        `convertAdds` -
        `convertDels` -
      Returns:

    - #### isConsolidated

          public abstract boolean isConsolidated()

Copyright © 2012–2014. All rights reserved.