Package org.apache.accumulo.core.data
Class Range
- java.lang.Object
-
- org.apache.accumulo.core.data.Range
-
-
Constructor Summary
Constructors Modifier Constructor Description Range()
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.Range(Key startKey, boolean startKeyInclusive, Key endKey, boolean endKeyInclusive)
Creates a range from startKey to endKey.Range(Key startKey, Key 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.Range(Range range)
Copies a range.Range(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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.Range
bound(Column min, Column max)
Creates a new range that is bounded by the columns passed in.Range
clip(Range range)
Creates a range which represents the intersection of this range and the passed in range.Range
clip(Range range, boolean returnNullIfDisjoint)
Creates a range which represents the intersection of this range and the passed in range.int
compareTo(Range o)
Compares this range to another range.boolean
contains(Key key)
Determines if the given key falls within this range.boolean
equals(Object o)
boolean
equals(Range otherRange)
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.Key
getEndKey()
Gets the ending key, or null if the end is positive infinity.Key
getStartKey()
Gets the start key, or null if the start is negative infinity.int
hashCode()
boolean
isEndKeyInclusive()
Gets whether the end key of this range is inclusive.boolean
isInfiniteStartKey()
Gets whether the start key is negative infinity.boolean
isInfiniteStopKey()
Gets whether the end key is positive infinity.boolean
isStartKeyInclusive()
Gets whether the start key of this range is inclusive.static List<Range>
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)
String
toString()
TRange
toThrift()
Converts this range to Thrift.void
write(DataOutput out)
-
-
-
Constructor Detail
-
Range
public Range()
Creates a range that goes from negative to positive infinity
-
Range
public Range(Key startKey, Key endKey)
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
public Range(CharSequence 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 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
public Range(CharSequence startRow, CharSequence 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
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 start row, false to skip- Throws:
IllegalArgumentException
- if end row is before start row
-
Range
public Range(Key startKey, boolean startKeyInclusive, Key endKey, boolean endKeyInclusive)
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 start key, false to skip- Throws:
IllegalArgumentException
- if end key is before start key
-
Range
public Range(Range 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(TRange trange)
Creates a range from a Thrift range.- Parameters:
trange
- Thrift range
-
-
Method Detail
-
getStartKey
public Key getStartKey()
Gets the start key, or null if the start is negative infinity.- Returns:
- start key
-
beforeStartKey
public boolean beforeStartKey(Key key)
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
public Key getEndKey()
Gets the ending key, or null if the end is positive infinity.- Returns:
- ending key
-
afterEndKey
public boolean afterEndKey(Key key)
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
-
equals
public boolean equals(Range otherRange)
Determines if this range equals another.- Parameters:
otherRange
- range to compare- Returns:
- true if ranges are equals, false otherwise
- See Also:
compareTo(Range)
-
compareTo
public int compareTo(Range o)
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
public boolean contains(Key key)
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
public static List<Range> mergeOverlapping(Collection<Range> ranges)
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
public Range clip(Range range)
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
public Range clip(Range range, boolean returnNullIfDisjoint)
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:
clip(Range)
-
bound
public Range bound(Column min, Column max)
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
-
readFields
public void readFields(DataInput in) throws IOException
- Specified by:
readFields
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
write
public void write(DataOutput out) throws IOException
- 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 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
public static Range exact(org.apache.hadoop.io.Text row)
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
public 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.- Parameters:
row
- 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 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 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 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
public static Range prefix(org.apache.hadoop.io.Text rowPrefix)
Returns a Range that covers all rows beginning with a prefix.- Parameters:
rowPrefix
- prefix of rows to cover
-
prefix
public 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.- 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
public static Range exact(CharSequence row)
Creates a range that covers an exact row.- Parameters:
row
- row to cover; set to null to cover all rows- See Also:
exact(Text)
-
exact
public static Range exact(CharSequence row, CharSequence cf)
Creates a range that covers an exact row and column family.- Parameters:
row
- row row to covercf
- column family to cover- See Also:
exact(Text, Text)
-
exact
public static Range exact(CharSequence row, CharSequence cf, CharSequence cq)
Creates a range that covers an exact row, column family, and column qualifier.- Parameters:
row
- row row to covercf
- column family to covercq
- column qualifier to cover- See Also:
exact(Text, Text, Text)
-
exact
public 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.- Parameters:
row
- row row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to cover- See Also:
exact(Text, Text, Text, Text)
-
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 row to covercf
- column family to covercq
- column qualifier to covercv
- column visibility to coverts
- timestamp to cover- See Also:
exact(Text, Text, Text, Text, long)
-
prefix
public static Range prefix(CharSequence rowPrefix)
Returns a Range that covers all rows beginning with a prefix.- Parameters:
rowPrefix
- prefix of rows to cover- See Also:
prefix(Text)
-
prefix
public static Range prefix(CharSequence row, CharSequence cfPrefix)
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(Text, Text)
-
prefix
public 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.- Parameters:
row
- row to covercf
- column family to covercqPrefix
- prefix of column qualifiers to cover- See Also:
prefix(Text, Text, Text)
-
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:
prefix(Text, Text, Text, Text)
-
-