Class RowRange

java.lang.Object
org.apache.accumulo.core.data.RowRange
All Implemented Interfaces:
Comparable<RowRange>

public class RowRange extends Object implements Comparable<RowRange>
This class is used to specify a range of rows.
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static RowRange
    all()
    Creates a range that includes all possible rows.
    Converts this row range to a Range object.
    static RowRange
    atLeast(CharSequence lowerBound)
    Creates a range of rows greater than or equal to the given row.
    static RowRange
    atLeast(org.apache.hadoop.io.Text lowerBound)
    Creates a range of rows greater than or equal to the given row.
    static RowRange
    atMost(CharSequence upperBound)
    Creates a range of rows less than or equal to the given row.
    static RowRange
    atMost(org.apache.hadoop.io.Text upperBound)
    Creates a range of rows less than or equal to the given row.
    clip(RowRange rowRange)
    Creates a row range which represents the intersection of this row range and the given row range.
    clip(RowRange rowRange, boolean returnNullIfDisjoint)
    Creates a row range which represents the intersection of this row range and the given row range.
    static RowRange
    Creates a range that covers an entire row.
    static RowRange
    closed(CharSequence lowerBound, CharSequence upperBound)
    Creates a range of rows from lowerBound inclusive to upperBound inclusive.
    static RowRange
    closed(org.apache.hadoop.io.Text row)
    Creates a range that covers an entire row.
    static RowRange
    closed(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
    Creates a range of rows from lowerBound inclusive to upperBound inclusive.
    static RowRange
    closedOpen(CharSequence lowerBound, CharSequence upperBound)
    Creates a range of rows from lowerBound inclusive to upperBound exclusive.
    static RowRange
    closedOpen(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
    Creates a range of rows from lowerBound inclusive to upperBound exclusive.
    int
    Compares this row range to another row range.
    boolean
    Determines if this row range contains the given row.
    boolean
    contains(org.apache.hadoop.io.Text row)
    Determines if this row range contains the given row.
    boolean
    equals(Object other)
     
    boolean
    Determines if this row range equals another.
    org.apache.hadoop.io.Text
     
    org.apache.hadoop.io.Text
     
    static RowRange
    Creates a range of rows strictly greater than the given row.
    static RowRange
    greaterThan(org.apache.hadoop.io.Text lowerBound)
    Creates a range of rows strictly greater than the given row.
    int
     
    boolean
    isAfter(org.apache.hadoop.io.Text that)
     
    boolean
    isBefore(org.apache.hadoop.io.Text that)
     
    boolean
     
    boolean
     
    static RowRange
    lessThan(CharSequence upperBound)
    Creates a range of rows strictly less than the given row.
    static RowRange
    lessThan(org.apache.hadoop.io.Text upperBound)
    Creates a range of rows strictly less than the given row.
    static List<RowRange>
    Merges overlapping and adjacent row ranges.
    static RowRange
    open(CharSequence lowerBound, CharSequence upperBound)
    Creates a range of rows from lowerBound exclusive to upperBound exclusive.
    static RowRange
    open(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
    Creates a range of rows from lowerBound exclusive to upperBound exclusive.
    static RowRange
    openClosed(CharSequence lowerBound, CharSequence upperBound)
    Creates a range of rows from lowerBound exclusive to upperBound inclusive.
    static RowRange
    openClosed(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
    Creates a range of rows from lowerBound exclusive to upperBound inclusive.
    static RowRange
    range(CharSequence lowerBound, boolean lowerBoundInclusive, CharSequence upperBound, boolean upperBoundInclusive)
    Creates a range of rows from the given lowerBound to the given upperBound.
    static RowRange
    range(org.apache.hadoop.io.Text lowerBound, boolean lowerBoundInclusive, org.apache.hadoop.io.Text upperBound, boolean upperBoundInclusive)
    Creates a range of rows from the given lowerBound to the given upperBound.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • all

      public static RowRange all()
      Creates a range that includes all possible rows.
    • open

      public static RowRange open(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
      Creates a range of rows from lowerBound exclusive to upperBound exclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • open

      public static RowRange open(CharSequence lowerBound, CharSequence upperBound)
      Creates a range of rows from lowerBound exclusive to upperBound exclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • closed

      public static RowRange closed(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
      Creates a range of rows from lowerBound inclusive to upperBound inclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • closed

      public static RowRange closed(CharSequence lowerBound, CharSequence upperBound)
      Creates a range of rows from lowerBound inclusive to upperBound inclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • closed

      public static RowRange closed(org.apache.hadoop.io.Text row)
      Creates a range that covers an entire row.
      Parameters:
      row - row to cover
    • closed

      public static RowRange closed(CharSequence row)
      Creates a range that covers an entire row.
      Parameters:
      row - row to cover
    • openClosed

      public static RowRange openClosed(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
      Creates a range of rows from lowerBound exclusive to upperBound inclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • openClosed

      public static RowRange openClosed(CharSequence lowerBound, CharSequence upperBound)
      Creates a range of rows from lowerBound exclusive to upperBound inclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • closedOpen

      public static RowRange closedOpen(org.apache.hadoop.io.Text lowerBound, org.apache.hadoop.io.Text upperBound)
      Creates a range of rows from lowerBound inclusive to upperBound exclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • closedOpen

      public static RowRange closedOpen(CharSequence lowerBound, CharSequence upperBound)
      Creates a range of rows from lowerBound inclusive to upperBound exclusive.
      Parameters:
      lowerBound - starting row
      upperBound - ending row
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • greaterThan

      public static RowRange greaterThan(org.apache.hadoop.io.Text lowerBound)
      Creates a range of rows strictly greater than the given row.
      Parameters:
      lowerBound - starting row
    • greaterThan

      public static RowRange greaterThan(CharSequence lowerBound)
      Creates a range of rows strictly greater than the given row.
      Parameters:
      lowerBound - starting row
    • atLeast

      public static RowRange atLeast(org.apache.hadoop.io.Text lowerBound)
      Creates a range of rows greater than or equal to the given row.
      Parameters:
      lowerBound - starting row
    • atLeast

      public static RowRange atLeast(CharSequence lowerBound)
      Creates a range of rows greater than or equal to the given row.
      Parameters:
      lowerBound - starting row
    • lessThan

      public static RowRange lessThan(org.apache.hadoop.io.Text upperBound)
      Creates a range of rows strictly less than the given row.
      Parameters:
      upperBound - ending row
    • lessThan

      public static RowRange lessThan(CharSequence upperBound)
      Creates a range of rows strictly less than the given row.
      Parameters:
      upperBound - ending row
    • atMost

      public static RowRange atMost(org.apache.hadoop.io.Text upperBound)
      Creates a range of rows less than or equal to the given row.
      Parameters:
      upperBound - ending row
    • atMost

      public static RowRange atMost(CharSequence upperBound)
      Creates a range of rows less than or equal to the given row.
      Parameters:
      upperBound - ending row
    • range

      public static RowRange range(org.apache.hadoop.io.Text lowerBound, boolean lowerBoundInclusive, org.apache.hadoop.io.Text upperBound, boolean upperBoundInclusive)
      Creates a range of rows from the given lowerBound to the given upperBound.
      Parameters:
      lowerBound - starting row; set to null for the smallest possible row (an empty one)
      lowerBoundInclusive - set to true to include lower bound, false to skip
      upperBound - ending row; set to null for positive infinity
      upperBoundInclusive - set to true to include upper bound, false to skip
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • range

      public static RowRange range(CharSequence lowerBound, boolean lowerBoundInclusive, CharSequence upperBound, boolean upperBoundInclusive)
      Creates a range of rows from the given lowerBound to the given upperBound.
      Parameters:
      lowerBound - starting row; set to null for the smallest possible row (an empty one)
      lowerBoundInclusive - set to true to include lower bound, false to skip
      upperBound - ending row; set to null for positive infinity
      upperBoundInclusive - set to true to include upper bound, false to skip
      Throws:
      IllegalArgumentException - if upper bound is before lower bound
    • getLowerBound

      public org.apache.hadoop.io.Text getLowerBound()
    • isLowerBoundInclusive

      public boolean isLowerBoundInclusive()
      Returns:
      true if the lower bound is inclusive or null, otherwise false
    • getUpperBound

      public org.apache.hadoop.io.Text getUpperBound()
    • isUpperBoundInclusive

      public boolean isUpperBoundInclusive()
      Returns:
      true if the upper bound is inclusive or null, otherwise false
    • asRange

      public Range asRange()
      Converts this row range to a Range object.
    • isAfter

      public boolean isAfter(org.apache.hadoop.io.Text that)
      Parameters:
      that - row to check
      Returns:
      true if every row in this row range is greater than the given row, otherwise false
    • isBefore

      public boolean isBefore(org.apache.hadoop.io.Text that)
      Parameters:
      that - row to check
      Returns:
      true if every row in this row range is less than the given row, otherwise false
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(RowRange other)
      Determines if this row range equals another.
      Parameters:
      other - range to compare
      Returns:
      true if row ranges are equal, otherwise false
    • compareTo

      public int compareTo(RowRange other)
      Compares this row range to another row range. Compares in order: lower bound, inclusiveness of lower bound, upper bound, inclusiveness of upper bound. Infinite rows sort last, and non-infinite rows are compared with BinaryComparable.compareTo(BinaryComparable). When bounds are equal, inclusive lower bounds sort before exclusive ones, while inclusive upper bounds sort after exclusive ones.
      Specified by:
      compareTo in interface Comparable<RowRange>
      Parameters:
      other - row range to compare
      Returns:
      comparison result
    • contains

      public boolean contains(String row)
      Determines if this row range contains the given row.
      Parameters:
      row - row to check
      Returns:
      true if the row is contained in the row range, otherwise false
    • contains

      public boolean contains(org.apache.hadoop.io.Text row)
      Determines if this row range contains the given row.
      Parameters:
      row - row to check
      Returns:
      true if the row is contained in the row range, otherwise false
    • mergeOverlapping

      public static List<RowRange> mergeOverlapping(Collection<RowRange> rowRanges)
      Merges overlapping and adjacent row ranges. Adjacent ranges are those that share an endpoint where at least one range includes that endpoint. For example, given the following input:
       [a,c], (c, d], (g,m), (j,t]
       
      the following row ranges would be returned:
       [a,d], (g,t]
       
      Parameters:
      rowRanges - the collection of row ranges to merge
      Returns:
      a list of merged row ranges
    • clip

      public RowRange clip(RowRange rowRange)
      Creates a row range which represents the intersection of this row range and the given row range. The following example will print true.
       RowRange rowRange1 = RowRange.closed("a", "f");
       RowRange rowRange2 = RowRange.closed("c", "n");
       RowRange rowRange3 = rowRange1.clip(rowRange2);
       System.out.println(rowRange3.equals(RowRange.closed("c", "f")));
       
      Parameters:
      rowRange - row range to clip to
      Returns:
      the intersection of this row range and the given row range
      Throws:
      IllegalArgumentException - if row ranges do not overlap
    • clip

      public RowRange clip(RowRange rowRange, boolean returnNullIfDisjoint)
      Creates a row range which represents the intersection of this row range and the given row range. Unlike clip(RowRange), this method can optionally return null if the row ranges do not overlap, instead of throwing an exception. The returnNullIfDisjoint parameter controls this behavior.
      Parameters:
      rowRange - row range to clip to
      returnNullIfDisjoint - true to return null if row ranges are disjoint, false to throw an exception
      Returns:
      the intersection of this row range and the given row range, or null if row ranges do not overlap and returnNullIfDisjoint is true
      Throws:
      IllegalArgumentException - if row ranges do not overlap and returnNullIfDisjoint is false
      See Also: