Class SequenceSet
java.lang.Object
org.apache.activemq.store.kahadb.disk.util.LinkedNodeList<Sequence>
org.apache.activemq.store.kahadb.disk.util.SequenceSet
Keeps track of a added long values. Collapses ranges of numbers using a
Sequence representation. Use to keep track of received message ids to find
out if a message is duplicate or if there are any missing messages.
- Author:
- chirino
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long value) voidbooleancontains(int first, int last) booleancontains(long value) Returns true if the value given is contained within one of the sequences held in this set.get(int value) getMissing(long first, long last) iterator()voidmerge(SequenceSet sequenceSet) longComputes the size of this Sequence by summing the values of all the contained sequences.booleanremove(long value) Removes the given value from the Sequence set, splitting a contained sequence if necessary.voidvoidremove(SequenceSet sequenceSet) longRemoves and returns the first element from this list.removeFirstSequence(long count) Removes and returns the first sequence that is count range large.Removes and returns the last sequence from this list.Methods inherited from class org.apache.activemq.store.kahadb.disk.util.LinkedNodeList
addFirst, addFirst, addLast, addLast, clear, getHead, getTail, isEmpty, reparent, rotate, rotateTo, size, toArrayList, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SequenceSet
public SequenceSet()
-
-
Method Details
-
add
-
merge
-
remove
-
remove
-
add
public boolean add(long value) - Parameters:
value- the value to add to the list- Returns:
- false if the value was a duplicate.
-
remove
public boolean remove(long value) Removes the given value from the Sequence set, splitting a contained sequence if necessary.- Parameters:
value- The value that should be removed from the SequenceSet.- Returns:
- true if the value was removed from the set, false if there was no sequence in the set that contained the given value.
-
removeFirst
public long removeFirst()Removes and returns the first element from this list.- Returns:
- the first element from this list.
- Throws:
NoSuchElementException- if this list is empty.
-
removeLastSequence
Removes and returns the last sequence from this list.- Returns:
- the last sequence from this list or null if the list is empty.
-
removeFirstSequence
Removes and returns the first sequence that is count range large.- Returns:
- a sequence that is count range large, or null if no sequence is that large in the list.
-
getMissing
- Returns:
- all the id Sequences that are missing from this set that are not in between the range provided.
-
getReceived
- Returns:
- all the Sequence that are in this list
-
contains
public boolean contains(long value) Returns true if the value given is contained within one of the sequences held in this set.- Parameters:
value- The value to search for in the set.- Returns:
- true if the value is contained in the set.
-
contains
public boolean contains(int first, int last) -
get
-
rangeSize
public long rangeSize()Computes the size of this Sequence by summing the values of all the contained sequences.- Returns:
- the total number of values contained in this set if it were to be iterated over like an array.
-
iterator
-