Package me.ahoo.cosid.uncertainty
Class UncertaintyIdGenerator
java.lang.Object
me.ahoo.cosid.uncertainty.UncertaintyIdGenerator
- All Implemented Interfaces:
Decorator<IdGenerator>
,IdGenerator
,IdGeneratorDecorator
,Statistical
,StringIdGenerator
Uncertainty ID Generator.
For the following usage scenarios:
1. The problem of uneven sharding of snowflake IDs. 2. I don’t want the generated ID to be predictable, such as preventing crawler by ID number, predicting transaction volume.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
generate()
Generate distributed ID.Get decorator actual id generator.long
int
int
long
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.ahoo.cosid.IdGenerator
generateAsString, idConverter
Methods inherited from interface me.ahoo.cosid.IdGeneratorDecorator
stat
-
Field Details
-
actual
-
-
Constructor Details
-
UncertaintyIdGenerator
-
-
Method Details
-
uncertaintyBits
public int uncertaintyBits() -
originalIdBits
public int originalIdBits() -
uncertaintyBound
public long uncertaintyBound() -
maxOriginalId
public long maxOriginalId() -
getActual
Description copied from interface:IdGeneratorDecorator
Get decorator actual id generator.- Specified by:
getActual
in interfaceDecorator<IdGenerator>
- Specified by:
getActual
in interfaceIdGeneratorDecorator
- Returns:
- actual id generator
-
generate
public long generate()Description copied from interface:IdGenerator
Generate distributed ID.- Specified by:
generate
in interfaceIdGenerator
- Specified by:
generate
in interfaceIdGeneratorDecorator
- Returns:
- generated distributed ID
-