Package org.roaringbitmap
Class BitSetUtil
java.lang.Object
org.roaringbitmap.BitSetUtil
This class provides convenience functions to manipulate BitSet and RoaringBitmap objects.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic char[]
arrayContainerBufferOf
(int from, int to, int cardinality, long[] words) Creates array container's content char buffer.static RoaringBitmap
bitmapOf
(long[] words) Generate a RoaringBitmap out of a long[], each long using little-endian representation of its bitsstatic RoaringBitmap
bitmapOf
(ByteBuffer bb, boolean fastRank) Efficiently generate a RoaringBitmap from an uncompressed byte array or ByteBuffer This method tries to minimise all kinds of memory allocationstatic RoaringBitmap
bitmapOf
(ByteBuffer bb, boolean fastRank, long[] wordsBuffer) Efficiently generate a RoaringBitmap from an uncompressed byte array or ByteBuffer This method tries to minimise all kinds of memory allocation
You can provide a cached wordsBuffer for avoiding 8 KB of extra allocation on every call No reference is kept to the wordsBuffer, so it can be cached as a ThreadLocalstatic RoaringBitmap
Generate a RoaringBitmap out of a BitSetstatic BitSet
bitsetOf
(RoaringBitmap bitmap) Convert aRoaringBitmap
to aBitSet
.static BitSet
bitsetOfWithoutCopy
(RoaringBitmap bitmap) Convert aRoaringBitmap
to aBitSet
without copying to an intermediate array.static boolean
equals
(BitSet bitset, RoaringBitmap bitmap) Compares a RoaringBitmap and a BitSet.static byte[]
toByteArray
(RoaringBitmap bitmap) Returns an array of little-endian ordered bytes, given aRoaringBitmap
.static long[]
toLongArray
(RoaringBitmap bitmap) Returns an array of long, given aRoaringBitmap
.
-
Field Details
-
BLOCK_LENGTH
public static final int BLOCK_LENGTH- See Also:
-
-
Constructor Details
-
BitSetUtil
public BitSetUtil()
-
-
Method Details
-
bitsetOf
Convert aRoaringBitmap
to aBitSet
.Equivalent to calling
BitSet.valueOf(BitSetUtil.toLongArray(bitmap))
. -
bitsetOfWithoutCopy
Convert aRoaringBitmap
to aBitSet
without copying to an intermediate array. -
toByteArray
Returns an array of little-endian ordered bytes, given aRoaringBitmap
.See
BitSet.toByteArray()
. -
toLongArray
Returns an array of long, given aRoaringBitmap
.See
BitSet.toLongArray()
. -
arrayContainerBufferOf
public static char[] arrayContainerBufferOf(int from, int to, int cardinality, long[] words) Creates array container's content char buffer.- Parameters:
from
- first value of the rangeto
- last value of the rangecardinality
- new buffer cardinality, expected to be less than 4096 and more than present values in given bitmapwords
- bitmap- Returns:
- array container's content char buffer
-
bitmapOf
Generate a RoaringBitmap out of a BitSet- Parameters:
bitSet
- original bitset (will not be modified)- Returns:
- roaring bitmap equivalent to BitSet
-
bitmapOf
Generate a RoaringBitmap out of a long[], each long using little-endian representation of its bits- Parameters:
words
- array of longs (will not be modified)- Returns:
- roaring bitmap
- See Also:
-
bitmapOf
Efficiently generate a RoaringBitmap from an uncompressed byte array or ByteBuffer This method tries to minimise all kinds of memory allocation- Parameters:
bb
- the uncompressed bitmapfastRank
- if set, returned bitmap is of typeFastRankRoaringBitmap
- Returns:
- roaring bitmap
-
bitmapOf
Efficiently generate a RoaringBitmap from an uncompressed byte array or ByteBuffer This method tries to minimise all kinds of memory allocation
You can provide a cached wordsBuffer for avoiding 8 KB of extra allocation on every call No reference is kept to the wordsBuffer, so it can be cached as a ThreadLocal- Parameters:
bb
- the uncompressed bitmapfastRank
- if set, returned bitmap is of typeFastRankRoaringBitmap
wordsBuffer
- buffer of lengthBLOCK_LENGTH
- Returns:
- roaring bitmap
-
equals
Compares a RoaringBitmap and a BitSet. They are equal if and only if they contain the same set of integers.- Parameters:
bitset
- first object to be comparedbitmap
- second object to be compared- Returns:
- whether they are equals
-