org.apache.hadoop.hbase.io
Class TimeRange

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

@InterfaceAudience.Public
@InterfaceStability.Stable
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.

Only used internally; should not be accessed directly by clients.

Immutable. Thread-safe.


Field Summary
static long INITIAL_MAX_TIMESTAMP
           
static long INITIAL_MIN_TIMESTAMP
           
 
Constructor Summary
TimeRange()
          Default constructor.
TimeRange(byte[] minStamp)
          Represents interval [minStamp, Long.MAX_VALUE)
TimeRange(byte[] minStamp, byte[] maxStamp)
          Deprecated. This is removed in the 2.0 line and above
TimeRange(long minStamp)
          Represents interval [minStamp, Long.MAX_VALUE)
TimeRange(long minStamp, long maxStamp)
          Deprecated. This is made @InterfaceAudience.Private in the 2.0 line and above
 
Method Summary
 int compare(long timestamp)
          Compare the timestamp to timerange.
 long getMax()
           
 long getMin()
           
 boolean includesTimeRange(TimeRange tr)
          Check if the range has any overlap with TimeRange
 boolean isAllTime()
          Check if it is for all time
 String toString()
           
 boolean withinOrAfterTimeRange(long timestamp)
          Check if the specified timestamp is within this TimeRange.
 boolean withinTimeRange(byte[] bytes, int offset)
          Check if the specified timestamp is within this TimeRange.
 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 Detail

INITIAL_MIN_TIMESTAMP

public static final long INITIAL_MIN_TIMESTAMP
See Also:
Constant Field Values

INITIAL_MAX_TIMESTAMP

public static final long INITIAL_MAX_TIMESTAMP
See Also:
Constant Field Values
Constructor Detail

TimeRange

public TimeRange()
Default constructor. Represents interval [0, Long.MAX_VALUE) (allTime)


TimeRange

public TimeRange(long minStamp)
Represents interval [minStamp, Long.MAX_VALUE)

Parameters:
minStamp - the minimum timestamp value, inclusive

TimeRange

public TimeRange(byte[] minStamp)
Represents interval [minStamp, Long.MAX_VALUE)

Parameters:
minStamp - the minimum timestamp value, inclusive

TimeRange

@Deprecated
public TimeRange(byte[] minStamp,
                            byte[] maxStamp)
          throws IOException
Deprecated. This is removed in the 2.0 line and above

Represents interval [minStamp, maxStamp)

Parameters:
minStamp - the minimum timestamp, inclusive
maxStamp - the maximum timestamp, exclusive
Throws:
IOException

TimeRange

@Deprecated
public TimeRange(long minStamp,
                            long maxStamp)
Deprecated. This is made @InterfaceAudience.Private in the 2.0 line and above

Represents interval [minStamp, maxStamp)

Parameters:
minStamp - the minimum timestamp, inclusive
maxStamp - the maximum timestamp, exclusive
Throws:
IllegalArgumentException - if either <0,
Method Detail

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(byte[] bytes,
                               int offset)
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 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

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


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.