public class BitsAllocator extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
TOTAL_BITS
Total 64 bits
|
| 构造器和说明 |
|---|
BitsAllocator(int timestampBits,
int workerIdBits,
int sequenceBits)
Constructor with timestampBits, workerIdBits, sequenceBits
The highest bit used for sign, so 63 bits for timestampBits, workerIdBits, sequenceBits |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
allocate(long deltaTime,
long workerId,
long sequence)
Allocate bits for ID according to delta timestamp & workerId & sequence
Note that: The highest bit will always be 0 for sign
|
long |
getMaxDeltaTime() |
long |
getMaxSequence() |
long |
getMaxWorkerId() |
int |
getSequenceBits() |
int |
getSignBits()
Getters
|
int |
getTimestampBits() |
int |
getTimestampShift() |
int |
getWorkerIdBits() |
int |
getWorkerIdShift() |
public static final int TOTAL_BITS
public BitsAllocator(int timestampBits,
int workerIdBits,
int sequenceBits)
63 bits for timestampBits, workerIdBits, sequenceBitspublic long allocate(long deltaTime,
long workerId,
long sequence)
public int getSignBits()
public int getTimestampBits()
public int getWorkerIdBits()
public int getSequenceBits()
public long getMaxDeltaTime()
public long getMaxWorkerId()
public long getMaxSequence()
public int getTimestampShift()
public int getWorkerIdShift()
Copyright © 2020. All rights reserved.