Class IdBatch


  • public final class IdBatch
    extends Batch
    A batch of 128-bit unsigned integers.
    • Constructor Detail

      • IdBatch

        public IdBatch​(int capacity)
        Constructs an empty batch of ids with the desired maximum capacity.

        Once created, an instance cannot be resized, however it may contain any number of ids between zero and its capacity.

        Parameters:
        capacity - the maximum capacity.
        Throws:
        IllegalArgumentException - if capacity is negative.
    • Method Detail

      • add

        public void add​(byte[] id)
        Adds a new id at the end of this batch.

        If successful, moves the current position to the newly created id.

        Parameters:
        id - an array of 16 bytes representing the 128-bit value.
        Throws:
        IllegalStateException - if this batch is read-only.
        IndexOutOfBoundsException - if exceeds the batch's capacity.
      • add

        public void add​(long leastSignificant,
                        long mostSignificant)
        Adds a new id at the end of this batch.

        If successful, moves the current position to the newly created id.

        Parameters:
        leastSignificant - a long representing the the first 8 bytes of the 128-bit value.
        mostSignificant - a long representing the the last 8 bytes of the 128-bit value.
        Throws:
        IllegalStateException - if this batch is read-only.
        IndexOutOfBoundsException - if exceeds the batch's capacity.
      • add

        public void add​(long leastSignificant)
        Adds a new id at the end of this batch.

        If successful, moves the current position to the newly created id.

        Parameters:
        leastSignificant - a long representing the the first 8 bytes of the 128-bit value.
        Throws:
        IllegalStateException - if this batch is read-only.
        IndexOutOfBoundsException - if exceeds the batch's capacity.
      • setId

        public void setId​(long leastSignificant,
                          long mostSignificant)
        Sets the id.
        Parameters:
        leastSignificant - a long representing the the first 8 bytes of the 128-bit value.
        mostSignificant - a long representing the the last 8 bytes of the 128-bit value.
        Throws:
        IllegalStateException - if not at a valid position.
        IllegalStateException - if a read-only batch.