Class TimeRangeTracker

java.lang.Object
org.apache.hadoop.hbase.regionserver.TimeRangeTracker
Direct Known Subclasses:
TimeRangeTracker.NonSyncTimeRangeTracker, TimeRangeTracker.SyncTimeRangeTracker

@Private public abstract class TimeRangeTracker extends Object
Stores minimum and maximum timestamp values, it is [minimumTimestamp, maximumTimestamp] in interval notation. Use this class at write-time ONLY. Too much synchronization to use at read time Use TimeRange at read time instead of this. See toTimeRange() to make TimeRange to use. MemStores use this class to track minimum and maximum timestamps. The TimeRangeTracker made by the MemStore is passed to the StoreFile for it to write out as part a flush in the the file metadata. If no memstore involved -- i.e. a compaction -- then the StoreFile will calculate its own TimeRangeTracker as it appends. The StoreFile serialized TimeRangeTracker is used at read time via an instance of TimeRange to test if Cells fit the StoreFile TimeRange.
  • Field Details

  • Constructor Details

  • Method Details

    • create

    • create

    • create

      public static TimeRangeTracker create(TimeRangeTracker.Type type, long minimumTimestamp, long maximumTimestamp)
    • setMax

      protected abstract void setMax(long ts)
    • setMin

      protected abstract void setMin(long ts)
    • compareAndSetMin

      protected abstract boolean compareAndSetMin(long expect, long update)
    • compareAndSetMax

      protected abstract boolean compareAndSetMax(long expect, long update)
    • includeTimestamp

      public void includeTimestamp(Cell cell)
      Update the current TimestampRange to include the timestamp from cell. If the Key is of type DeleteColumn or DeleteFamily, it includes the entire time range from 0 to timestamp of the key.
      Parameters:
      cell - the Cell to include
    • includeTimestamp

      void includeTimestamp(long timestamp)
      If required, update the current TimestampRange to include timestamp
      Parameters:
      timestamp - the timestamp value to include
    • includesTimeRange

      public boolean includesTimeRange(TimeRange tr)
      Check if the range has ANY overlap with TimeRange
      Parameters:
      tr - TimeRange, it expects [minStamp, maxStamp)
      Returns:
      True if there is overlap, false otherwise
    • getMin

      public abstract long getMin()
      Returns the minimumTimestamp
    • getMax

      public abstract long getMax()
      Returns the maximumTimestamp
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseFrom

      public static TimeRangeTracker parseFrom(byte[] data) throws IOException
      Parameters:
      data - the serialization data. It can't be null!
      Returns:
      An instance of NonSyncTimeRangeTracker filled w/ the content of serialized NonSyncTimeRangeTracker in timeRangeTrackerBytes.
      Throws:
      IOException
    • parseFrom

      public static TimeRangeTracker parseFrom(byte[] data, TimeRangeTracker.Type type) throws IOException
      Throws:
      IOException
    • toByteArray

      public static byte[] toByteArray(TimeRangeTracker tracker) throws IOException
      This method used to serialize TimeRangeTracker (TRT) by protobuf while this breaks the forward compatibility on HFile.(See HBASE-21008) In previous hbase version ( < 2.0.0 ) we use DataOutput to serialize TRT, these old versions don't have capability to deserialize TRT which is serialized by protobuf. So we need to revert the change of serializing TimeRangeTracker back to DataOutput. For more information, please check HBASE-21012.
      Parameters:
      tracker - TimeRangeTracker needed to be serialized.
      Returns:
      byte array filled with serialized TimeRangeTracker.
      Throws:
      IOException - if something goes wrong in writeLong.
    • toTimeRange

      Returns Make a TimeRange from current state of this.