Class TimeUuid
- java.lang.Object
-
- org.apache.jackrabbit.oak.index.indexer.document.tree.store.utils.TimeUuid
-
- All Implemented Interfaces:
Comparable<TimeUuid>
public class TimeUuid extends Object implements Comparable<TimeUuid>
A UUID implementation. It supports creating version 7 UUIDs, which are time-ordered. See also draft-ietf-uuidrev-rfc4122bis-00 Unlike java.util.UUID, the comparison is unsigned, so that the string comparison yields the same result.
-
-
Constructor Summary
Constructors Constructor Description TimeUuid(long msb, long lsb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(TimeUuid o)Unlike java.util.UUID, the comparison is unsigned, so that the string comparison yields the same result.booleanequals(Object obj)longgetCounterPart()Get the counter part (12 bits).longgetLeastSignificantBits()static longgetMillisAndCountIncreasing(long now, AtomicLong lastMillisAndCount)Get the next timestamp (in milliseconds) and counter.longgetMostSignificantBits()longgetRandomPart()Get the random part (62 bits).longgetTimestampPart()Get the timestamp part (48 bits).inthashCode()static TimeUuidnewUuid()StringtoHumanReadableString()StringtoShortString()StringtoString()
-
-
-
Method Detail
-
toShortString
public String toShortString()
-
toHumanReadableString
public String toHumanReadableString()
-
getTimestampPart
public long getTimestampPart()
Get the timestamp part (48 bits).- Returns:
- the timestamp part
-
getCounterPart
public long getCounterPart()
Get the counter part (12 bits).- Returns:
- counter part
-
getRandomPart
public long getRandomPart()
Get the random part (62 bits). The first 2 bits are fixed.- Returns:
- the random part
-
compareTo
public int compareTo(TimeUuid o)
Unlike java.util.UUID, the comparison is unsigned, so that the string comparison yields the same result.- Specified by:
compareToin interfaceComparable<TimeUuid>
-
getMillisAndCountIncreasing
public static long getMillisAndCountIncreasing(long now, AtomicLong lastMillisAndCount)Get the next timestamp (in milliseconds) and counter. The lowest 12 bits of the returned value is the counter. The milliseconds are shifted by 12 bits.- Parameters:
now- the millisecondslastMillisAndCount- the last returned value- Returns:
- the new value
-
newUuid
public static TimeUuid newUuid()
-
getMostSignificantBits
public long getMostSignificantBits()
-
getLeastSignificantBits
public long getLeastSignificantBits()
-
-