Class ConcurrentOpenLongPairRangeSet<T extends Comparable<T>>
java.lang.Object
org.apache.pulsar.common.util.collections.ConcurrentOpenLongPairRangeSet<T>
- All Implemented Interfaces:
LongPairRangeSet<T>
public class ConcurrentOpenLongPairRangeSet<T extends Comparable<T>>
extends Object
implements LongPairRangeSet<T>
A Concurrent set comprising zero or more ranges of type
LongPairRangeSet.LongPair
. This can be alternative of
RangeSet
and can be used if range
type is LongPairRangeSet.LongPair
Usage: a. This can be used if one doesn't want to create object for every new insertedrange
b. It createsBitSet
for 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 Comparable<T>>, LongPairRangeSet.LongPair, LongPairRangeSet.LongPairConsumer<T>, LongPairRangeSet.RangeBoundConsumer<T>, LongPairRangeSet.RangeProcessor<T extends Comparable<T>>, LongPairRangeSet.RawRangeProcessor
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConcurrentOpenLongPairRangeSet
(int size, boolean threadSafe, LongPairRangeSet.LongPairConsumer<T> consumer) ConcurrentOpenLongPairRangeSet
(int size, LongPairRangeSet.LongPairConsumer<T> consumer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(com.google.common.collect.Range<LongPairRangeSet.LongPair> range) Adds the specified range to thisRangeSet
(optional operation).void
addOpenClosed
(long lowerKey, long lowerValueOpen, long upperKey, long upperValue) Adds the specified range to thisRangeSet
(optional operation).asRanges()
Returns a view of the disconnected ranges that make up this range set.int
cardinality
(long lowerKey, long lowerValue, long upperKey, long upperValue) Return the number bit sets to true from lower (inclusive) to upper (inclusive).void
clear()
boolean
contains
(long key, long value) Determines whether any of this range set's member ranges containsvalue
.boolean
contains
(LongPairRangeSet.LongPair position) com.google.common.collect.Range<T>
It returns very first smallest range in the rangeSet.void
forEach
(LongPairRangeSet.RangeProcessor<T> action) Performs the given action for each entry in this map until all entries have been processed or action returns "false".void
forEach
(LongPairRangeSet.RangeProcessor<T> action, LongPairRangeSet.LongPairConsumer<? extends T> consumerParam) Performs the given action for each entry in this map until all entries have been processed or action returns "false".void
Performs the given action for each entry in this map until all entries have been processed or action returns "false".boolean
isEmpty()
com.google.common.collect.Range<T>
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
, ornull
if this range set does not containvalue
.void
remove
(com.google.common.collect.Range<LongPairRangeSet.LongPair> range) void
removeAtMost
(long key, long value) Remove range that contains all values less than or equal to given key-value.int
size()
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.toString()
-
Field Details
-
rangeBitSetMap
-
-
Constructor Details
-
ConcurrentOpenLongPairRangeSet
-
ConcurrentOpenLongPairRangeSet
-
ConcurrentOpenLongPairRangeSet
public ConcurrentOpenLongPairRangeSet(int size, boolean threadSafe, LongPairRangeSet.LongPairConsumer<T> consumer)
-
-
Method Details
-
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 thata
will be the minimal range set for which botha.enclosesAll(b)
anda.encloses(range)
.Note that
range
will merge givenrange
with any ranges in the range set that are connected with it. Moreover, ifrange
is empty, this is a no-op.- Specified by:
addOpenClosed
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
contains
public boolean contains(long key, long value) Description copied from interface:LongPairRangeSet
Determines whether any of this range set's member ranges containsvalue
.- Specified by:
contains
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
rangeContaining
Description copied from interface:LongPairRangeSet
Returns the unique range from this range set that containsvalue
, ornull
if this range set does not containvalue
.- Specified by:
rangeContaining
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
removeAtMost
public void removeAtMost(long key, long value) Description copied from interface:LongPairRangeSet
Remove range that contains all values less than or equal to given key-value.- Specified by:
removeAtMost
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
clear
public void clear()- Specified by:
clear
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
span
Description copied from interface:LongPairRangeSet
Returns the minimal range which encloses all ranges in this range set.- Specified by:
span
in interfaceLongPairRangeSet<T extends Comparable<T>>
- Returns:
-
asRanges
Description copied from interface:LongPairRangeSet
Returns a view of the disconnected ranges that make up this range set.- Specified by:
asRanges
in interfaceLongPairRangeSet<T extends Comparable<T>>
- Returns:
-
forEach
Description copied from interface:LongPairRangeSet
Performs 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:
forEach
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
forEach
public void forEach(LongPairRangeSet.RangeProcessor<T> action, LongPairRangeSet.LongPairConsumer<? extends T> consumerParam) Description copied from interface:LongPairRangeSet
Performs 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:
forEach
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
forEachRawRange
Description copied from interface:LongPairRangeSet
Performs 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.) This method is optimized on reducing intermediate object creation. to do iteration jobs.- Specified by:
forEachRawRange
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
firstRange
Description copied from interface:LongPairRangeSet
It returns very first smallest range in the rangeSet.- Specified by:
firstRange
in interfaceLongPairRangeSet<T extends Comparable<T>>
- Returns:
- first smallest range into the set
-
lastRange
Description copied from interface:LongPairRangeSet
It returns very last biggest range in the rangeSet.- Specified by:
lastRange
in interfaceLongPairRangeSet<T extends 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:LongPairRangeSet
Return the number bit sets to true from lower (inclusive) to upper (inclusive).- Specified by:
cardinality
in interfaceLongPairRangeSet<T extends Comparable<T>>
-
size
public int size()Description copied from interface:LongPairRangeSet
Returns total number of ranges into the set.- Specified by:
size
in interfaceLongPairRangeSet<T extends Comparable<T>>
- Returns:
-
toString
-
add
Adds the specified range to thisRangeSet
(optional operation). That is, for equal range sets a and b, the result ofa.add(range)
is thata
will be the minimal range set for which botha.enclosesAll(b)
anda.encloses(range)
.Note that
range
will merge givenrange
with any ranges in the range set that are connected with it. Moreover, ifrange
is empty/invalid, this is a no-op. -
contains
-
remove
-