Class TimeRange

java.lang.Object
org.apache.hadoop.hbase.io.TimeRange

@Public public class TimeRange extends Object
Represents an interval of version timestamps. Presumes timestamps between INITIAL_MIN_TIMESTAMP and INITIAL_MAX_TIMESTAMP only. Gets freaked out if passed a timestamp that is < INITIAL_MIN_TIMESTAMP,

Evaluated according to minStamp <= timestamp < maxStamp or [minStamp,maxStamp) in interval notation.

Can be returned and read by clients. Should not be directly created by clients. Thus, all constructors are purposely @InterfaceAudience.Private.

Immutable. Thread-safe.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final TimeRange
     
    private final boolean
     
    static final long
     
    static final long
     
    private final long
     
    private final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
    TimeRange(byte[] minStamp)
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
    TimeRange(byte[] minStamp, byte[] maxStamp)
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
    TimeRange(long minStamp)
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
    TimeRange(long minStamp, long maxStamp)
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
  • Method Summary

    Modifier and Type
    Method
    Description
    static TimeRange
     
    static TimeRange
    at(long ts)
     
    static TimeRange
    between(long minStamp, long maxStamp)
    Represents the time interval [minStamp, maxStamp)
    private static void
    check(long minStamp, long maxStamp)
     
    int
    compare(long timestamp)
    Compare the timestamp to timerange.
    static TimeRange
    from(long minStamp)
    Represents the time interval [minStamp, Long.MAX_VALUE)
    long
    Returns the biggest timestamp that should be considered
    long
    Returns the smallest timestamp that should be considered
    boolean
    Check if the range has any overlap with TimeRange
    boolean
    Check if it is for all time
    private static boolean
    isAllTime(long minStamp, long maxStamp)
     
     
    static TimeRange
    until(long maxStamp)
    Represents the time interval [0, maxStamp)
    boolean
    withinOrAfterTimeRange(long timestamp)
    Check if the specified timestamp is within or after this TimeRange.
    boolean
    withinTimeRange(byte[] bytes, int offset)
    Deprecated.
    This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
    boolean
    withinTimeRange(long timestamp)
    Check if the specified timestamp is within this TimeRange.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • TimeRange

      @Deprecated @Private public TimeRange()
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
      Default constructor. Represents interval [0, Long.MAX_VALUE) (allTime)
    • TimeRange

      @Deprecated @Private public TimeRange(long minStamp)
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
      Represents interval [minStamp, Long.MAX_VALUE)
      Parameters:
      minStamp - the minimum timestamp value, inclusive
    • TimeRange

      @Deprecated @Private public TimeRange(byte[] minStamp)
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
      Represents interval [minStamp, Long.MAX_VALUE)
      Parameters:
      minStamp - the minimum timestamp value, inclusive
    • TimeRange

      @Deprecated @Private public TimeRange(byte[] minStamp, byte[] maxStamp)
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
      Represents interval [minStamp, maxStamp)
      Parameters:
      minStamp - the minimum timestamp, inclusive
      maxStamp - the maximum timestamp, exclusive
    • TimeRange

      @Deprecated @Private public TimeRange(long minStamp, long maxStamp)
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0.
      Represents interval [minStamp, maxStamp)
      Parameters:
      minStamp - the minimum timestamp, inclusive
      maxStamp - the maximum timestamp, exclusive
      Throws:
      IllegalArgumentException - if either <0,
  • Method Details

    • allTime

      public static TimeRange allTime()
    • at

      public static TimeRange at(long ts)
    • from

      public static TimeRange from(long minStamp)
      Represents the time interval [minStamp, Long.MAX_VALUE)
      Parameters:
      minStamp - the minimum timestamp value, inclusive
    • until

      public static TimeRange until(long maxStamp)
      Represents the time interval [0, maxStamp)
      Parameters:
      maxStamp - the minimum timestamp value, exclusive
    • between

      public static TimeRange between(long minStamp, long maxStamp)
      Represents the time interval [minStamp, maxStamp)
      Parameters:
      minStamp - the minimum timestamp, inclusive
      maxStamp - the maximum timestamp, exclusive
    • isAllTime

      private static boolean isAllTime(long minStamp, long maxStamp)
    • check

      private static void check(long minStamp, long maxStamp)
    • getMin

      public long getMin()
      Returns the smallest timestamp that should be considered
    • getMax

      public long getMax()
      Returns the biggest timestamp that should be considered
    • isAllTime

      public boolean isAllTime()
      Check if it is for all time
      Returns:
      true if it is for all time
    • withinTimeRange

      @Deprecated public boolean withinTimeRange(byte[] bytes, int offset)
      Deprecated.
      This is made @InterfaceAudience.Private in the 2.0 line and above and may be changed to private or removed in 3.0. Use withinTimeRange(long) instead
      Check if the specified timestamp is within this TimeRange.

      Returns true if within interval [minStamp, maxStamp), false if not.

      Parameters:
      bytes - timestamp to check
      offset - offset into the bytes
      Returns:
      true if within TimeRange, false if not
    • withinTimeRange

      public boolean withinTimeRange(long timestamp)
      Check if the specified timestamp is within this TimeRange.

      Returns true if within interval [minStamp, maxStamp), false if not.

      Parameters:
      timestamp - timestamp to check
      Returns:
      true if within TimeRange, false if not
    • includesTimeRange

      public boolean includesTimeRange(TimeRange tr)
      Check if the range has any overlap with TimeRange
      Parameters:
      tr - TimeRange
      Returns:
      True if there is overlap, false otherwise
    • withinOrAfterTimeRange

      public boolean withinOrAfterTimeRange(long timestamp)
      Check if the specified timestamp is within or after this TimeRange.

      Returns true if greater than minStamp, false if not.

      Parameters:
      timestamp - timestamp to check
      Returns:
      true if within or after TimeRange, false if not
    • compare

      public int compare(long timestamp)
      Compare the timestamp to timerange.
      Returns:
      -1 if timestamp is less than timerange, 0 if timestamp is within timerange, 1 if timestamp is greater than timerange
    • toString

      public String toString()
      Overrides:
      toString in class Object