Package org.roaringbitmap
Class BitSetUtil
- java.lang.Object
-
- org.roaringbitmap.BitSetUtil
-
public class BitSetUtil extends java.lang.Object
This class provides convenience functions to manipulate BitSet and RoaringBitmap objects.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BLOCK_LENGTH
-
Constructor Summary
Constructors Constructor Description BitSetUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static ArrayContainer
arrayContainerOf(int from, int to, int cardinality, long[] words)
static RoaringBitmap
bitmapOf(long[] words)
Generate a RoaringBitmap out of a long[], each long using little-endian representation of its bitsstatic RoaringBitmap
bitmapOf(java.nio.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(java.nio.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
bitmapOf(java.util.BitSet bitSet)
Generate a RoaringBitmap out of a BitSetprivate static int
cardinality(int from, int to, long[] words)
private static Container
containerOf(int from, int to, int blockCardinality, long[] words)
static boolean
equals(java.util.BitSet bitset, RoaringBitmap bitmap)
Compares a RoaringBitmap and a BitSet.
-
-
-
Field Detail
-
BLOCK_LENGTH
public static final int BLOCK_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
arrayContainerOf
private static ArrayContainer arrayContainerOf(int from, int to, int cardinality, long[] words)
-
bitmapOf
public static RoaringBitmap bitmapOf(java.util.BitSet bitSet)
Generate a RoaringBitmap out of a BitSet- Parameters:
bitSet
- original bitset (will not be modified)- Returns:
- roaring bitmap equivalent to BitSet
-
bitmapOf
public static RoaringBitmap bitmapOf(long[] words)
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:
for an equivalent
-
bitmapOf
public static RoaringBitmap bitmapOf(java.nio.ByteBuffer bb, boolean fastRank)
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
public static RoaringBitmap bitmapOf(java.nio.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 ThreadLocal- Parameters:
bb
- the uncompressed bitmapfastRank
- if set, returned bitmap is of typeFastRankRoaringBitmap
wordsBuffer
- buffer of lengthBLOCK_LENGTH
- Returns:
- roaring bitmap
-
cardinality
private static int cardinality(int from, int to, long[] words)
-
containerOf
private static Container containerOf(int from, int to, int blockCardinality, long[] words)
-
equals
public static boolean equals(java.util.BitSet bitset, RoaringBitmap bitmap)
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
-
-