org.apache.cassandra.db

## Class RangeTombstone.Tracker

- java.lang.Object
- - org.apache.cassandra.db.RangeTombstone.Tracker

- Enclosing class:
    RangeTombstone

      public static class RangeTombstone.Tracker
      extends java.lang.Object

  Tracks opened RangeTombstones when iterating over a partition.

  This tracker must be provided all the atoms of a given partition in order (to the `update` method). Given this, it keeps enough information to be able to decide if one of an atom is deleted (shadowed) by a previously open RT. One the tracker can prove a given range tombstone cannot be useful anymore (that is, as soon as we've seen an atom that is after the end of that RT), it discards this RT. In other words, the maximum memory used by this object should be proportional to the maximum number of RT that can be simultaneously open (and this should fairly low in practice).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tracker(java.util.Comparator<Composite> comparator)` Creates a new tracker given the table comparator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `hasUnwrittenTombstones()`
    `boolean` | `isDeleted(Cell cell)` Tests if the provided column is deleted by one of the tombstone tracked by this tracker.
    `boolean` | `update(OnDiskAtom atom, boolean isExpired)` Update this tracker given an `atom`.
    `long` | `writeOpenedMarkers(Composite startPos, DataOutputPlus out, OnDiskAtom.SerializerForWriting atomSerializer)` Computes the RangeTombstone that are needed at the beginning of an index block starting with `firstColumn`.
    `long` | `writeUnwrittenTombstones(DataOutputPlus out, OnDiskAtom.SerializerForWriting atomSerializer)` Writes out all tombstones that have been accepted after the previous call of this method.
    `int` | `writtenAtom()` The total number of atoms written by calls to the above methods.

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

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

- - ### Constructor Detail

    - #### Tracker

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

      Creates a new tracker given the table comparator.
      Parameters:
        `comparator` - the comparator for the table this will track atoms for. The tracker assumes that atoms will be later provided to the tracker in `comparator` order.

  - ### Method Detail

    - #### writeOpenedMarkers

          public long writeOpenedMarkers(Composite startPos,
                                         DataOutputPlus out,
                                         OnDiskAtom.SerializerForWriting atomSerializer)
                                  throws java.io.IOException

      Computes the RangeTombstone that are needed at the beginning of an index block starting with `firstColumn`.
      Returns:
        the total serialized size of said tombstones and write them to `out` it if isn't null.
      Throws:
        `java.io.IOException`

    - #### writeUnwrittenTombstones

          public long writeUnwrittenTombstones(DataOutputPlus out,
                                               OnDiskAtom.SerializerForWriting atomSerializer)
                                        throws java.io.IOException

      Writes out all tombstones that have been accepted after the previous call of this method. Tombstones are not written immediately to permit redundant ones to be skipped.
      Returns:
        the serialized size of written tombstones
      Throws:
        `java.io.IOException`

    - #### writtenAtom

          public int writtenAtom()

      The total number of atoms written by calls to the above methods.

    - #### update

          public boolean update(OnDiskAtom atom,
                                boolean isExpired)

      Update this tracker given an `atom`.

      This method first test if some range tombstone can be discarded due to the knowledge of that new atom. Then, if it's a range tombstone, it adds it to the tracker.

      Note that this method should be called on *every* atom of a partition for the tracker to work as efficiently as possible (#9486).

    - #### isDeleted

          public boolean isDeleted(Cell cell)

      Tests if the provided column is deleted by one of the tombstone tracked by this tracker.

      This method should be called on columns in the same order than for the update() method. Note that this method does not update the tracker so the update() method should still be called on `column` (it doesn't matter if update is called before or after this call).

    - #### hasUnwrittenTombstones

          public boolean hasUnwrittenTombstones()

Copyright © 2018 The Apache Software Foundation