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.
| 限定符和类型 | 字段和说明 |
|---|---|
static long |
EPOCH |
| 构造器和说明 |
|---|
SnowflakeShardingKeyGenerator() |
public String getType()
getType 在接口中 org.apache.shardingsphere.spi.TypeBasedSPIpublic Comparable<?> generateKey()
generateKey 在接口中 ShardingKeyGeneratorCopyright © 2020 The Apache Software Foundation. All rights reserved.