Class LongUuid
java.lang.Object
io.clonecloudstore.common.standard.guid.LongUuid
UUID Generator but limited to 1 Long (64 bits), compatible multi instances (through the PID,
but not multi servers, neither multi-sites due to lack of Mac address/Platform Id.
Inspired from com.groupon locality-uuid which used combination of internal counter value, process id and Timestamp. see https://github.com/groupon/locality-uuid.java
Benchmark shows about 20 millions/s generated LongUuid, 8 M/s getId().
Inspired from com.groupon locality-uuid which used combination of internal counter value, process id and Timestamp. see https://github.com/groupon/locality-uuid.java
Benchmark shows about 20 millions/s generated LongUuid, 8 M/s getId().
-
Constructor Summary
ConstructorsConstructorDescriptionLongUuid()
Constructor that generates a new UUID using the current process id and MAC address, timestamp and a counterLongUuid
(byte[] bytes) Constructor that takes a byte array as UUID's contentLongUuid
(long value) Constructor that takes a String representation of a UUID in Base 16 -
Method Summary
Modifier and TypeMethodDescriptionboolean
byte[]
getBytes()
copy the uuid of this UUID, so that it can't be changed, and return itgetId()
static short
long
getLong()
static long
int
Extract process id from raw UUID bytes and return as intlong
Extract timestamp from raw UUID bytes and return as intint
hashCode()
toString()
-
Constructor Details
-
LongUuid
public LongUuid()Constructor that generates a new UUID using the current process id and MAC address, timestamp and a counter -
LongUuid
public LongUuid(long value) -
LongUuid
public LongUuid(byte[] bytes) Constructor that takes a byte array as UUID's content- Parameters:
bytes
- UUID content
-
LongUuid
Constructor that takes a String representation of a UUID in Base 16- Parameters:
idsource
- UUID content as String
-
-
Method Details
-
getLongUuid
public static long getLongUuid()- Returns:
- a new Uuid as long
-
getKeySize
public static short getKeySize()- Returns:
- the LongUuid size in bytes
-
getBytes
public byte[] getBytes()copy the uuid of this UUID, so that it can't be changed, and return it- Returns:
- raw byte array of UUID
-
getProcessId
public int getProcessId()Extract process id from raw UUID bytes and return as int- Returns:
- id of process that generated the UUID
-
getTimestamp
public long getTimestamp()Extract timestamp from raw UUID bytes and return as int- Returns:
- millisecond UTC timestamp from generation of the UUID
-
hashCode
public int hashCode() -
equals
-
toString
-
getId
- Returns:
- the Base 16 representation
-
getLong
public long getLong()- Returns:
- the equivalent UUID as long
-