Package org.roaringbitmap
Class RangeBitmap.Appender
java.lang.Object
org.roaringbitmap.RangeBitmap.Appender
- Enclosing class:
RangeBitmap
Builder for constructing immutable RangeBitmaps
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Consumer
<ByteBuffer> private int
private final IntFunction
<ByteBuffer> private final byte
private ByteBuffer
private boolean
private static final int
private int
private long
private ByteBuffer
private final long
private int
private int
private final Container[]
-
Constructor Summary
ConstructorsConstructorDescriptionAppender
(long maxValue, IntFunction<ByteBuffer> bufferSupplier, Consumer<ByteBuffer> cleaner) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long value) Adds the value and associates it with the current row index.private void
append()
build()
see build(IntFunction)build
(ByteBuffer buffer) Converts the appender into an immutable range index, using the supplied ByteBuffer.build
(IntFunction<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
private boolean
flush()
private ByteBuffer
growBuffer
(ByteBuffer buffer, int growth) private int
private static long
rangeMask
(long maxValue) Produces a mask covering the smallest number of bytes required to represent the sliced max value.void
serialize
(ByteBuffer buffer) Serializes the bitmap to the buffer without materialising it.int
Returns the size of the RangeBitmap on disk.
-
Field Details
-
GROWTH
private static final int GROWTH- See Also:
-
bufferSupplier
-
bufferCleaner
-
bytesPerMask
private final byte bytesPerMask -
rangeMask
private final long rangeMask -
slice
-
maskBuffer
-
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
-
-
Constructor Details
-
Appender
Appender(long maxValue, IntFunction<ByteBuffer> bufferSupplier, Consumer<ByteBuffer> cleaner)
-
-
Method Details
-
build
Converts the appender into an immutable range index.- Parameters:
supplier
- provides an appropriate ByteBuffer to store into- Returns:
- a queriable RangeBitmap
-
build
see build(IntFunction) -
build
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
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
-
containerForSlice
-
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)
-