java.lang.Object
org.bitlap.roaringbitmap.buffer.BufferUtil
Various useful methods for roaring bitmaps.
This class is similar to org.bitlap.roaringbitmap.Util but meant to be used with memory mapping.
-
方法概要
修饰符和类型方法说明static MappeableContainer[]addOffset(MappeableContainer source, char offsets) Add value "offset" to all values in the container, producing two new containers.protected static intadvanceUntil(CharBuffer array, int pos, int length, char min) Find the smallest integer larger than pos such that array[pos]>= min.protected static voidarraycopy(CharBuffer src, int srcPos, CharBuffer dest, int destPos, int length) protected static intbranchyUnsignedBinarySearch(ByteBuffer array, int position, int begin, int end, char k) protected static intbranchyUnsignedBinarySearch(CharBuffer array, int begin, int end, char k) static intcardinalityInBitmapRange(LongBuffer bitmap, int start, int end) Hamming weight of the bitset in the range start, start+1,..., end-1protected static voidfillArrayAND(char[] container, LongBuffer bitmap1, LongBuffer bitmap2) protected static voidfillArrayANDNOT(char[] container, LongBuffer bitmap1, LongBuffer bitmap2) protected static voidfillArrayXOR(char[] container, LongBuffer bitmap1, LongBuffer bitmap2) static voidflipBitmapRange(LongBuffer bitmap, int start, int end) flip bits at start, start+1,..., end-1static intflipBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。protected static intgetSizeInBytesFromCardinalityEtc(int card, int numRuns, boolean isRunEncoded) From the cardinality of a container, compute the corresponding size in bytes of the container.protected static charhighbits(int x) protected static charhighbits(long x) static intintersectArrayIntoBitmap(long[] bitmap, CharBuffer array, int length) Intersects the bitmap with the array, returning the cardinality of the resultstatic intintersectArrayIntoBitmap(LongBuffer bitmap, CharBuffer array, int length) Intersects the bitmap with the array, returning the cardinality of the resultprotected static booleanChecks whether the Buffer is backed by a simple array.static intiterateUntil(CharBuffer array, int pos, int length, int min) Find the smallest integer larger than pos such that array[pos]>= min.protected static charlowbits(int x) protected static charlowbits(long x) protected static intlowbitsAsInteger(long x) protected static charprotected static intstatic voidresetBitmapRange(LongBuffer bitmap, int start, int end) clear bits at start, start+1,..., end-1static intresetBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。static voidsetBitmapRange(LongBuffer bitmap, int start, int end) set bits at start, start+1,..., end-1static intsetBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。static intunsignedBinarySearch(ByteBuffer array, int position, int begin, int end, char k) Look for value k in buffer in the range [begin,end).static intunsignedBinarySearch(CharBuffer array, int begin, int end, char k) Look for value k in buffer in the range [begin,end).protected static intunsignedDifference(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) protected static intunsignedExclusiveUnion2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) protected static intunsignedIntersect2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) static booleanunsignedIntersects(CharBuffer set1, int length1, CharBuffer set2, int length2) Checks if two arrays intersectprotected static intunsignedLocalIntersect2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) protected static intunsignedLocalIntersect2by2Cardinality(CharBuffer set1, int length1, CharBuffer set2, int length2) protected static intunsignedOneSidedGallopingIntersect2by2(CharBuffer smallSet, int smallLength, CharBuffer largeSet, int largeLength, char[] buffer) protected static intunsignedUnion2by2(CharBuffer set1, int offset1, int length1, CharBuffer set2, int offset2, int length2, char[] buffer)
-
方法详细资料
-
addOffset
Add value "offset" to all values in the container, producing two new containers. The existing container remains unchanged. The new container are not converted, so they need to be checked: e.g., we could produce two bitmap containers having low cardinality.- 参数:
source- source containeroffsets- value to add to each value in the container- 返回:
- return an array made of two containers
-
advanceUntil
Find the smallest integer larger than pos such that array[pos]>= min. If none can be found, return length. Based on code by O. Kaser.- 参数:
array- container where we searchpos- initial positionmin- minimal thresholdlength- how big should the array consider to be- 返回:
- x greater than pos such that array[pos] is at least as large as min, pos is is equal to length if it is not possible.
-
iterateUntil
Find the smallest integer larger than pos such that array[pos]>= min. If none can be found, return length.- 参数:
array- array to search withinpos- starting position of the searchlength- length of the array to searchmin- minimum value- 返回:
- x greater than pos such that array[pos] is at least as large as min, pos is is equal to length if it is not possible.
-
arraycopy
protected static void arraycopy(CharBuffer src, int srcPos, CharBuffer dest, int destPos, int length) -
branchyUnsignedBinarySearch
-
branchyUnsignedBinarySearch
protected static int branchyUnsignedBinarySearch(ByteBuffer array, int position, int begin, int end, char k) -
fillArrayAND
-
fillArrayANDNOT
-
fillArrayXOR
-
flipBitmapRange
flip bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
cardinalityInBitmapRange
Hamming weight of the bitset in the range start, start+1,..., end-1- 参数:
bitmap- array of words representing a bitsetstart- first index (inclusive)end- last index (exclusive)- 返回:
- the hamming weight of the corresponding range
-
setBitmapRangeAndCardinalityChange
@Deprecated public static int setBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。set bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
flipBitmapRangeAndCardinalityChange
@Deprecated public static int flipBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。flip bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
resetBitmapRangeAndCardinalityChange
@Deprecated public static int resetBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) 已过时。reset bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
getSizeInBytesFromCardinalityEtc
protected static int getSizeInBytesFromCardinalityEtc(int card, int numRuns, boolean isRunEncoded) From the cardinality of a container, compute the corresponding size in bytes of the container. Additional information is required if the container is run encoded.- 参数:
card- the cardinality if this is not run encoded, otherwise ignorednumRuns- number of runs if run encoded, othewise ignoredisRunEncoded- boolean- 返回:
- the size in bytes
-
highbits
protected static char highbits(int x) -
highbits
protected static char highbits(long x) -
isBackedBySimpleArray
Checks whether the Buffer is backed by a simple array. In java, a Buffer is an abstraction that can represent various data, from data on disk all the way to native Java arrays. Like all abstractions, a Buffer might carry a performance penalty. Thus, we sometimes check whether the Buffer is simply a wrapper around a Java array. In these instances, it might be best, from a performance point of view, to access the underlying array (using the array()) method.- 参数:
b- the provided Buffer- 返回:
- whether the Buffer is backed by a simple array
-
lowbits
protected static char lowbits(int x) -
lowbits
protected static char lowbits(long x) -
lowbitsAsInteger
protected static int lowbitsAsInteger(long x) -
maxLowBit
protected static char maxLowBit() -
maxLowBitAsInteger
protected static int maxLowBitAsInteger() -
resetBitmapRange
clear bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
setBitmapRange
set bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
unsignedBinarySearch
Look for value k in buffer in the range [begin,end). If the value is found, return its index. If not, return -(i+1) where i is the index where the value would be inserted. The buffer is assumed to contain sorted values where chars are interpreted as unsigned integers.- 参数:
array- buffer where we searchbegin- first index (inclusive)end- last index (exclusive)k- value we search for- 返回:
- count
-
unsignedBinarySearch
Look for value k in buffer in the range [begin,end). If the value is found, return its index. If not, return -(i+1) where i is the index where the value would be inserted. The buffer is assumed to contain sorted values where chars are interpreted as unsigned integers.- 参数:
array- buffer where we searchposition- starting position of the container in the ByteBufferbegin- first index (inclusive)end- last index (exclusive)k- value we search for- 返回:
- count
-
unsignedDifference
protected static int unsignedDifference(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) -
intersectArrayIntoBitmap
Intersects the bitmap with the array, returning the cardinality of the result- 参数:
bitmap- the bitmap, modifiedarray- the array, not modifiedlength- how much of the array to consume- 返回:
- the size of the intersection, i.e. how many bits still set in the bitmap
-
intersectArrayIntoBitmap
Intersects the bitmap with the array, returning the cardinality of the result- 参数:
bitmap- the bitmap, modifiedarray- the array, not modifiedlength- how much of the array to consume- 返回:
- the size of the intersection, i.e. how many bits still set in the bitmap
-
unsignedExclusiveUnion2by2
protected static int unsignedExclusiveUnion2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) -
unsignedIntersect2by2
protected static int unsignedIntersect2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) -
unsignedIntersects
public static boolean unsignedIntersects(CharBuffer set1, int length1, CharBuffer set2, int length2) Checks if two arrays intersect- 参数:
set1- first arraylength1- length of first arrayset2- second arraylength2- length of second array- 返回:
- true if they intersect
-
unsignedLocalIntersect2by2
protected static int unsignedLocalIntersect2by2(CharBuffer set1, int length1, CharBuffer set2, int length2, char[] buffer) -
unsignedLocalIntersect2by2Cardinality
protected static int unsignedLocalIntersect2by2Cardinality(CharBuffer set1, int length1, CharBuffer set2, int length2) -
unsignedOneSidedGallopingIntersect2by2
protected static int unsignedOneSidedGallopingIntersect2by2(CharBuffer smallSet, int smallLength, CharBuffer largeSet, int largeLength, char[] buffer) -
unsignedUnion2by2
protected static int unsignedUnion2by2(CharBuffer set1, int offset1, int length1, CharBuffer set2, int offset2, int length2, char[] buffer)
-