RangeTombstoneList (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.db

## Class RangeTombstoneList

- java.lang.Object
- - org.apache.cassandra.db.RangeTombstoneList

- All Implemented Interfaces:
    java.lang.Iterable<RangeTombstone>, IMeasurableMemory

      public class RangeTombstoneList
      extends java.lang.Object
      implements java.lang.Iterable<RangeTombstone>, IMeasurableMemory

  Data structure holding the range tombstones of a ColumnFamily.

  This is essentially a sorted list of non-overlapping (tombstone) ranges.

  A range tombstone has 4 elements: the start and end of the range covered, and the deletion infos (markedAt timestamp and local deletion time). The markedAt timestamp is what define the priority of 2 overlapping tombstones. That is, given 2 tombstones [0, 10]@t1 and [5, 15]@t2, then if t2 > t1 (and are the tombstones markedAt values), the 2nd tombstone take precedence over the first one on [5, 10]. If such tombstones are added to a RangeTombstoneList, the range tombstone list will store them as [[0, 5]@t1, [5, 15]@t2].

  The only use of the local deletion time is to know when a given tombstone can be purged, which will be done by the purge() method.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `RangeTombstoneList.InOrderTester` This object allow testing whether a given column (name/timestamp) is deleted or not by this RangeTombstoneList, assuming that the column given to this object are passed in (comparator) sorted order.
    `static class` | `RangeTombstoneList.Serializer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RangeTombstoneList(java.util.Comparator<Composite> comparator, int capacity)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Composite start, Composite end, long markedAt, int delTime)` Adds a new range tombstone.
    `void` | `add(RangeTombstone tombstone)`
    `void` | `addAll(RangeTombstoneList tombstones)` Adds all the range tombstones of `tombstones` to this RangeTombstoneList.
    `java.util.Comparator<Composite>` | `comparator()`
    `RangeTombstoneList` | `copy()`
    `RangeTombstoneList` | `copy(AbstractAllocator allocator)`
    `int` | `dataSize()`
    `RangeTombstoneList` | `diff(RangeTombstoneList superset)` Evaluates a diff between superset (known to be all merged tombstones) and this list for read repair
    `boolean` | `equals(java.lang.Object o)`
    `int` | `hashCode()`
    `boolean` | `hasPurgeableTombstones(int gcBefore)` Returns whether `purge(gcBefore)` would remove something or not.
    `boolean` | `isDeleted(Cell cell)` Returns whether the given name/timestamp pair is deleted by one of the tombstone of this RangeTombstoneList.
    `boolean` | `isEmpty()`
    `java.util.Iterator<RangeTombstone>` | `iterator()`
    `java.util.Iterator<RangeTombstone>` | `iterator(Composite from, Composite till)`
    `long` | `maxMarkedAt()`
    `long` | `minMarkedAt()`
    `void` | `purge(int gcBefore)` Removes all range tombstones whose local deletion time is older than gcBefore.
    `RangeTombstone` | `search(Composite name)`
    `DeletionTime` | `searchDeletionTime(Composite name)` Returns the DeletionTime for the tombstone overlapping `name` (there can't be more than one), or null if `name` is not covered by any tombstone.
    `int` | `size()`
    `long` | `unsharedHeapSize()`
    `void` | `updateAllTimestamp(long timestamp)`
    `void` | `updateDigest(java.security.MessageDigest digest)` Calculates digest for triggering read repair on mismatch

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

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

- - ### Constructor Detail

    - #### RangeTombstoneList

          public RangeTombstoneList(java.util.Comparator<Composite> comparator,
                            int capacity)

  - ### Method Detail

    - #### isEmpty

          public boolean isEmpty()

    - #### size

          public int size()

    - #### comparator

          public java.util.Comparator<Composite> comparator()

    - #### copy

          public RangeTombstoneList copy()

    - #### copy

          public RangeTombstoneList copy(AbstractAllocator allocator)

    - #### add

          public void add(RangeTombstone tombstone)

    - #### add

          public void add(Composite start,
                 Composite end,
                 long markedAt,
                 int delTime)

      Adds a new range tombstone. This method will be faster if the new tombstone sort after all the currently existing ones (this is a common use case), but it doesn't assume it.

    - #### addAll

          public void addAll(RangeTombstoneList tombstones)

      Adds all the range tombstones of `tombstones` to this RangeTombstoneList.

    - #### isDeleted

          public boolean isDeleted(Cell cell)

      Returns whether the given name/timestamp pair is deleted by one of the tombstone of this RangeTombstoneList.

    - #### searchDeletionTime

          public DeletionTime searchDeletionTime(Composite name)

      Returns the DeletionTime for the tombstone overlapping `name` (there can't be more than one), or null if `name` is not covered by any tombstone.

    - #### search

          public RangeTombstone search(Composite name)

    - #### dataSize

          public int dataSize()

    - #### minMarkedAt

          public long minMarkedAt()

    - #### maxMarkedAt

          public long maxMarkedAt()

    - #### updateAllTimestamp

          public void updateAllTimestamp(long timestamp)

    - #### purge

          public void purge(int gcBefore)

      Removes all range tombstones whose local deletion time is older than gcBefore.

    - #### hasPurgeableTombstones

          public boolean hasPurgeableTombstones(int gcBefore)

      Returns whether `purge(gcBefore)` would remove something or not.

    - #### iterator

          public java.util.Iterator<RangeTombstone> iterator()

      Specified by:
        `iterator` in interface `java.lang.Iterable<RangeTombstone>`

    - #### iterator

          public java.util.Iterator<RangeTombstone> iterator(Composite from,
                                                    Composite till)

    - #### diff

          public RangeTombstoneList diff(RangeTombstoneList superset)

      Evaluates a diff between superset (known to be all merged tombstones) and this list for read repair
      Returns:
        null if there is no difference

    - #### updateDigest

          public void updateDigest(java.security.MessageDigest digest)

      Calculates digest for triggering read repair on mismatch

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### unsharedHeapSize

          public long unsharedHeapSize()

      Specified by:
        `unsharedHeapSize` in interface `IMeasurableMemory`
      Returns:
        the amount of on-heap memory retained by the object that might be reclaimed if the object were reclaimed, i.e. it should try to exclude globally cached data where possible, or counting portions of arrays that are referenced by the object but used by other objects only (e.g. slabbed byte-buffers), etc.

Copyright © 2014 The Apache Software Foundation