public class SnowFlakeGenerator extends Object implements IdGenerator
+------+----------------------+----------------+-----------+
| sign | delta millisecond | worker node id | sequence |
+------+----------------------+----------------+-----------+
1bit timeBits workerBits seqBits
Note that: The total bits must be 64
| 构造器和说明 |
|---|
SnowFlakeGenerator(int timeBits,
int workerBits,
int seqBits,
long epochTimestamp,
long workerId) |
SnowFlakeGenerator(TimeUnit timeUnit,
int timeBits,
int workerBits,
int seqBits,
long epochTimestamp,
long workerId) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
nextId()
Generate unique id
|
long[] |
nextSegment(int size)
Generate unique id
|
String |
parse(long id)
Parse the ID into elements which are used to generate the ID.
|
public SnowFlakeGenerator(int timeBits,
int workerBits,
int seqBits,
long epochTimestamp,
long workerId)
public SnowFlakeGenerator(TimeUnit timeUnit, int timeBits, int workerBits, int seqBits, long epochTimestamp, long workerId)
public long nextId()
nextId 在接口中 IdGeneratorSnowFlakeException - in the case: Clock moved backwards; Exceeds the max timestamppublic long[] nextSegment(int size)
IdGeneratornextSegment 在接口中 IdGeneratorpublic String parse(long id)
IdGeneratorparse 在接口中 IdGeneratorCopyright © 2020. All rights reserved.