Package org.roaringbitmap.buffer
Class RoaringBatchIterator
- java.lang.Object
-
- org.roaringbitmap.buffer.RoaringBatchIterator
-
- All Implemented Interfaces:
java.lang.Cloneable
,BatchIterator
public final class RoaringBatchIterator extends java.lang.Object implements BatchIterator
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayBatchIterator
arrayBatchIterator
private BitmapBatchIterator
bitmapBatchIterator
private MappeableContainerPointer
containerPointer
private ContainerBatchIterator
iterator
private int
key
private RunBatchIterator
runBatchIterator
-
Constructor Summary
Constructors Constructor Description RoaringBatchIterator(MappeableContainerPointer containerPointer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceIfNeeded(int target)
If needed, advance as long as the next value is smaller than minval The advanceIfNeeded method is used for performance reasons, to skip over unnecessary repeated calls to next.BatchIterator
clone()
Creates a copy of the iterator.boolean
hasNext()
Returns true is there are more values to get.int
nextBatch(int[] buffer)
Writes the next batch of integers onto the buffer, and returns how many were written.private void
nextContainer()
private void
nextIterator()
private void
nextIterator(MappeableArrayContainer array)
private void
nextIterator(MappeableBitmapContainer bitmap)
private void
nextIterator(MappeableRunContainer run)
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.roaringbitmap.BatchIterator
asIntIterator
-
-
-
-
Field Detail
-
containerPointer
private MappeableContainerPointer containerPointer
-
key
private int key
-
iterator
private ContainerBatchIterator iterator
-
arrayBatchIterator
private ArrayBatchIterator arrayBatchIterator
-
bitmapBatchIterator
private BitmapBatchIterator bitmapBatchIterator
-
runBatchIterator
private RunBatchIterator runBatchIterator
-
-
Constructor Detail
-
RoaringBatchIterator
public RoaringBatchIterator(MappeableContainerPointer containerPointer)
-
-
Method Detail
-
nextBatch
public int nextBatch(int[] buffer)
Description copied from interface:BatchIterator
Writes the next batch of integers onto the buffer, and returns how many were written. Aims to fill the buffer.- Specified by:
nextBatch
in interfaceBatchIterator
- Parameters:
buffer
- - the target to write onto- Returns:
- how many values were written during the call.
-
hasNext
public boolean hasNext()
Description copied from interface:BatchIterator
Returns true is there are more values to get.- Specified by:
hasNext
in interfaceBatchIterator
- Returns:
- whether the iterator is exhaused or not.
-
advanceIfNeeded
public void advanceIfNeeded(int target)
Description copied from interface:BatchIterator
If needed, advance as long as the next value is smaller than minval The advanceIfNeeded method is used for performance reasons, to skip over unnecessary repeated calls to next. Suppose for example that you wish to compute the intersection between an ordered list of integers (e.g., int[] x = {1,4,5}) and a BatchIterator. You might do it as follows...
The benefit of calling advanceIfNeeded is that each such call can be much faster than repeated calls to "next". The underlying implementation can "skip" over some data.int[] buffer = new int[128]; BatchIterator j = // get an iterator int val = // first value from my other data structure j.advanceIfNeeded(val); while ( j.hasNext() ) { int limit = j.nextBatch(buffer); for (int i = 0; i < limit; i++) { if (buffer[i] == val) { // got it! // do something here val = // get next value? } } j.advanceIfNeeded(val); }
- Specified by:
advanceIfNeeded
in interfaceBatchIterator
- Parameters:
target
- threshold
-
clone
public BatchIterator clone()
Description copied from interface:BatchIterator
Creates a copy of the iterator.- Specified by:
clone
in interfaceBatchIterator
- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of the current iterator
-
nextContainer
private void nextContainer()
-
nextIterator
private void nextIterator()
-
nextIterator
private void nextIterator(MappeableArrayContainer array)
-
nextIterator
private void nextIterator(MappeableBitmapContainer bitmap)
-
nextIterator
private void nextIterator(MappeableRunContainer run)
-
-