Class TupleRange

java.lang.Object
com.apple.foundationdb.record.TupleRange

@API(UNSTABLE) public class TupleRange extends Object
A range within a subspace specified by two Tuple endpoints.
  • Field Details

  • Constructor Details

  • Method Details

    • getLow

      @Nullable public Tuple getLow()
    • getHigh

      @Nullable public Tuple getHigh()
    • getLowEndpoint

      @Nonnull public EndpointType getLowEndpoint()
    • getHighEndpoint

      @Nonnull public EndpointType getHighEndpoint()
    • equals

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

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

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

      @Nonnull protected static String tupleToString(@Nullable Tuple t)
    • isEquals

      public boolean isEquals()
    • prepend

      @Nonnull public TupleRange prepend(@Nonnull Tuple beginning)
      Create a TupleRange over the same keys as this range but prepended by the supplied Tuple. For example, if this range is over all Tuples from ("a", 3) exclusive to ("b", 4) inclusive and one calls this method with (0, null) as the argument, this will create a range from (0, null, "a", 3) exclusive to (0, null, "b", 4) inclusive.
      Parameters:
      beginning - a Tuple to prepend to the beginning of this range
      Returns:
      a new TupleRange over all keys in this range but prepended with beginning
    • prefix

      @Nonnull public TupleRange prefix(int prefixCount)
      Create a TupleRange over a prefix of the keys of this range. For example, if this range is over all Tuples from ("a", 3) exclusive to ("b", 4) inclusive and one calls this method with prefixCount of 1, this will create a range from ("a") inclusive to ("b") inclusive. Note that the newly returned TupleRange is guaranteed to encompass the old range.
      Parameters:
      prefixCount - the number of prefix parts to consider
      Returns:
      a new TupleRange of a prefix of predixCount parts of this tuple range
    • overlaps

      public boolean overlaps(@Nonnull Tuple lowTuple, @Nonnull Tuple highTuple)
      Method to compute if an inclusive/inclusive range given by two Tuples overlap with this tuple range.
      Parameters:
      lowTuple - low tuple
      highTuple - high tuple
      Returns:
      true if and only if the range [lowTuple, highTuple] overlaps this tuple range
    • contains

      public boolean contains(@Nonnull Tuple tuple)
      Method to compute if a given Tuple is contained within this tuple range.
      Parameters:
      tuple - tuple
      Returns:
      true if and only if tuple is contained within this tuple range
    • allOf

      @Nonnull public static TupleRange allOf(@Nullable Tuple prefix)
      Create a TupleRange over all keys beginning with a given Tuple. This is a shortcut for creating a TupleRange with prefix as both the low- and high-endpoint and setting both endpoint types to RANGE_INCLUSIVE.
      Parameters:
      prefix - the Tuple all keys in the returned range should begin with
      Returns:
      a TupleRange corresponding to keys prefixed by prefix
    • between

      public static TupleRange between(@Nullable Tuple low, @Nullable Tuple high)
      Create a TupleRange over all keys between the given Tuples.
      Parameters:
      low - the inclusive start of the range
      high - the exclusive end of the range
      Returns:
      a TupleRange between start and end
    • betweenInclusive

      public static TupleRange betweenInclusive(@Nullable Tuple low, @Nullable Tuple high)
      Create a TupleRange over all keys between the given Tuples, including both endpoints.
      Parameters:
      low - the inclusive start of the range
      high - the inclusive end of the range
      Returns:
      a TupleRange between start and end, inclusive
    • prefixedBy

      @Nonnull public static TupleRange prefixedBy(@Nonnull String prefixString)
      Create a TupleRange over all keys prefixed by some String. This is a shortcut for creating a TupleRange where both the low- and high-endpoints are Tuples containing a single String where both the low and high endpoint types are PREFIX_STRING.
      Parameters:
      prefixString - the string that the keys in the returned range will have as a prefix
      Returns:
      a TupleRange corresponding to keys prefixed by prefixString
    • toRange

      @Nonnull public Range toRange()
      Convert into a FoundationDB Range. This behaves just like the version of toRange() that takes a Subspace, but this version does not prefix the resulting range with anything. If either endpoint is null, then the null endpoints will be replaced with byte arrays representing the beginning or ending of the user-readable keys in FoundationDB (that is, it will not include the system keyspace).
      Returns:
      a FoundationDB Range over the same keys as this TupleRange
    • toRange

      @Nonnull public Range toRange(@Nonnull Subspace subspace)
      Convert into a FoundationDB Range. This adjusts the endpoints of this TupleRange and creates a Range object that spans over the same range of keys. This range can be passed to Trasaction.getRange(), for example. As with all other ranges in FoundationDB, the resulting range will include its beginning endpoint but exclude its ending endpoint. The range produced will be prefixed by the Subspace provided.
      Parameters:
      subspace - the Subspace this range should be prefixed by
      Returns:
      a FoundationDB Range over the same keys as this TupleRange
    • toRange

      @Nonnull public static Range toRange(@Nullable byte[] lowBytes, @Nullable byte[] highBytes, @Nonnull EndpointType lowEndpoint, @Nonnull EndpointType highEndpoint)
      Convert a pair of endpoints into a FoundationDB Range. If both lowBytes and highBytes could be unpacked into Tuples, this would be equivalent to unpacking them, creating a TupleRange object out of them, and then calling toRange() on the resulting TupleRange.
      Parameters:
      lowBytes - the beginning of the range
      highBytes - the end of the range
      lowEndpoint - the type (inclusive, exclusive, etc.) of the low endpoint
      highEndpoint - the type (inclusive, exclusive, etc.) of the high endpoint
      Returns:
      a FoundationDB Range over the same keys as the provided parameters