public final class DefaultKeyGenerator extends Object implements KeyGenerator
Use snowflake algorithm. Length is 64 bit.
1bit sign bit. 41bits timestamp offset from 2016.11.01(Sharding-Sphere distributed primary key published data) to now. 10bits worker process id. 12bits auto increment offset in one mills
Call @DefaultKeyGenerator.setWorkerId to set.
| Modifier and Type | Field and Description |
|---|---|
static long |
EPOCH |
| Constructor and Description |
|---|
DefaultKeyGenerator() |
| Modifier and Type | Method and Description |
|---|---|
Number |
generateKey()
Generate key.
|
static void |
setWorkerId(long workerId)
Set work process id.
|
public static void setWorkerId(long workerId)
workerId - work process idpublic Number generateKey()
generateKey in interface KeyGeneratorLong.Copyright © 2018. All rights reserved.