Class TimeRange

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

@Public public final 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 Details

  • Constructor Details

    • TimeRange

      private TimeRange(long minStamp, long maxStamp)
      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

      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