Class 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 RangeBitmaps
    • 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 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.