Package org.roaringbitmap
Class RangeBitmap
- java.lang.Object
-
- org.roaringbitmap.RangeBitmap
-
public final class RangeBitmap extends java.lang.Object
A 2D bitmap which associates values with a row index and can perform range queries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RangeBitmap.Appender
Builder for constructing immutable RangeBitmapsprivate static class
RangeBitmap.Bits
private class
RangeBitmap.DoubleEvaluation
private class
RangeBitmap.SingleEvaluation
-
Field Summary
Fields Modifier and Type Field Description private static int
ARRAY
private static int
BITMAP
private static int
BITMAP_SIZE
private java.nio.ByteBuffer
buffer
private byte
bytesPerMask
private int
containersOffset
private static int
COOKIE
private long
mask
private int
masksOffset
private long
max
private static int
RUN
-
Constructor Summary
Constructors Constructor Description RangeBitmap(long mask, long max, java.nio.ByteBuffer buffer, int masksOffset, int containersOffset, byte bytesPerMask)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RangeBitmap.Appender
appender(long maxValue)
Append values to the RangeBitmap before sealing it, defaults to on heap ByteBuffers.static RangeBitmap.Appender
appender(long maxValue, java.util.function.IntFunction<java.nio.ByteBuffer> bufferSupplier, java.util.function.Consumer<java.nio.ByteBuffer> cleaner)
Append values to the RangeBitmap before sealing it.RoaringBitmap
between(long min, long max)
Returns a RoaringBitmap of rows which have a value in between the thresholds.long
betweenCardinality(long min, long max)
Returns the number of rows which have a value in between the thresholds.long
betweenCardinality(long min, long max, RoaringBitmap context)
Returns the number of rows which have a value in between the thresholds.RoaringBitmap
eq(long value)
Returns a RoaringBitmap of rows which have a value equal to the value.RoaringBitmap
eq(long value, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value equal to the value.long
eqCardinality(long value)
Returns the number of rows which have a value equal to the value.long
eqCardinality(long value, RoaringBitmap context)
Returns the number of rows which have a value equal to the value, and intersect with the context bitmap, which will not be modified.private static long
getContainerMask(java.nio.ByteBuffer buffer, int position, long mask, int bytesPerMask)
RoaringBitmap
gt(long threshold)
Returns a RoaringBitmap of rows which have a value greater than the threshold.RoaringBitmap
gt(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value greater than the threshold, and intersect with the context bitmap, which will not be modified.long
gtCardinality(long threshold)
Returns the number of rows which have a value greater than the threshold.long
gtCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value greater than the threshold, and intersect with the context bitmap, which will not be modified.RoaringBitmap
gte(long threshold)
Returns a RoaringBitmap of rows which have a value greater than or equal to the threshold.RoaringBitmap
gte(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value greater than or equal to the threshold, and intersect with the context bitmap, which will not be modified.long
gteCardinality(long threshold)
Returns the number of rows which have a value greater than or equal to the threshold.long
gteCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value greater than or equal to the threshold, and intersect with the context bitmap, which will not be modified.RoaringBitmap
lt(long threshold)
Returns a RoaringBitmap of rows which have a value less than the threshold.RoaringBitmap
lt(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value less than the threshold, and intersect with the context bitmap, which will not be modified.long
ltCardinality(long threshold)
Returns the number of rows which have a value less than the threshold.long
ltCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value less than the threshold, and intersect with the context bitmap, which will not be modified.RoaringBitmap
lte(long threshold)
Returns a RoaringBitmap of rows which have a value less than or equal to the threshold.RoaringBitmap
lte(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value less than or equal to the threshold, and intersect with the context bitmap, which will not be modified.long
lteCardinality(long threshold)
Returns the number of rows which have a value less than or equal to the threshold.long
lteCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value less than or equal to the threshold, and intersect with the context bitmap, which will not be modified.static RangeBitmap
map(java.nio.ByteBuffer buffer)
Maps the RangeBitmap from the buffer with minimal allocation.RoaringBitmap
neq(long value)
Returns a RoaringBitmap of rows which have a value not equal to the value.RoaringBitmap
neq(long value, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value not equal to the value.long
neqCardinality(long value)
Returns the number of rows which have a value not equal to the value.long
neqCardinality(long value, RoaringBitmap context)
Returns the number of rows which have a value not equal to the value, and intersect with the context bitmap, which will not be modified.
-
-
-
Field Detail
-
COOKIE
private static final int COOKIE
- See Also:
- Constant Field Values
-
BITMAP
private static final int BITMAP
- See Also:
- Constant Field Values
-
RUN
private static final int RUN
- See Also:
- Constant Field Values
-
ARRAY
private static final int ARRAY
- See Also:
- Constant Field Values
-
BITMAP_SIZE
private static final int BITMAP_SIZE
- See Also:
- Constant Field Values
-
buffer
private final java.nio.ByteBuffer buffer
-
masksOffset
private final int masksOffset
-
containersOffset
private final int containersOffset
-
mask
private final long mask
-
max
private final long max
-
bytesPerMask
private final byte bytesPerMask
-
-
Method Detail
-
appender
public static RangeBitmap.Appender appender(long maxValue, java.util.function.IntFunction<java.nio.ByteBuffer> bufferSupplier, java.util.function.Consumer<java.nio.ByteBuffer> cleaner)
Append values to the RangeBitmap before sealing it.- Parameters:
maxValue
- the maximum value to be appended, values larger than this value will be rejected.bufferSupplier
- provides ByteBuffers.- Returns:
- an appender.
-
appender
public static RangeBitmap.Appender appender(long maxValue)
Append values to the RangeBitmap before sealing it, defaults to on heap ByteBuffers.- Parameters:
maxValue
- the maximum value to be appended, values larger than this value will be rejected.- Returns:
- an appender.
-
map
public static RangeBitmap map(java.nio.ByteBuffer buffer)
Maps the RangeBitmap from the buffer with minimal allocation. The buffer must not be reused while the mapped RangeBitmap is live.- Parameters:
buffer
- a buffer containing a serialized RangeBitmap.- Returns:
- a RangeBitmap backed by the buffer.
-
between
public RoaringBitmap between(long min, long max)
Returns a RoaringBitmap of rows which have a value in between the thresholds.- Parameters:
min
- the inclusive minimum value.max
- the inclusive maximum value.- Returns:
- a bitmap of matching rows.
-
betweenCardinality
public long betweenCardinality(long min, long max)
Returns the number of rows which have a value in between the thresholds.- Parameters:
min
- the inclusive minimum value.max
- the inclusive maximum value.- Returns:
- the number of matching rows.
-
betweenCardinality
public long betweenCardinality(long min, long max, RoaringBitmap context)
Returns the number of rows which have a value in between the thresholds.- Parameters:
min
- the inclusive minimum value.max
- the inclusive maximum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
lte
public RoaringBitmap lte(long threshold)
Returns a RoaringBitmap of rows which have a value less than or equal to the threshold.- Parameters:
threshold
- the inclusive maximum value.- Returns:
- a bitmap of matching rows.
-
lte
public RoaringBitmap lte(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value less than or equal to the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the inclusive maximum value.context
- to be intersected with.- Returns:
- a bitmap of matching rows.
-
lteCardinality
public long lteCardinality(long threshold)
Returns the number of rows which have a value less than or equal to the threshold.- Parameters:
threshold
- the inclusive maximum value.- Returns:
- the number of matching rows.
-
lteCardinality
public long lteCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value less than or equal to the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the inclusive maximum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
lt
public RoaringBitmap lt(long threshold)
Returns a RoaringBitmap of rows which have a value less than the threshold.- Parameters:
threshold
- the exclusive maximum value.- Returns:
- a bitmap of matching rows.
-
lt
public RoaringBitmap lt(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value less than the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the exclusive maximum value.context
- to be intersected with.- Returns:
- a bitmap of matching rows which intersect .
-
ltCardinality
public long ltCardinality(long threshold)
Returns the number of rows which have a value less than the threshold.- Parameters:
threshold
- the exclusive maximum value.- Returns:
- the number of matching rows.
-
ltCardinality
public long ltCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value less than the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the exclusive maximum value.context
- to be intersected with.- Returns:
- the number of matching rows which intersect .
-
gt
public RoaringBitmap gt(long threshold)
Returns a RoaringBitmap of rows which have a value greater than the threshold.- Parameters:
threshold
- the exclusive minimum value.- Returns:
- a bitmap of matching rows.
-
gt
public RoaringBitmap gt(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value greater than the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the exclusive minimum value.context
- to be intersected with.- Returns:
- a bitmap of matching rows.
-
gtCardinality
public long gtCardinality(long threshold)
Returns the number of rows which have a value greater than the threshold.- Parameters:
threshold
- the exclusive minimum value.- Returns:
- the number of matching rows.
-
gtCardinality
public long gtCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value greater than the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the exclusive minimum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
gte
public RoaringBitmap gte(long threshold)
Returns a RoaringBitmap of rows which have a value greater than or equal to the threshold.- Parameters:
threshold
- the inclusive minimum value.- Returns:
- a bitmap of matching rows.
-
gte
public RoaringBitmap gte(long threshold, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value greater than or equal to the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the inclusive minimum value.context
- to be intersected with.- Returns:
- a bitmap of matching rows.
-
gteCardinality
public long gteCardinality(long threshold)
Returns the number of rows which have a value greater than or equal to the threshold.- Parameters:
threshold
- the inclusive minimum value.- Returns:
- the number of matching rows.
-
gteCardinality
public long gteCardinality(long threshold, RoaringBitmap context)
Returns the number of rows which have a value greater than or equal to the threshold, and intersect with the context bitmap, which will not be modified.- Parameters:
threshold
- the inclusive minimum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
eq
public RoaringBitmap eq(long value)
Returns a RoaringBitmap of rows which have a value equal to the value.- Parameters:
value
- the value to filter by.- Returns:
- a bitmap of matching rows.
-
eq
public RoaringBitmap eq(long value, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value equal to the value.- Parameters:
value
- the value to filter by.context
- to be intersected with.- Returns:
- a bitmap of matching rows.
-
eqCardinality
public long eqCardinality(long value)
Returns the number of rows which have a value equal to the value.- Parameters:
value
- the inclusive minimum value.- Returns:
- the number of matching rows.
-
eqCardinality
public long eqCardinality(long value, RoaringBitmap context)
Returns the number of rows which have a value equal to the value, and intersect with the context bitmap, which will not be modified.- Parameters:
value
- the inclusive minimum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
neq
public RoaringBitmap neq(long value)
Returns a RoaringBitmap of rows which have a value not equal to the value.- Parameters:
value
- the value to filter by.- Returns:
- a bitmap of matching rows.
-
neq
public RoaringBitmap neq(long value, RoaringBitmap context)
Returns a RoaringBitmap of rows which have a value not equal to the value.- Parameters:
value
- the value to filter by.context
- to be intersected with.- Returns:
- a bitmap of matching rows.
-
neqCardinality
public long neqCardinality(long value)
Returns the number of rows which have a value not equal to the value.- Parameters:
value
- the inclusive minimum value.- Returns:
- the number of matching rows.
-
neqCardinality
public long neqCardinality(long value, RoaringBitmap context)
Returns the number of rows which have a value not equal to the value, and intersect with the context bitmap, which will not be modified.- Parameters:
value
- the inclusive minimum value.context
- to be intersected with.- Returns:
- the number of matching rows.
-
getContainerMask
private static long getContainerMask(java.nio.ByteBuffer buffer, int position, long mask, int bytesPerMask)
-
-