Class SeqnoList

All Implemented Interfaces:
Iterable<Long>, Constructable<SeqnoList>, SizeStreamable, Streamable

public class SeqnoList extends FixedSizeBitSet implements SizeStreamable, Iterable<Long>, Constructable<SeqnoList>
A bitset of missing messages with a fixed size. The index (in the bit set) of a seqno is computed as seqno - offset.
Since:
3.1
  • Field Details

    • offset

      protected long offset
  • Constructor Details

    • SeqnoList

      public SeqnoList()
      Only to be used by serialization
    • SeqnoList

      public SeqnoList(int size, long offset)
      Creates a SeqnoList with a capacity for size elements.
      Parameters:
      size - The max number of seqnos in the bitset
      offset - Lowest seqno. Used to compute the index of a given seqno into the bitset: seqno - offset
    • SeqnoList

      public SeqnoList(int size)
  • Method Details

    • create

      public Supplier<? extends SeqnoList> create()
      Description copied from interface: Constructable
      Creates an instance of the class implementing this interface
      Specified by:
      create in interface Constructable<SeqnoList>
    • add

      public SeqnoList add(long seqno)
      Adds a single seqno
    • add

      public SeqnoList add(long... seqnos)
    • add

      public SeqnoList add(Collection<Long> seqnos)
    • add

      public SeqnoList add(long from, long to)
      Adds a seqno range
    • removeHigherThan

      public SeqnoList removeHigherThan(long seqno)
      Removes all seqnos > seqno
    • removeLowerThan

      public SeqnoList removeLowerThan(long seqno)
      Removes all seqnos > seqno
    • getLast

      public long getLast()
      Returns the last seqno, this is also the highest seqno in the list as we add seqnos in order
    • getFirst

      public long getFirst()
      Returns the first seqno, this is also the lowest seqno in the list as we add seqnos in order
    • serializedSize

      public int serializedSize()
      Description copied from interface: SizeStreamable
      Returns the size (in bytes) of the marshalled object
      Specified by:
      serializedSize in interface SizeStreamable
    • writeTo

      public void writeTo(DataOutput out) throws IOException
      Description copied from interface: Streamable
      Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed
      Specified by:
      writeTo in interface Streamable
      Throws:
      IOException
    • readFrom

      public void readFrom(DataInput in) throws IOException
      Description copied from interface: Streamable
      Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
      Specified by:
      readFrom in interface Streamable
      Throws:
      IOException
    • size

      public int size()
      Overrides:
      size in class FixedSizeBitSet
    • isEmpty

      public boolean isEmpty()
    • toString

      public String toString()
      Description copied from class: FixedSizeBitSet
      Returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.

      Overrides the toString method of Object.

      Example:

       BitSet drPepper = new BitSet();
      Now drPepper.toString() returns "{}".
       drPepper.set(2);
      Now drPepper.toString() returns "{2}".
       drPepper.set(4);
       drPepper.set(10);
      Now drPepper.toString() returns "{2, 4, 10}".
      Overrides:
      toString in class FixedSizeBitSet
      Returns:
      a string representation of this bit set.
    • iterator

      public Iterator<Long> iterator()
      Specified by:
      iterator in interface Iterable<Long>
    • index

      protected int index(long seqno)
    • seqno

      protected long seqno(int index)