Class TupleHelpers

    • Method Detail

      • equals

        public static boolean equals​(@Nullable
                                     Tuple t1,
                                     @Nullable
                                     Tuple t2)
        Determine if two Tuples have the same contents. Unfortunately, the implementation of Tuple.equals() serializes both Tuples to byte arrays, so it is fairly expensive. This method avoids serializing either Tuple, and it also adds a short-circuit to return early if the two Tuples are pointer-equal.
        Parameters:
        t1 - the first Tuple to compare
        t2 - the second Tuple to compare
        Returns:
        true if the two Tuples would serialize to the same array and false otherwise
      • negate

        public static Number negate​(@Nonnull
                                    Number number)
        Negate a number used as an element of a Tuple.
        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 encoded Tuple. Unlike Tuple.getPackedSize(), this does not include the extra space an incomplete Versionstamp 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