Package me.ahoo.cosid.segment
Class DefaultSegmentId
java.lang.Object
me.ahoo.cosid.segment.DefaultSegmentId
- All Implemented Interfaces:
IdGenerator,SegmentId,Statistical,StringIdGenerator
Default segment algorithm ID generator.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSegmentId(long idSegmentTtl, IdSegmentDistributor maxIdDistributor) DefaultSegmentId(IdSegmentDistributor maxIdDistributor) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.IdGenerator
generateAsString, idConverter
-
Constructor Details
-
DefaultSegmentId
-
DefaultSegmentId
-
-
Method Details
-
current
Description copied from interface:SegmentIdGet the current ID segment being used for generation.This method returns the segment from which IDs are currently being allocated. The segment contains the range of available IDs and tracks the current position within that range.
-
generate
public long generate()Description copied from interface:IdGeneratorGenerate a distributed ID as a long value.This method generates a unique numeric identifier that is guaranteed to be unique within the distributed system. The exact algorithm used depends on the implementation (e.g., Snowflake, Segment, CosId).
- Specified by:
generatein interfaceIdGenerator- Returns:
- A unique distributed ID as a long value
-