Class ConcurrentOpenLongPairRangeSet<T extends java.lang.Comparable<T>>
- java.lang.Object
-
- org.apache.pulsar.common.util.collections.ConcurrentOpenLongPairRangeSet<T>
-
- All Implemented Interfaces:
LongPairRangeSet<T>
public class ConcurrentOpenLongPairRangeSet<T extends java.lang.Comparable<T>> extends java.lang.Object implements LongPairRangeSet<T>
A Concurrent set comprising zero or more ranges of typeLongPairRangeSet.LongPair. This can be alternative ofRangeSetand can be used ifrangetype isLongPairRangeSet.LongPairUsage: a. This can be used if one doesn't want to create object for every new inserted
rangeb. It createsBitSetfor every unique first-key of the range. So, this rangeSet is not suitable for large number of unique keys.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pulsar.common.util.collections.LongPairRangeSet
LongPairRangeSet.DefaultRangeSet<T extends java.lang.Comparable<T>>, LongPairRangeSet.LongPair, LongPairRangeSet.LongPairConsumer<T>, LongPairRangeSet.RangeProcessor<T extends java.lang.Comparable<T>>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.NavigableMap<java.lang.Long,java.util.BitSet>rangeBitSetMap
-
Constructor Summary
Constructors Constructor Description ConcurrentOpenLongPairRangeSet(int size, boolean threadSafe, LongPairRangeSet.LongPairConsumer<T> consumer)ConcurrentOpenLongPairRangeSet(int size, LongPairRangeSet.LongPairConsumer<T> consumer)ConcurrentOpenLongPairRangeSet(LongPairRangeSet.LongPairConsumer<T> consumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(com.google.common.collect.Range<LongPairRangeSet.LongPair> range)Adds the specified range to thisRangeSet(optional operation).voidaddOpenClosed(long lowerKey, long lowerValueOpen, long upperKey, long upperValue)Adds the specified range to thisRangeSet(optional operation).java.util.List<com.google.common.collect.Range<T>>asRanges()Returns a view of the disconnected ranges that make up this range set.intcardinality(long lowerKey, long lowerValue, long upperKey, long upperValue)Return the number bit sets to true from lower (inclusive) to upper (inclusive).voidclear()booleancontains(long key, long value)Determines whether any of this range set's member ranges containsvalue.booleancontains(LongPairRangeSet.LongPair position)com.google.common.collect.Range<T>firstRange()It returns very first smallest range in the rangeSet.voidforEach(LongPairRangeSet.RangeProcessor<T> action)Performs the given action for each entry in this map until all entries have been processed or action returns "false".voidforEach(LongPairRangeSet.RangeProcessor<T> action, LongPairRangeSet.LongPairConsumer<? extends T> consumer)Performs the given action for each entry in this map until all entries have been processed or action returns "false".booleanisEmpty()com.google.common.collect.Range<T>lastRange()It returns very last biggest range in the rangeSet.com.google.common.collect.Range<T>rangeContaining(long key, long value)Returns the unique range from this range set that containsvalue, ornullif this range set does not containvalue.voidremove(com.google.common.collect.Range<LongPairRangeSet.LongPair> range)voidremoveAtMost(long key, long value)Remove range that contains all values less than or equal to given key-value.intsize()Returns total number of ranges into the set.com.google.common.collect.Range<T>span()Returns the minimal range which encloses all ranges in this range set.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ConcurrentOpenLongPairRangeSet
public ConcurrentOpenLongPairRangeSet(LongPairRangeSet.LongPairConsumer<T> consumer)
-
ConcurrentOpenLongPairRangeSet
public ConcurrentOpenLongPairRangeSet(int size, LongPairRangeSet.LongPairConsumer<T> consumer)
-
ConcurrentOpenLongPairRangeSet
public ConcurrentOpenLongPairRangeSet(int size, boolean threadSafe, LongPairRangeSet.LongPairConsumer<T> consumer)
-
-
Method Detail
-
addOpenClosed
public void addOpenClosed(long lowerKey, long lowerValueOpen, long upperKey, long upperValue)Adds the specified range to thisRangeSet(optional operation). That is, for equal range sets a and b, the result ofa.add(range)is thatawill be the minimal range set for which botha.enclosesAll(b)anda.encloses(range).Note that
rangewill merge givenrangewith any ranges in the range set that are connected with it. Moreover, ifrangeis empty, this is a no-op.- Specified by:
addOpenClosedin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
contains
public boolean contains(long key, long value)Description copied from interface:LongPairRangeSetDetermines whether any of this range set's member ranges containsvalue.- Specified by:
containsin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
rangeContaining
public com.google.common.collect.Range<T> rangeContaining(long key, long value)
Description copied from interface:LongPairRangeSetReturns the unique range from this range set that containsvalue, ornullif this range set does not containvalue.- Specified by:
rangeContainingin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
removeAtMost
public void removeAtMost(long key, long value)Description copied from interface:LongPairRangeSetRemove range that contains all values less than or equal to given key-value.- Specified by:
removeAtMostin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
clear
public void clear()
- Specified by:
clearin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
span
public com.google.common.collect.Range<T> span()
Description copied from interface:LongPairRangeSetReturns the minimal range which encloses all ranges in this range set.- Specified by:
spanin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>- Returns:
-
asRanges
public java.util.List<com.google.common.collect.Range<T>> asRanges()
Description copied from interface:LongPairRangeSetReturns a view of the disconnected ranges that make up this range set.- Specified by:
asRangesin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>- Returns:
-
forEach
public void forEach(LongPairRangeSet.RangeProcessor<T> action)
Description copied from interface:LongPairRangeSetPerforms the given action for each entry in this map until all entries have been processed or action returns "false". Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.)- Specified by:
forEachin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
forEach
public void forEach(LongPairRangeSet.RangeProcessor<T> action, LongPairRangeSet.LongPairConsumer<? extends T> consumer)
Description copied from interface:LongPairRangeSetPerforms the given action for each entry in this map until all entries have been processed or action returns "false". Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.)- Specified by:
forEachin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
firstRange
public com.google.common.collect.Range<T> firstRange()
Description copied from interface:LongPairRangeSetIt returns very first smallest range in the rangeSet.- Specified by:
firstRangein interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>- Returns:
- first smallest range into the set
-
lastRange
public com.google.common.collect.Range<T> lastRange()
Description copied from interface:LongPairRangeSetIt returns very last biggest range in the rangeSet.- Specified by:
lastRangein interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>- Returns:
- last biggest range into the set
-
cardinality
public int cardinality(long lowerKey, long lowerValue, long upperKey, long upperValue)Description copied from interface:LongPairRangeSetReturn the number bit sets to true from lower (inclusive) to upper (inclusive).- Specified by:
cardinalityin interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>
-
size
public int size()
Description copied from interface:LongPairRangeSetReturns total number of ranges into the set.- Specified by:
sizein interfaceLongPairRangeSet<T extends java.lang.Comparable<T>>- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
add
public void add(com.google.common.collect.Range<LongPairRangeSet.LongPair> range)
Adds the specified range to thisRangeSet(optional operation). That is, for equal range sets a and b, the result ofa.add(range)is thatawill be the minimal range set for which botha.enclosesAll(b)anda.encloses(range).Note that
rangewill merge givenrangewith any ranges in the range set that are connected with it. Moreover, ifrangeis empty/invalid, this is a no-op.
-
contains
public boolean contains(LongPairRangeSet.LongPair position)
-
remove
public void remove(com.google.common.collect.Range<LongPairRangeSet.LongPair> range)
-
-