Class TimeUUID

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<TimeUUID>
    Direct Known Subclasses:
    Ballot

    public class TimeUUID
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<TimeUUID>
    See Also:
    Serialized Form
    • Field Detail

      • UUID_EPOCH_UNIX_MILLIS

        public static final long UUID_EPOCH_UNIX_MILLIS
        See Also:
        Constant Field Values
      • TIMESTAMP_UUID_VERSION_IN_MSB

        protected static final long TIMESTAMP_UUID_VERSION_IN_MSB
        See Also:
        Constant Field Values
      • UUID_VERSION_BITS_IN_MSB

        protected static final long UUID_VERSION_BITS_IN_MSB
        See Also:
        Constant Field Values
      • TIMEUUID_SIZE

        public static final long TIMEUUID_SIZE
    • Constructor Detail

      • TimeUUID

        public TimeUUID​(long uuidTimestamp,
                        long lsb)
    • Method Detail

      • atUnixMicrosWithLsb

        public static TimeUUID atUnixMicrosWithLsb​(long unixMicros,
                                                   long uniqueLsb)
      • atUnixMicrosWithLsbAsUUID

        public static java.util.UUID atUnixMicrosWithLsbAsUUID​(long unixMicros,
                                                               long uniqueLsb)
      • minAtUnixMillis

        public static TimeUUID minAtUnixMillis​(long unixMillis)
        Returns the smaller possible type 1 UUID having the provided timestamp. Warning: this method should only be used for querying as this doesn't at all guarantee the uniqueness of the resulting UUID.
      • maxAtUnixMillis

        public static TimeUUID maxAtUnixMillis​(long unixMillis)
        Returns the biggest possible type 1 UUID having the provided timestamp. Warning: this method should only be used for querying as this doesn't at all guarantee the uniqueness of the resulting UUID.
      • fromString

        public static TimeUUID fromString​(java.lang.String uuidString)
      • fromUuid

        public static TimeUUID fromUuid​(java.util.UUID uuid)
      • fromBytes

        public static TimeUUID fromBytes​(long msb,
                                         long lsb)
      • deserialize

        public static TimeUUID deserialize​(java.nio.ByteBuffer buffer)
      • deserialize

        public static TimeUUID deserialize​(java.io.DataInput in)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • serialize

        public void serialize​(java.io.DataOutput out)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • toBytes

        public java.nio.ByteBuffer toBytes()
      • toBytes

        public static byte[] toBytes​(long msb,
                                     long lsb)
      • sizeInBytes

        public static long sizeInBytes()
      • asUUID

        public java.util.UUID asUUID()
      • unix

        public long unix​(java.util.concurrent.TimeUnit units)
        The Cassandra internal micros-resolution timestamp of the TimeUUID, as of unix epoch
      • unixMicros

        public long unixMicros()
        The Cassandra internal micros-resolution timestamp of the TimeUUID, as of unix epoch
      • uuidTimestamp

        public long uuidTimestamp()
        The UUID-format timestamp, i.e. 10x micros-resolution, as of UUIDGen.UUID_EPOCH_UNIX_MILLIS The tenths of a microsecond are used to store a flag value.
      • msb

        public long msb()
      • lsb

        public long lsb()
      • rawTimestampToUnixMicros

        public static long rawTimestampToUnixMicros​(long rawTimestamp)
      • unixMillisToRawTimestamp

        public static long unixMillisToRawTimestamp​(long unixMillis,
                                                    long tenthsOfAMicro)
      • unixMicrosToRawTimestamp

        public static long unixMicrosToRawTimestamp​(long unixMicros)
      • msbToRawTimestamp

        public static long msbToRawTimestamp​(long msb)
      • rawTimestampToMsb

        public static long rawTimestampToMsb​(long rawTimestamp)
      • hashCode

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

        public boolean equals​(java.lang.Object that)
        Overrides:
        equals in class java.lang.Object
      • equals

        public boolean equals​(TimeUUID that)
      • equals

        public boolean equals​(java.util.UUID that)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public static java.lang.String toString​(TimeUUID ballot)
      • toString

        public static java.lang.String toString​(TimeUUID ballot,
                                                java.lang.String kind)
      • compareTo

        public int compareTo​(TimeUUID that)
        Specified by:
        compareTo in interface java.lang.Comparable<TimeUUID>