Class DefaultSegmentId

java.lang.Object
me.ahoo.cosid.segment.DefaultSegmentId
All Implemented Interfaces:
IdGenerator, SegmentId, Statistical, StringIdGenerator

public class DefaultSegmentId extends Object implements SegmentId
Default segment algorithm ID generator.
  • Constructor Details

  • Method Details

    • current

      public IdSegment current()
      Description copied from interface: SegmentId
      Get 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.

      Specified by:
      current in interface SegmentId
      Returns:
      The current ID segment
    • generate

      public long generate()
      Description copied from interface: IdGenerator
      Generate 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:
      generate in interface IdGenerator
      Returns:
      A unique distributed ID as a long value