@InterfaceAudience.Public public class TimeRange extends Object
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.
Modifier and Type | Field and Description |
---|---|
static long |
INITIAL_MAX_TIMESTAMP |
static long |
INITIAL_MIN_TIMESTAMP |
Constructor and Description |
---|
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.
|
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.
|
Modifier and Type | Method and Description |
---|---|
static TimeRange |
allTime() |
static TimeRange |
at(long ts) |
static TimeRange |
between(long minStamp,
long maxStamp)
Represents the time interval [minStamp, maxStamp)
|
int |
compare(long timestamp)
Compare the timestamp to timerange.
|
static TimeRange |
from(long minStamp)
Represents the time interval [minStamp, Long.MAX_VALUE)
|
long |
getMax()
Returns the biggest timestamp that should be considered
|
long |
getMin()
Returns the smallest timestamp that should be considered
|
boolean |
includesTimeRange(TimeRange tr)
Check if the range has any overlap with TimeRange
|
boolean |
isAllTime()
Check if it is for all time
|
String |
toString() |
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. Use
withinTimeRange(long) instead |
boolean |
withinTimeRange(long timestamp)
Check if the specified timestamp is within this TimeRange.
|
public static final long INITIAL_MIN_TIMESTAMP
public static final long INITIAL_MAX_TIMESTAMP
@Deprecated @InterfaceAudience.Private public TimeRange()
@Deprecated @InterfaceAudience.Private public TimeRange(long minStamp)
minStamp
- the minimum timestamp value, inclusive@Deprecated @InterfaceAudience.Private public TimeRange(byte[] minStamp)
minStamp
- the minimum timestamp value, inclusive@Deprecated @InterfaceAudience.Private public TimeRange(byte[] minStamp, byte[] maxStamp)
minStamp
- the minimum timestamp, inclusivemaxStamp
- the maximum timestamp, exclusive@Deprecated @InterfaceAudience.Private public TimeRange(long minStamp, long maxStamp)
minStamp
- the minimum timestamp, inclusivemaxStamp
- the maximum timestamp, exclusiveIllegalArgumentException
- if either <0,public static TimeRange from(long minStamp)
minStamp
- the minimum timestamp value, inclusivepublic static TimeRange until(long maxStamp)
maxStamp
- the minimum timestamp value, exclusivepublic static TimeRange between(long minStamp, long maxStamp)
minStamp
- the minimum timestamp, inclusivemaxStamp
- the maximum timestamp, exclusivepublic long getMin()
public long getMax()
public boolean isAllTime()
@Deprecated public boolean withinTimeRange(byte[] bytes, int offset)
withinTimeRange(long)
insteadReturns true if within interval [minStamp, maxStamp), false if not.
bytes
- timestamp to checkoffset
- offset into the bytespublic boolean withinTimeRange(long timestamp)
Returns true if within interval [minStamp, maxStamp), false if not.
timestamp
- timestamp to checkpublic boolean includesTimeRange(TimeRange tr)
tr
- TimeRangepublic boolean withinOrAfterTimeRange(long timestamp)
Returns true if greater than minStamp, false if not.
timestamp
- timestamp to checkpublic int compare(long timestamp)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.