Package com.apple.foundationdb.tuple
Class TupleHelpers
- java.lang.Object
-
- com.apple.foundationdb.tuple.TupleHelpers
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compare(Tuple t1, Tuple t2)
Compare two tuples lexicographically, that is, the same way they would sort when used as keys.static boolean
equals(Tuple t1, Tuple t2)
Determine if twoTuple
s have the same contents.static Number
negate(Number number)
Negate a number used as an element of aTuple
.static int
packedSizeAsTupleItem(Object item)
Get the number of bytes that an object would occupy as an element of an encodedTuple
.static Tuple
set(Tuple src, int index, Object value)
static Tuple
subTuple(Tuple src, int start, int end)
-
-
-
Method Detail
-
compare
@API(MAINTAINED) public static int compare(@Nonnull Tuple t1, @Nonnull Tuple t2)
Compare two tuples lexicographically, that is, the same way they would sort when used as keys. Note that this is currently WAY more efficient than callingTuple.equals(java.lang.Object)
, and slightly more efficient than callingTuple.compareTo(com.apple.foundationdb.tuple.Tuple)
.
-
equals
public static boolean equals(@Nullable Tuple t1, @Nullable Tuple t2)
Determine if twoTuple
s have the same contents. Unfortunately, the implementation ofTuple.equals()
serializes bothTuple
s to byte arrays, so it is fairly expensive. This method avoids serializing eitherTuple
, and it also adds a short-circuit to return early if the twoTuple
s are pointer-equal.
-
negate
public static Number negate(@Nonnull Number number)
Negate a number used as an element of aTuple
.- Parameters:
number
- the number to be negated- Returns:
- a negated number suitable for use in a new
Tuple
-
packedSizeAsTupleItem
public static int packedSizeAsTupleItem(Object item)
Get the number of bytes that an object would occupy as an element of an encodedTuple
. UnlikeTuple.getPackedSize()
, this does not include the extra space an incompleteVersionstamp
would add to the end to record its position.- Parameters:
item
- an item of a tuple- Returns:
- the number of bytes in the encoded form of the item
-
-