Package org.apache.accumulo.core.data
Class Range
java.lang.Object
org.apache.accumulo.core.data.Range
- All Implemented Interfaces:
Comparable<Range>
,org.apache.hadoop.io.Writable
,org.apache.hadoop.io.WritableComparable<Range>
This class is used to specify a range of Accumulo keys.
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionRange()
Creates a range that goes from negative to positive infinityRange
(CharSequence row) Creates a range that covers an entire row.Range
(CharSequence startRow, boolean startRowInclusive, CharSequence endRow, boolean endRowInclusive) Creates a range from startRow to endRow.Range
(CharSequence startRow, CharSequence endRow) Creates a range from startRow inclusive to endRow inclusive.protected
Range
(Key start, boolean startKeyInclusive, boolean infiniteStartKey, Key stop, boolean stopKeyInclusive, boolean infiniteStopKey) Creates a range from start to stop.Creates a range from startKey to endKey.Creates a range from startKey inclusive to endKey inclusive.Range
(Key start, Key stop, boolean startKeyInclusive, boolean stopKeyInclusive, boolean infiniteStartKey, boolean infiniteStopKey) Creates a range from start to stop.Copies a range.Range
(org.apache.accumulo.core.dataImpl.thrift.TRange trange) Creates a range from a Thrift range.Range
(org.apache.hadoop.io.Text row) Creates a range that covers an entire row.Range
(org.apache.hadoop.io.Text startRow, boolean startRowInclusive, org.apache.hadoop.io.Text endRow, boolean endRowInclusive) Creates a range from startRow to endRow.Range
(org.apache.hadoop.io.Text startRow, org.apache.hadoop.io.Text endRow) Creates a range from startRow inclusive to endRow inclusive. -
Method Summary
Modifier and TypeMethodDescriptionboolean
afterEndKey
(Key key) Determines if the given key is after the ending key of this range.boolean
beforeStartKey
(Key key) Determines if the given key is before the start key of this range.Creates a new range that is bounded by the columns passed in.Creates a range which represents the intersection of this range and the passed in range.Creates a range which represents the intersection of this range and the passed in range.int
Compares this range to another range.boolean
Determines if the given key falls within this range.boolean
boolean
Determines if this range equals another.static Range
exact
(CharSequence row) Creates a range that covers an exact row.static Range
exact
(CharSequence row, CharSequence cf) Creates a range that covers an exact row and column family.static Range
exact
(CharSequence row, CharSequence cf, CharSequence cq) Creates a range that covers an exact row, column family, and column qualifier.static Range
exact
(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv) Creates a range that covers an exact row, column family, column qualifier, and column visibility.static Range
exact
(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv, long ts) Creates a range that covers an exact row, column family, column qualifier, column visibility, and timestamp.static Range
exact
(org.apache.hadoop.io.Text row) Creates a range that covers an exact row.static Range
exact
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf) Creates a range that covers an exact row and column family.static Range
exact
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq) Creates a range that covers an exact row, column family, and column qualifier.static Range
exact
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv) Creates a range that covers an exact row, column family, column qualifier, and column visibility.static Range
exact
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv, long ts) Creates a range that covers an exact row, column family, column qualifier, column visibility, and timestamp.static org.apache.hadoop.io.Text
followingPrefix
(org.apache.hadoop.io.Text prefix) Returns a Text that sorts just after all Texts beginning with a prefix.Gets the ending key, or null if the end is positive infinity.Gets the start key, or null if the start is negative infinity.int
hashCode()
boolean
Gets whether the end key of this range is inclusive.boolean
Gets whether the start key is negative infinity.boolean
Gets whether the end key is positive infinity.boolean
Gets whether the start key of this range is inclusive.mergeOverlapping
(Collection<Range> ranges) Merges overlapping and adjacent ranges.static Range
prefix
(CharSequence rowPrefix) Returns a Range that covers all rows beginning with a prefix.static Range
prefix
(CharSequence row, CharSequence cfPrefix) Returns a Range that covers all column families beginning with a prefix within a given row.static Range
prefix
(CharSequence row, CharSequence cf, CharSequence cqPrefix) Returns a Range that covers all column qualifiers beginning with a prefix within a given row and column family.static Range
prefix
(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cvPrefix) Returns a Range that covers all column visibilities beginning with a prefix within a given row, column family, and column qualifier.static Range
prefix
(org.apache.hadoop.io.Text rowPrefix) Returns a Range that covers all rows beginning with a prefix.static Range
prefix
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cfPrefix) Returns a Range that covers all column families beginning with a prefix within a given row.static Range
prefix
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cqPrefix) Returns a Range that covers all column qualifiers beginning with a prefix within a given row and column family.static Range
prefix
(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cvPrefix) Returns a Range that covers all column visibilities beginning with a prefix within a given row, column family, and column qualifier.void
readFields
(DataInput in) toString()
org.apache.accumulo.core.dataImpl.thrift.TRange
toThrift()
Converts this range to Thrift.void
write
(DataOutput out)
-
Constructor Details
-
Range
public Range()Creates a range that goes from negative to positive infinity -
Range
Creates a range from startKey inclusive to endKey inclusive.- Parameters:
startKey
- starting key; set to null for negative infinityendKey
- ending key; set to null for positive infinity- Throws:
IllegalArgumentException
- if end key is before start key
-
Range
Creates a range that covers an entire row.- Parameters:
row
- row to cover; set to null to cover all rows
-
Range
public Range(org.apache.hadoop.io.Text row) Creates a range that covers an entire row.- Parameters:
row
- row to cover; set to null to cover all rows
-
Range
public Range(org.apache.hadoop.io.Text startRow, org.apache.hadoop.io.Text endRow) Creates a range from startRow inclusive to endRow inclusive.- Parameters:
startRow
- starting row; set to null for negative infinityendRow
- ending row; set to null for positive infinity- Throws:
IllegalArgumentException
- if end row is before start row
-
Range
Creates a range from startRow inclusive to endRow inclusive.- Parameters:
startRow
- starting row; set to null for negative infinityendRow
- ending row; set to null for positive infinity- Throws:
IllegalArgumentException
- if end row is before start row
-
Range
public Range(org.apache.hadoop.io.Text startRow, boolean startRowInclusive, org.apache.hadoop.io.Text endRow, boolean endRowInclusive) Creates a range from startRow to endRow.- Parameters:
startRow
- starting row; set to null for negative infinitystartRowInclusive
- true to include start row, false to skipendRow
- ending row; set to null for positive infinityendRowInclusive
- true to include end row, false to skip- Throws:
IllegalArgumentException
- if end row is before start row
-
Range
public Range(CharSequence startRow, boolean startRowInclusive, CharSequence endRow, boolean endRowInclusive) Creates a range from startRow to endRow.- Parameters:
startRow
- starting row; set to null for negative infinitystartRowInclusive
- true to include start row, false to skipendRow
- ending row; set to null for positive infinityendRowInclusive
- true to include end row, false to skip- Throws:
IllegalArgumentException
- if end row is before start row
-
Range
Creates a range from startKey to endKey.- Parameters:
startKey
- starting key; set to null for negative infinitystartKeyInclusive
- true to include start key, false to skipendKey
- ending key; set to null for positive infinityendKeyInclusive
- true to include end key, false to skip- Throws:
IllegalArgumentException
- if end key is before start key
-
Range
Copies a range.- Parameters:
range
- range to copy
-
Range
public Range(Key start, Key stop, boolean startKeyInclusive, boolean stopKeyInclusive, boolean infiniteStartKey, boolean infiniteStopKey) Creates a range from start to stop.- Parameters:
start
- set this to null when negative infinity is neededstop
- set this to null when infinity is neededstartKeyInclusive
- determines if the ranges includes the start keystopKeyInclusive
- determines if the range includes the end keyinfiniteStartKey
- true if start key is negative infinity (null)infiniteStopKey
- true if stop key is positive infinity (null)- Throws:
IllegalArgumentException
- if stop is before start, or infiniteStartKey is true but start is not null, or infiniteStopKey is true but stop is not null
-
Range
protected Range(Key start, boolean startKeyInclusive, boolean infiniteStartKey, Key stop, boolean stopKeyInclusive, boolean infiniteStopKey) Creates a range from start to stop. Unlike the public six-argument method, this one does not assure that stop is after start, which helps performance in cases where that assurance is already in place.- Parameters:
start
- set this to null when negative infinity is neededstartKeyInclusive
- determines if the ranges includes the start keyinfiniteStartKey
- true if start key is negative infinity (null)stop
- set this to null when infinity is neededstopKeyInclusive
- determines if the range includes the end keyinfiniteStopKey
- true if stop key is positive infinity (null)- Throws:
IllegalArgumentException
- if infiniteStartKey is true but start is not null, or infiniteStopKey is true but stop is not null
-
Range
public Range(org.apache.accumulo.core.dataImpl.thrift.TRange trange) Creates a range from a Thrift range.- Parameters:
trange
- Thrift range
-
-
Method Details
-
getStartKey
Gets the start key, or null if the start is negative infinity.- Returns:
- start key
-
beforeStartKey
Determines if the given key is before the start key of this range.- Parameters:
key
- key to check- Returns:
- true if the given key is before the range, otherwise false
-
getEndKey
Gets the ending key, or null if the end is positive infinity.- Returns:
- ending key
-
afterEndKey
Determines if the given key is after the ending key of this range.- Parameters:
key
- key to check- Returns:
- true if the given key is after the range, otherwise false
-
hashCode
public int hashCode() -
equals
-
equals
Determines if this range equals another.- Parameters:
otherRange
- range to compare- Returns:
- true if ranges are equals, false otherwise
- See Also:
-
compareTo
Compares this range to another range. Compares in order: start key, inclusiveness of start key, end key, inclusiveness of end key. Infinite keys sort first, and non-infinite keys are compared withKey.compareTo(Key)
. Inclusive sorts before non-inclusive.- Specified by:
compareTo
in interfaceComparable<Range>
- Parameters:
o
- range to compare- Returns:
- comparison result
-
contains
Determines if the given key falls within this range.- Parameters:
key
- key to consider- Returns:
- true if the given key falls within the range, false otherwise
-
mergeOverlapping
Merges overlapping and adjacent ranges. For example given the following input:[a,c], (c, d], (g,m), (j,t]
the following ranges would be returned:[a,d], (g,t]
- Parameters:
ranges
- to merge- Returns:
- list of merged ranges
-
clip
Creates a range which represents the intersection of this range and the passed in range. The following example will print true.Range range1 = new Range("a", "f"); Range range2 = new Range("c", "n"); Range range3 = range1.clip(range2); System.out.println(range3.equals(new Range("c", "f")));
- Parameters:
range
- range to clip to- Returns:
- the intersection of this range and the given range
- Throws:
IllegalArgumentException
- if ranges does not overlap
-
clip
Creates a range which represents the intersection of this range and the passed in range. Unlikeclip(Range)
, this method can optionally return null if the ranges do not overlap, instead of throwing an exception. The returnNullIfDisjoint parameter controls this behavior.- Parameters:
range
- range to clip toreturnNullIfDisjoint
- true to return null if ranges are disjoint, false to throw an exception- Returns:
- the intersection of this range and the given range, or null if ranges do not overlap and returnNullIfDisjoint is true
- Throws:
IllegalArgumentException
- if ranges does not overlap and returnNullIfDisjoint is false- See Also:
-
bound
Creates a new range that is bounded by the columns passed in. The start key in the returned range will have a column >= to the minimum column. The end key in the returned range will have a column <= the max column.- Parameters:
min
- minimum columnmax
- maximum column- Returns:
- a column bounded range
- Throws:
IllegalArgumentException
- if the minimum column compares greater than the maximum column
-
toString
-
readFields
- Specified by:
readFields
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
write
- Specified by:
write
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
isStartKeyInclusive
public boolean isStartKeyInclusive()Gets whether the start key of this range is inclusive.- Returns:
- true if start key is inclusive
-
isEndKeyInclusive
public boolean isEndKeyInclusive()Gets whether the end key of this range is inclusive.- Returns:
- true if end key is inclusive
-
toThrift
public org.apache.accumulo.core.dataImpl.thrift.TRange toThrift()Converts this range to Thrift.- Returns:
- Thrift range
-
isInfiniteStartKey
public boolean isInfiniteStartKey()Gets whether the start key is negative infinity.- Returns:
- true if start key is negative infinity
-
isInfiniteStopKey
public boolean isInfiniteStopKey()Gets whether the end key is positive infinity.- Returns:
- true if end key is positive infinity
-
exact
Creates a range that covers an exact row. Returns the same Range asRange(Text)
.- Parameters:
row
- row to cover; set to null to cover all rows
-
exact
Creates a range that covers an exact row and column family.- Parameters:
row
- row to covercf
- column family to cover
-
exact
public static Range exact(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq) Creates a range that covers an exact row, column family, and column qualifier.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to cover
-
exact
public static Range exact(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv) Creates a range that covers an exact row, column family, column qualifier, and column visibility.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to cover
-
exact
public static Range exact(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cv, long ts) Creates a range that covers an exact row, column family, column qualifier, column visibility, and timestamp.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to coverts
- timestamp to cover
-
followingPrefix
public static org.apache.hadoop.io.Text followingPrefix(org.apache.hadoop.io.Text prefix) Returns a Text that sorts just after all Texts beginning with a prefix.- Parameters:
prefix
- to follow- Returns:
- prefix that immediately follows the given prefix when sorted, or null if no prefix can follow (i.e., the string is all 0xff bytes)
-
prefix
Returns a Range that covers all rows beginning with a prefix.- Parameters:
rowPrefix
- prefix of rows to cover
-
prefix
Returns a Range that covers all column families beginning with a prefix within a given row.- Parameters:
row
- row to covercfPrefix
- prefix of column families to cover
-
prefix
public static Range prefix(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cqPrefix) Returns a Range that covers all column qualifiers beginning with a prefix within a given row and column family.- Parameters:
row
- row to covercf
- column family to covercqPrefix
- prefix of column qualifiers to cover
-
prefix
public static Range prefix(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text cf, org.apache.hadoop.io.Text cq, org.apache.hadoop.io.Text cvPrefix) Returns a Range that covers all column visibilities beginning with a prefix within a given row, column family, and column qualifier.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercvPrefix
- prefix of column visibilities to cover
-
exact
Creates a range that covers an exact row.- Parameters:
row
- row to cover; set to null to cover all rows- See Also:
-
exact
Creates a range that covers an exact row and column family.- Parameters:
row
- row to covercf
- column family to cover- See Also:
-
exact
Creates a range that covers an exact row, column family, and column qualifier.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to cover- See Also:
-
exact
Creates a range that covers an exact row, column family, column qualifier, and column visibility.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to cover- See Also:
-
exact
public static Range exact(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv, long ts) Creates a range that covers an exact row, column family, column qualifier, column visibility, and timestamp.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to coverts
- timestamp to cover- See Also:
-
prefix
Returns a Range that covers all rows beginning with a prefix.- Parameters:
rowPrefix
- prefix of rows to cover- See Also:
-
prefix
Returns a Range that covers all column families beginning with a prefix within a given row.- Parameters:
row
- row to covercfPrefix
- prefix of column families to cover- See Also:
-
prefix
Returns a Range that covers all column qualifiers beginning with a prefix within a given row and column family.- Parameters:
row
- row to covercf
- column family to covercqPrefix
- prefix of column qualifiers to cover- See Also:
-
prefix
public static Range prefix(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cvPrefix) Returns a Range that covers all column visibilities beginning with a prefix within a given row, column family, and column qualifier.- Parameters:
row
- row to covercf
- column family to covercq
- column qualifier to covercvPrefix
- prefix of column visibilities to cover- See Also:
-