Class HiLoSequenceGenerator

java.lang.Object
io.higson.runtime.hilo.HiLoSequenceGenerator
All Implemented Interfaces:
IdentifierGenerator

public class HiLoSequenceGenerator extends Object implements IdentifierGenerator
Classic hi-lo identifier generator. Reserves a contiguous buffer of allocationSize ids per single database round-trip.

Requires the underlying sequence to be declared with INCREMENT BY 1. Each nextval() returns a hi value; the generator multiplies it by allocationSize to derive the buffer boundaries.

For a sequence starting at 1 with INCREMENT BY 1 and allocationSize = 50:

  • first nextval() returns 1 → buffer [50, 99]
  • second nextval() returns 2 → buffer [100, 149]
Thread-safe via an internal monitor; a single instance may be shared across concurrent callers.