public final class SnowflakeShardingKeyGenerator extends Object implements ShardingKeyGenerator
Use snowflake algorithm. Length is 64 bit.
1bit sign bit. 41bits timestamp offset from 2016.11.01(ShardingSphere distributed primary key published data) to now. 10bits worker process id. 12bits auto increment offset in one mills
Call @SnowflakeShardingKeyGenerator.setWorkerId to set worker id, default value is 0.
Call @SnowflakeShardingKeyGenerator.setMaxTolerateTimeDifferenceMilliseconds to set max tolerate time difference milliseconds, default value is 0.
| Modifier and Type | Field and Description |
|---|---|
static long |
EPOCH |
| Constructor and Description |
|---|
SnowflakeShardingKeyGenerator() |
| Modifier and Type | Method and Description |
|---|---|
Comparable<?> |
generateKey() |
String |
getType() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetProperties, setPropertiespublic String getType()
getType in interface TypeBasedSPIpublic Comparable<?> generateKey()
generateKey in interface ShardingKeyGeneratorCopyright © 2020 The Apache Software Foundation. All rights reserved.