Package org.roaringbitmap
Class RangeBitmap.Appender
- java.lang.Object
-
- org.roaringbitmap.RangeBitmap.Appender
-
- Enclosing class:
- RangeBitmap
public static final class RangeBitmap.Appender extends java.lang.Object
Builder for constructing immutable RangeBitmaps
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Consumer<java.nio.ByteBuffer>
bufferCleaner
private int
bufferPos
private java.util.function.IntFunction<java.nio.ByteBuffer>
bufferSupplier
private byte
bytesPerMask
private java.nio.ByteBuffer
containers
private boolean
dirty
private static int
GROWTH
private int
key
private long
mask
private java.nio.ByteBuffer
maskBuffer
private long
rangeMask
private int
rid
private int
serializedContainerSize
private Container[]
slice
-
Constructor Summary
Constructors Constructor Description Appender(long maxValue, java.util.function.IntFunction<java.nio.ByteBuffer> bufferSupplier, java.util.function.Consumer<java.nio.ByteBuffer> cleaner)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long value)
Adds the value and associates it with the current row index.private void
append()
RangeBitmap
build()
see build(IntFunction)RangeBitmap
build(java.nio.ByteBuffer buffer)
Converts the appender into an immutable range index, using the supplied ByteBuffer.RangeBitmap
build(java.util.function.IntFunction<java.nio.ByteBuffer> supplier)
Converts the appender into an immutable range index.private static byte
bytesPerMask(long maxValue)
void
clear()
Call this to reuse the appender and its buffersprivate Container
containerForSlice(int sliceNumber)
private int
containerGrowth()
private boolean
flush()
private java.nio.ByteBuffer
growBuffer(java.nio.ByteBuffer buffer, int growth)
private int
maskBufferGrowth()
private static long
rangeMask(long maxValue)
Produces a mask covering the smallest number of bytes required to represent the sliced max value.void
serialize(java.nio.ByteBuffer buffer)
Serializes the bitmap to the buffer without materialising it.int
serializedSizeInBytes()
Returns the size of the RangeBitmap on disk.
-
-
-
Field Detail
-
GROWTH
private static final int GROWTH
- See Also:
- Constant Field Values
-
bufferSupplier
private final java.util.function.IntFunction<java.nio.ByteBuffer> bufferSupplier
-
bufferCleaner
private final java.util.function.Consumer<java.nio.ByteBuffer> bufferCleaner
-
bytesPerMask
private final byte bytesPerMask
-
rangeMask
private final long rangeMask
-
slice
private final Container[] slice
-
maskBuffer
private java.nio.ByteBuffer maskBuffer
-
containers
private java.nio.ByteBuffer containers
-
bufferPos
private int bufferPos
-
mask
private long mask
-
rid
private int rid
-
key
private int key
-
serializedContainerSize
private int serializedContainerSize
-
dirty
private boolean dirty
-
-
Method Detail
-
build
public RangeBitmap build(java.util.function.IntFunction<java.nio.ByteBuffer> supplier)
Converts the appender into an immutable range index.- Parameters:
supplier
- provides an appropriate ByteBuffer to store into- Returns:
- a queriable RangeBitmap
-
build
public RangeBitmap build()
see build(IntFunction)
-
build
public RangeBitmap build(java.nio.ByteBuffer buffer)
Converts the appender into an immutable range index, using the supplied ByteBuffer.- Parameters:
buffer
- a little endian buffer which must have sufficient capacity for the appended values.- Returns:
- a queriable RangeBitmap
-
clear
public void clear()
Call this to reuse the appender and its buffers
-
serializedSizeInBytes
public int serializedSizeInBytes()
Returns the size of the RangeBitmap on disk.- Returns:
- the serialized size in bytes.
-
serialize
public void serialize(java.nio.ByteBuffer buffer)
Serializes the bitmap to the buffer without materialising it. The user should call serializedSizeInBytes to size the buffer appropriately.It is not guaranteed that all values will be written
- Parameters:
buffer
- expected to be large enough to contain the bitmap.
-
add
public void add(long value)
Adds the value and associates it with the current row index.- Parameters:
value
- the value, will be rejected if greater than max value.
-
flush
private boolean flush()
-
append
private void append()
-
maskBufferGrowth
private int maskBufferGrowth()
-
containerGrowth
private int containerGrowth()
-
growBuffer
private java.nio.ByteBuffer growBuffer(java.nio.ByteBuffer buffer, int growth)
-
containerForSlice
private Container containerForSlice(int sliceNumber)
-
rangeMask
private static long rangeMask(long maxValue)
Produces a mask covering the smallest number of bytes required to represent the sliced max value.- Parameters:
maxValue
- the maximum value this bitmap should support.- Returns:
- a mask with a multiple of 8 contiguous bits set.
-
bytesPerMask
private static byte bytesPerMask(long maxValue)
-
-