org.apache.accumulo.core.data
Class Range

java.lang.Object
  extended by org.apache.accumulo.core.data.Range
All Implemented Interfaces:
Comparable<Range>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Range>

public class Range
extends Object
implements org.apache.hadoop.io.WritableComparable<Range>

This class is used to specify a range of Accumulo Keys.


Constructor Summary
Range()
          Creates a range that goes from negative to positive infinity
Range(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
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)
           
Range(Range range)
          Copies a 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
Range(TRange trange)
           
 
Method Summary
 boolean afterEndKey(Key key)
           
 boolean beforeStartKey(Key key)
           
 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)
          Same as other clip function except if gives the option to return null of the ranges do not overlap instead of throwing an exception.
 int compareTo(Range o)
          Compares this range to another range.
 boolean contains(Key key)
           
 boolean equals(Object o)
           
 boolean equals(Range otherRange)
           
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 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, visibility, and timestamp
static Range exact(org.apache.hadoop.io.Text row)
          Creates a range that covers an exact row Returns the same Range as new Range(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 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, 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()
           
 Key getStartKey()
           
 int hashCode()
           
 boolean isEndKeyInclusive()
           
 boolean isInfiniteStartKey()
           
 boolean isInfiniteStopKey()
           
 boolean isStartKeyInclusive()
           
static List<Range> mergeOverlapping(Collection<Range> ranges)
          Takes a collection on range and 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()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 - set this to null when negative infinity is needed
endKey - set this to null when positive infinity is needed

Range

public Range(CharSequence row)
Creates a range that covers an entire row

Parameters:
row - set this 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 - set this 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 - set this to null when negative infinity is needed
endRow - set this to null when positive infinity is needed

Range

public Range(CharSequence startRow,
             CharSequence endRow)
Creates a range from startRow inclusive to endRow inclusive

Parameters:
startRow - set this to null when negative infinity is needed
endRow - set this to null when positive infinity is needed

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 - set this to null when negative infinity is needed
startRowInclusive - determines if the start row is skipped
endRow - set this to null when positive infinity is needed
endRowInclusive - determines if the endRow is included

Range

public Range(CharSequence startRow,
             boolean startRowInclusive,
             CharSequence endRow,
             boolean endRowInclusive)
Creates a range from startRow to endRow

Parameters:
startRow - set this to null when negative infinity is needed
startRowInclusive - determines if the start row is skipped
endRow - set this to null when positive infinity is needed
endRowInclusive - determines if the endRow is included

Range

public Range(Key startKey,
             boolean startKeyInclusive,
             Key endKey,
             boolean endKeyInclusive)
Creates a range from startKey to endKey

Parameters:
startKey - set this to null when negative infinity is needed
startKeyInclusive - determines if the ranges includes the start key
endKey - set this to null when infinity is needed
endKeyInclusive - determines if the range includes the end key

Range

public Range(Range range)
Copies a range


Range

public Range(Key start,
             Key stop,
             boolean startKeyInclusive,
             boolean stopKeyInclusive,
             boolean infiniteStartKey,
             boolean infiniteStopKey)

Range

public Range(TRange trange)
Method Detail

getStartKey

public Key getStartKey()
Returns:
the first key in the range, null if the key is infinite

beforeStartKey

public boolean beforeStartKey(Key key)
Parameters:
key -
Returns:
true if the given key is before the range, otherwise false

getEndKey

public Key getEndKey()
Returns:
the last key in the range, null if the end key is infinite

afterEndKey

public boolean afterEndKey(Key key)
Parameters:
key -
Returns:
true if the given key is after the range, otherwise false

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

equals

public boolean equals(Range otherRange)

compareTo

public int compareTo(Range o)
Compares this range to another range. Compares in the order start key, inclusiveness of start key, end key, inclusiveness of end key. Infinite keys sort first, and non-infinite keys are compared with Key.compareTo(Key). Inclusive sorts before non-inclusive.

Specified by:
compareTo in interface Comparable<Range>

contains

public boolean contains(Key key)
Parameters:
key -
Returns:
true if the given key falls within the range

mergeOverlapping

public static List<Range> mergeOverlapping(Collection<Range> ranges)
Takes a collection on range and 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 -
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 -
Returns:
the intersection
Throws:
IllegalArgumentException - if ranges does not overlap

clip

public Range clip(Range range,
                  boolean returnNullIfDisjoint)
Same as other clip function except if gives the option to return null of the ranges do not overlap instead of throwing an exception.

Parameters:
range -
returnNullIfDisjoint - If the ranges do not overlap and true is passed, then null is returned otherwise an exception is thrown.
Returns:
the intersection
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 stary 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 -
max -
Returns:
a column bounded range
Throws:
IllegalArgumentException - if min > max

toString

public String toString()
Overrides:
toString in class Object

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

isStartKeyInclusive

public boolean isStartKeyInclusive()

isEndKeyInclusive

public boolean isEndKeyInclusive()

toThrift

public TRange toThrift()

isInfiniteStartKey

public boolean isInfiniteStartKey()

isInfiniteStopKey

public boolean isInfiniteStopKey()

exact

public static Range exact(org.apache.hadoop.io.Text row)
Creates a range that covers an exact row Returns the same Range as new Range(row)

Parameters:
row - all keys in the range will have this row

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 - all keys in the range will have this row
cf - all keys in the range will have this column family

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 - all keys in the range will have this row
cf - all keys in the range will have this column family
cq - all keys in the range will have this column qualifier

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 visibility

Parameters:
row - all keys in the range will have this row
cf - all keys in the range will have this column family
cq - all keys in the range will have this column qualifier
cv - all keys in the range will have this column visibility

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, visibility, and timestamp

Parameters:
row - all keys in the range will have this row
cf - all keys in the range will have this column family
cq - all keys in the range will have this column qualifier
cv - all keys in the range will have this column visibility
ts - all keys in the range will have this timestamp

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 -

prefix

public static Range prefix(org.apache.hadoop.io.Text rowPrefix)
Returns a Range that covers all rows beginning with a prefix

Parameters:
rowPrefix - all keys in the range will have rows that begin with this prefix

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 - all keys in the range will have this row
cfPrefix - all keys in the range will have column families that begin with this prefix

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 - all keys in the range will have this row
cf - all keys in the range will have this column family
cqPrefix - all keys in the range will have column qualifiers that begin with this prefix

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 - all keys in the range will have this row
cf - all keys in the range will have this column family
cq - all keys in the range will have this column qualifier
cvPrefix - all keys in the range will have column visibilities that begin with this prefix

exact

public static Range exact(CharSequence row)
Creates a range that covers an exact row

See Also:
exact(Text)

exact

public static Range exact(CharSequence row,
                          CharSequence cf)
Creates a range that covers an exact row and column family

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

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 visibility

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, visibility, and timestamp

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

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

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

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

See Also:
prefix(Text, Text, Text, Text)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.