public void add ( final long rangeStart , final long rangeEnd ) { int startHigh = high ( rangeStart ) ; int startLow = low ( rangeStart ) ; int endHigh = high ( rangeEnd ) ; int endLow = low ( rangeEnd ) ; for ( int high = startHigh ; high <= endHigh ; high ++ ) { final int currentStartLow ; if ( startHigh == high ) { // The whole range starts in this bucket currentStartLow = startLow ; } else { // Add the bucket from the beginning currentStartLow = 0 ; } long startLowAsLong = Util . toUnsignedLong ( currentStartLow ) ; final long endLowAsLong ; if ( endHigh == high ) { // The whole range ends in this bucket endLowAsLong = Util . toUnsignedLong ( endLow ) ; } else { // Add the bucket until the end: we have a +1 as, in RoaringBitmap.add(long,long), the end // is excluded endLowAsLong = Util . toUnsignedLong ( - 1 ) + 1 ; } if ( endLowAsLong > startLowAsLong ) { // Initialize the bitmap only if there is access data to write BitmapDataProvider bitmap = highToBitmap . get ( high ) ; if ( bitmap == null ) { bitmap = new MutableRoaringBitmap ( ) ; pushBitmapForHigh ( high , bitmap ) ; } if ( bitmap instanceof RoaringBitmap ) { ( ( RoaringBitmap ) bitmap ) . add ( startLowAsLong , endLowAsLong ) ; } else if ( bitmap instanceof MutableRoaringBitmap ) { ( ( MutableRoaringBitmap ) bitmap ) . add ( startLowAsLong , endLowAsLong ) ; } else { throw new UnsupportedOperationException ( "TODO. Not for " + bitmap . getClass ( ) ) ; } } } invalidateAboveHigh ( startHigh ) ; }
Add to the current bitmap all longs in [ rangeStart rangeEnd ) .