public class ImmutableRoaringBitmap extends java.lang.Object implements java.lang.Iterable<java.lang.Integer>, java.lang.Cloneable, ImmutableBitmapDataProvider
import org.roaringbitmap.buffer.*;
//...
MutableRoaringBitmap rr1 = MutableRoaringBitmap.bitmapOf(1, 2, 3, 1000);
MutableRoaringBitmap rr2 = MutableRoaringBitmap.bitmapOf(2, 3, 1010);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
// could call "rr1.runOptimize()" and "rr2.runOptimize" if
// there were runs to compress
rr1.serialize(dos);
rr2.serialize(dos);
dos.close();
ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray());
ImmutableRoaringBitmap rrback1 = new ImmutableRoaringBitmap(bb);
bb.position(bb.position() + rrback1.serializedSizeInBytes());
ImmutableRoaringBitmap rrback2 = new ImmutableRoaringBitmap(bb);
MutableRoaringBitmapImmutableBitmapDataProvider.RoaringOfInt| 限定符 | 构造器和说明 |
|---|---|
protected |
ImmutableRoaringBitmap() |
|
ImmutableRoaringBitmap(java.nio.ByteBuffer b)
Constructs a new ImmutableRoaringBitmap starting at this ByteBuffer's position().
|
| 限定符和类型 | 方法和说明 |
|---|---|
static MutableRoaringBitmap |
and(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Bitwise AND (intersection) operation.
|
static MutableRoaringBitmap |
and(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
int rangeStart,
int rangeEnd)
已过时。
use the version where longs specify the range. Negative range end are illegal.
|
static MutableRoaringBitmap |
and(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
long rangeStart,
long rangeEnd)
Computes AND between input bitmaps in the given range, from rangeStart (inclusive) to rangeEnd
(exclusive)
|
static int |
andCardinality(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Cardinality of Bitwise AND (intersection) operation.
|
static MutableRoaringBitmap |
andNot(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Bitwise ANDNOT (difference) operation.
|
static MutableRoaringBitmap |
andNot(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2,
int rangeStart,
int rangeEnd)
已过时。
use the version where longs specify the range. Negative values for range
endpoints are not allowed.
|
static MutableRoaringBitmap |
andNot(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2,
long rangeStart,
long rangeEnd)
Bitwise ANDNOT (difference) operation for the given range, rangeStart (inclusive) and rangeEnd
(exclusive).
|
static int |
andNotCardinality(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Cardinality of the bitwise ANDNOT (left difference) operation.
|
static ImmutableRoaringBitmap |
bitmapOf(int... data)
Generate a bitmap with the specified values set to true.
|
boolean |
cardinalityExceeds(long threshold)
Returns true if the bitmap's cardinality exceeds the threshold.
|
ImmutableRoaringBitmap |
clone() |
boolean |
contains(ImmutableRoaringBitmap subset)
Checks whether the parameter is a subset of this RoaringBitmap or not
|
boolean |
contains(int x)
Checks whether the value in included, which is equivalent to checking if the corresponding bit
is set (get in BitSet class).
|
boolean |
contains(long minimum,
long supremum)
Checks if the bitmap contains the range.
|
boolean |
equals(java.lang.Object o) |
int |
first()
Get the first (smallest) integer in this RoaringBitmap,
that is, returns the minimum of the set.
|
static MutableRoaringBitmap |
flip(ImmutableRoaringBitmap bm,
int rangeStart,
int rangeEnd)
已过时。
use the version where longs specify the range
|
static MutableRoaringBitmap |
flip(ImmutableRoaringBitmap bm,
long rangeStart,
long rangeEnd)
Complements the bits in the given range, from rangeStart (inclusive) rangeEnd (exclusive).
|
void |
forEach(IntConsumer ic)
Visit all values in the bitmap and pass them to the consumer
|
BatchIterator |
getBatchIterator()
This iterator may be faster than others
|
int |
getCardinality()
Returns the number of distinct integers added to the bitmap (e.g., number of bits set).
|
MappeableContainerPointer |
getContainerPointer()
Return a low-level container pointer that can be used to access the underlying data structure.
|
PeekableIntIterator |
getIntIterator()
For better performance, consider the Use the
forEach method. |
long |
getLongCardinality()
Returns the number of distinct integers added to the bitmap (e.g., number of bits set).
|
long |
getLongSizeInBytes()
Estimate of the memory usage of this data structure.
|
IntIterator |
getReverseIntIterator() |
int |
getSizeInBytes()
Estimate of the memory usage of this data structure.
|
int |
hashCode()
Compute the hashCode() of this bitmap.
|
boolean |
hasRunCompression()
Check whether this bitmap has had its runs compressed.
|
static boolean |
intersects(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Checks whether the two bitmaps intersect.
|
boolean |
intersects(long minimum,
long supremum)
Checks if the range intersects with the bitmap.
|
boolean |
isEmpty()
Checks whether the bitmap is empty.
|
boolean |
isHammingSimilar(ImmutableRoaringBitmap other,
int tolerance)
Returns true if the other bitmap has no more than tolerance bits
differing from this bitmap.
|
java.util.Iterator<java.lang.Integer> |
iterator()
iterate over the positions of the true values.
|
int |
last()
Get the last (largest) integer in this RoaringBitmap,
that is, returns the maximum of the set.
|
protected static MutableRoaringBitmap |
lazyor(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2) |
MutableRoaringBitmap |
limit(int maxcardinality)
Create a new Roaring bitmap containing at most maxcardinality integers.
|
long |
nextAbsentValue(int fromValue)
Returns the first absent value equal to or larger than the provided
value (interpreted as an unsigned integer).
|
long |
nextValue(int fromValue)
Returns the first value equal to or larger than the provided value
(interpreted as an unsigned integer).
|
static MutableRoaringBitmap |
or(ImmutableRoaringBitmap... bitmaps)
Compute overall OR between bitmaps.
|
static MutableRoaringBitmap |
or(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Bitwise OR (union) operation.
|
static MutableRoaringBitmap |
or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps)
Compute overall OR between bitmaps.
|
static MutableRoaringBitmap |
or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
int rangeStart,
int rangeEnd)
已过时。
use the version where longs specify the range.
Negative range points are forbidden.
|
static MutableRoaringBitmap |
or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
long rangeStart,
long rangeEnd)
Computes OR between input bitmaps in the given range, from rangeStart (inclusive) to rangeEnd
(exclusive)
|
static int |
orCardinality(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Cardinality of the bitwise OR (union) operation.
|
static MutableRoaringBitmap |
orNot(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2,
long rangeEnd)
Bitwise ORNOT operation for the given range, rangeStart (inclusive) and rangeEnd
(exclusive).
|
long |
previousAbsentValue(int fromValue)
Returns the first absent value less than or equal to the provided
value (interpreted as an unsigned integer).
|
long |
previousValue(int fromValue)
Returns the first value less than or equal to the provided value
(interpreted as an unsigned integer).
|
long |
rangeCardinality(long start,
long end)
Computes the number of values in the interval [start,end) where
start is included and end excluded.
|
int |
rank(int x)
Rank returns the number of integers that are smaller or equal to x (rank(infinity) would be
getCardinality()).
|
long |
rankLong(int x)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be
GetCardinality()).
|
int |
select(int j)
Return the jth value stored in this bitmap.
|
void |
serialize(java.nio.ByteBuffer buffer)
Serialize this bitmap to a ByteBuffer.
|
void |
serialize(java.io.DataOutput out)
Serialize this bitmap.
|
int |
serializedSizeInBytes()
Report the number of bytes required for serialization.
|
int[] |
toArray()
Return the set values as an array if the cardinality is less
than 2147483648.
|
MutableRoaringBitmap |
toMutableRoaringBitmap()
Copies the content of this bitmap to a bitmap that can be modified.
|
RoaringBitmap |
toRoaringBitmap()
Copies this bitmap to a mutable RoaringBitmap.
|
java.lang.String |
toString()
A string describing the bitmap.
|
static MutableRoaringBitmap |
xor(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Bitwise XOR (symmetric difference) operation.
|
static MutableRoaringBitmap |
xor(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
int rangeStart,
int rangeEnd)
已过时。
use the version where longs specify the range.
Negative values not allowed for rangeStart and rangeEnd
|
static MutableRoaringBitmap |
xor(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps,
long rangeStart,
long rangeEnd)
Computes XOR between input bitmaps in the given range, from rangeStart (inclusive) to rangeEnd
(exclusive)
|
static int |
xorCardinality(ImmutableRoaringBitmap x1,
ImmutableRoaringBitmap x2)
Cardinality of the bitwise XOR (symmetric difference) operation.
|
reverseStream, streamprotected ImmutableRoaringBitmap()
public ImmutableRoaringBitmap(java.nio.ByteBuffer b)
b - data sourcepublic static MutableRoaringBitmap and(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, long rangeStart, long rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of range@Deprecated public static MutableRoaringBitmap and(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, int rangeStart, int rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of rangepublic static MutableRoaringBitmap and(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapBufferFastAggregation.and(ImmutableRoaringBitmap...)public static int andCardinality(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapBufferFastAggregation.and(ImmutableRoaringBitmap...)public static int xorCardinality(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmappublic static int andNotCardinality(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmappublic static MutableRoaringBitmap andNot(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2, long rangeStart, long rangeEnd)
x1 - first bitmapx2 - other bitmaprangeStart - beginning of the range (inclusive)rangeEnd - end of range (exclusive)@Deprecated public static MutableRoaringBitmap andNot(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2, int rangeStart, int rangeEnd)
x1 - first bitmapx2 - other bitmaprangeStart - beginning of the range (inclusive)rangeEnd - end of range (exclusive)public static MutableRoaringBitmap andNot(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmappublic static MutableRoaringBitmap orNot(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2, long rangeEnd)
x1 - first bitmapx2 - other bitmaprangeEnd - end point of the range (exclusive)public static ImmutableRoaringBitmap bitmapOf(int... data)
(ImmutableRoaringBitmap) MutableRoaringBitmap.bitmapOf(data)
data - set valuespublic static MutableRoaringBitmap flip(ImmutableRoaringBitmap bm, long rangeStart, long rangeEnd)
bm - bitmap being negatedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of range@Deprecated public static MutableRoaringBitmap flip(ImmutableRoaringBitmap bm, int rangeStart, int rangeEnd)
bm - bitmap being negatedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of rangepublic static boolean intersects(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapprotected static MutableRoaringBitmap lazyor(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps)
BufferFastAggregation.or(org.bitlap.roaringbitmap.buffer.ImmutableRoaringBitmap...))bitmaps - input bitmapspublic static MutableRoaringBitmap or(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapBufferFastAggregation.or(ImmutableRoaringBitmap...),
BufferFastAggregation.horizontal_or(ImmutableRoaringBitmap...)public static MutableRoaringBitmap or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps)
BufferFastAggregation.or(org.bitlap.roaringbitmap.buffer.ImmutableRoaringBitmap...))bitmaps - input bitmapspublic static MutableRoaringBitmap or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, long rangeStart, long rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of range@Deprecated public static MutableRoaringBitmap or(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, int rangeStart, int rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of rangepublic static int orCardinality(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapBufferFastAggregation.or(ImmutableRoaringBitmap...),
BufferFastAggregation.horizontal_or(ImmutableRoaringBitmap...)public static MutableRoaringBitmap xor(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, long rangeStart, long rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of range@Deprecated public static MutableRoaringBitmap xor(java.util.Iterator<? extends ImmutableRoaringBitmap> bitmaps, int rangeStart, int rangeEnd)
bitmaps - input bitmaps, these are not modifiedrangeStart - inclusive beginning of rangerangeEnd - exclusive ending of rangepublic static MutableRoaringBitmap xor(ImmutableRoaringBitmap x1, ImmutableRoaringBitmap x2)
x1 - first bitmapx2 - other bitmapBufferFastAggregation.xor(ImmutableRoaringBitmap...),
BufferFastAggregation.horizontal_xor(ImmutableRoaringBitmap...)public ImmutableRoaringBitmap clone()
clone 在类中 java.lang.Objectpublic boolean contains(int x)
contains 在接口中 ImmutableBitmapDataProviderx - integer valuepublic boolean contains(long minimum,
long supremum)
minimum - the inclusive lower bound of the rangesupremum - the exclusive upper bound of the rangepublic boolean contains(ImmutableRoaringBitmap subset)
subset - the potential subsetpublic boolean equals(java.lang.Object o)
equals 在类中 java.lang.Objectpublic boolean isHammingSimilar(ImmutableRoaringBitmap other, int tolerance)
other - the bitmap to compare totolerance - the maximum number of bits that may differpublic boolean intersects(long minimum,
long supremum)
minimum - the inclusive unsigned lower bound of the rangesupremum - the exclusive unsigned upper bound of the rangepublic long getLongCardinality()
getLongCardinality 在接口中 ImmutableBitmapDataProviderpublic int getCardinality()
ImmutableBitmapDataProvidergetCardinality 在接口中 ImmutableBitmapDataProviderpublic boolean cardinalityExceeds(long threshold)
threshold - thresholdpublic void forEach(IntConsumer ic)
ImmutableBitmapDataProvider
bitmap.forEach(new IntConsumer() {
{@literal @}Override
public void accept(int value) {
// do something here
}});
}
forEach 在接口中 ImmutableBitmapDataProvideric - the consumerpublic MappeableContainerPointer getContainerPointer()
public PeekableIntIterator getIntIterator()
forEach method.getIntIterator 在接口中 ImmutableBitmapDataProviderpublic IntIterator getReverseIntIterator()
getReverseIntIterator 在接口中 ImmutableBitmapDataProviderpublic BatchIterator getBatchIterator()
ImmutableBitmapDataProvidergetBatchIterator 在接口中 ImmutableBitmapDataProviderpublic long getLongSizeInBytes()
getLongSizeInBytes 在接口中 ImmutableBitmapDataProviderpublic int getSizeInBytes()
getSizeInBytes 在接口中 ImmutableBitmapDataProviderpublic int hashCode()
hashCode 在类中 java.lang.Objectpublic boolean hasRunCompression()
public boolean isEmpty()
isEmpty 在接口中 ImmutableBitmapDataProviderpublic java.util.Iterator<java.lang.Integer> iterator()
iterator 在接口中 java.lang.Iterable<java.lang.Integer>public MutableRoaringBitmap limit(int maxcardinality)
limit 在接口中 ImmutableBitmapDataProvidermaxcardinality - maximal cardinalitypublic long rankLong(int x)
rankLong 在接口中 ImmutableBitmapDataProviderx - upper limitpublic long rangeCardinality(long start,
long end)
ImmutableBitmapDataProviderrangeCardinality 在接口中 ImmutableBitmapDataProviderstart - lower limit (included)end - upper limit (excluded)public int rank(int x)
ImmutableBitmapDataProviderrank 在接口中 ImmutableBitmapDataProviderx - upper limitpublic int select(int j)
select 在接口中 ImmutableBitmapDataProviderj - index of the valuepublic int first()
first 在接口中 ImmutableBitmapDataProviderjava.util.NoSuchElementException - if emptypublic int last()
last 在接口中 ImmutableBitmapDataProviderjava.util.NoSuchElementException - if emptypublic long nextValue(int fromValue)
ImmutableBitmapDataProvider-1 is returned. It is not necessarily a
computationally effective way to iterate through the values.nextValue 在接口中 ImmutableBitmapDataProviderfromValue - the lower bound (inclusive)-1 if there is no such valuepublic long previousValue(int fromValue)
ImmutableBitmapDataProvider-1 is returned. It is not an efficient
way to iterate through the values backwards.previousValue 在接口中 ImmutableBitmapDataProviderfromValue - the upper bound (inclusive)-1 if there is no such valuepublic long nextAbsentValue(int fromValue)
ImmutableBitmapDataProvidernextAbsentValue 在接口中 ImmutableBitmapDataProviderfromValue - the lower bound (inclusive)public long previousAbsentValue(int fromValue)
ImmutableBitmapDataProviderpreviousAbsentValue 在接口中 ImmutableBitmapDataProviderfromValue - the lower bound (inclusive)public void serialize(java.io.DataOutput out)
throws java.io.IOException
MutableRoaringBitmap.runOptimize() before serialization to improve
compression if this is a MutableRoaringBitmap instance.
The current bitmap is not modified.
There is a distinct and dedicated method to serialize to a ByteBuffer.
Note: Java's data structures are in big endian format. Roaring serializes to a little endian
format, so the bytes are flipped by the library during serialization to ensure that what is
stored is in little endian---despite Java's big endianness. You can defeat this process by
reflipping the bytes again in a custom DataOutput which could lead to serialized Roaring
objects with an incorrect byte order.serialize 在接口中 ImmutableBitmapDataProviderout - the DataOutput streamjava.io.IOException - Signals that an I/O exception has occurred.public void serialize(java.nio.ByteBuffer buffer)
ImmutableBitmapDataProvider
byte[] array = new byte[mrb.serializedSizeInBytes()];
mrb.serialize(ByteBuffer.wrap(array));
serialize 在接口中 ImmutableBitmapDataProviderbuffer - the ByteBufferpublic int serializedSizeInBytes()
serializedSizeInBytes 在接口中 ImmutableBitmapDataProviderpublic int[] toArray()
toArray 在接口中 ImmutableBitmapDataProviderpublic MutableRoaringBitmap toMutableRoaringBitmap()
public RoaringBitmap toRoaringBitmap()
public java.lang.String toString()
toString 在类中 java.lang.Object