public boolean hasNext() { if ( endOfProcess ) return false; int first; while ( curr[ first = queue.first() ] == lastLeft ) { if ( ++currPos[ first ] == count[ first ] ) { endOfProcess = true; return false; } curr[ first ] = position[ first ][ currPos[ first ] ]; maxRight = Math.max( maxRight, curr[ first ] ); queue.changed(); } return true; }
@Override public Interval nextInterval() throws IOException { if ( endOfProcess ) return null; int first; while ( curr[ first = queue.first() ] == lastLeft ) { if ( ( curr[ first ] = indexIterator[ first ].nextPosition() ) == IndexIterator.END_OF_POSITIONS ) { endOfProcess = true; return null; } maxRight = Math.max( maxRight, curr[ first ] ); queue.changed(); } int nextLeft, nextRight; do { nextLeft = curr[ first = queue.first() ]; nextRight = maxRight; if ( DEBUG ) System.err.println( this + " is saving interval " + Interval.valueOf( nextLeft, nextRight ) ); /* We check whether all iterators are on the same position, and * whether the top interval iterator is exhausted. In both cases, the * current span is guaranteed to be a minimal interval. */ if ( curr[ first ] == maxRight || ( endOfProcess = ( curr[ first ] = indexIterator[ first ].nextPosition() ) == IndexIterator.END_OF_POSITIONS ) ) break; if ( maxRight < curr[ first ] ) maxRight = curr[ first ]; queue.changed(); } while ( maxRight == nextRight ); return Interval.valueOf( lastLeft = nextLeft, nextRight ); }
@Override public Interval nextInterval() throws IOException { if ( endOfProcess ) return null; int first; while ( curr[ first = queue.first() ] == lastLeft ) { if ( ( curr[ first ] = indexIterator[ first ].nextPosition() ) == IndexIterator.END_OF_POSITIONS ) { endOfProcess = true; return null; } maxRight = Math.max( maxRight, curr[ first ] ); queue.changed(); } int nextLeft, nextRight; do { nextLeft = curr[ first = queue.first() ]; nextRight = maxRight; if ( DEBUG ) System.err.println( this + " is saving interval " + Interval.valueOf( nextLeft, nextRight ) ); /* We check whether all iterators are on the same position, and * whether the top interval iterator is exhausted. In both cases, the * current span is guaranteed to be a minimal interval. */ if ( curr[ first ] == maxRight || ( endOfProcess = ( curr[ first ] = indexIterator[ first ].nextPosition() ) == IndexIterator.END_OF_POSITIONS ) ) break; if ( maxRight < curr[ first ] ) maxRight = curr[ first ]; queue.changed(); } while ( maxRight == nextRight ); return Interval.valueOf( lastLeft = nextLeft, nextRight ); }
private int hasNextInternal() { if ( positionQueue.isEmpty() ) return -1; int first; while ( curr[ first = positionQueue.first() ] == last ) { if ( ++currPos[ first ] == count[ first ] ) { positionQueue.dequeue(); if ( positionQueue.isEmpty() ) return -1; } else { curr[ first ] = position[ first ][ currPos[ first ] ]; positionQueue.changed(); } } return first; }
public Interval nextInterval() { if ( ! hasNext() ) return null; int nextLeft, nextRight; do { final int first = queue.first(); nextLeft = curr[ first ]; nextRight = maxRight; if ( DEBUG ) System.err.println( this + " is saving interval " + Interval.valueOf( nextLeft, nextRight ) ); /* We check whether all iterators are on the same position, and * whether the top interval iterator is exhausted. In both cases, the * current span is guaranteed to be a minimal interval. */ if ( curr[ first ] == maxRight || ( endOfProcess = ++currPos[ first ] == count[ first ] ) ) break; curr[ first ] = position[ first ][ currPos[ first ] ]; if ( maxRight < curr[ first ] ) maxRight = curr[ first ]; queue.changed(); } while ( maxRight == nextRight ); return Interval.valueOf( lastLeft = nextLeft, nextRight ); }
public int nextDocument() throws IOException { if ( curr == END_OF_LIST ) return END_OF_LIST; if ( curr != -1 ) { final int result; if ( ( result = documentIterator[ currentIterator ].nextDocument() ) != END_OF_LIST ) { globalDocumentPointer[ currentIterator ] = strategy.globalPointer( usedIndex[ currentIterator ], result ); queue.changed(); } else queue.dequeue(); } return curr = queue.isEmpty() ? END_OF_LIST : globalDocumentPointer[ currentIterator = queue.first() ]; }
protected int nextDocumentInternal() throws IOException { final int result; if ( ( result = documentIterator[ currentIterator ].nextDocument() ) != -1 ) { globalDocumentPointer[ currentIterator ] = strategy.globalPointer( usedIndex[ currentIterator ], result ); queue.changed(); } else queue.dequeue(); curr = queue.isEmpty() ? END_OF_LIST : globalDocumentPointer[ currentIterator = queue.first() ]; return toNextDocument( curr ); }
public Interval nextInterval() { if ( next != null ) { final Interval result = next; next = null; return result; } if ( emitted < extracted ) return Interval.valueOf( cache[ emitted++ ] ); if ( positionQueue.isEmpty() ) return null; final int first = positionQueue.first(); if ( extracted == cache.length ) cache = IntArrays.grow( cache, extracted + 1 ); cache[ extracted++ ] = curr[ first ]; if ( ++currPos[ first ] < count[ first ] ) { curr[ first ] = position[ first ][ currPos[ first ] ]; positionQueue.changed(); if ( curr[ positionQueue.first() ] == cache[ extracted - 1 ] ) throw new IllegalArgumentException( "Duplicate positions in " + this ); } else positionQueue.dequeue(); return Interval.valueOf( cache[ emitted++ ] ); }
public Interval nextInterval() { if ( next != null ) { final Interval result = next; next = null; return result; } if ( emitted < extracted ) return Interval.valueOf( cache[ emitted++ ] ); if ( positionQueue.isEmpty() ) return null; final int first = positionQueue.first(); if ( extracted == cache.length ) cache = IntArrays.grow( cache, extracted + 1 ); cache[ extracted++ ] = curr[ first ]; if ( ++currPos[ first ] < count[ first ] ) { curr[ first ] = position[ first ][ currPos[ first ] ]; positionQueue.changed(); if ( curr[ positionQueue.first() ] == cache[ extracted - 1 ] ) throw new IllegalArgumentException( "Duplicate positions in " + this ); } else positionQueue.dequeue(); return Interval.valueOf( cache[ emitted++ ] ); }
public int skipTo( final int n ) throws IOException { ahead = false; if ( curr >= n ) return curr; currentIterators.clear(); frontSize = -1; // Invalidate front int first, res; while( refArray[ first = queue.first() ] < n ) { // Cannot advance the minimum if ( ( res = documentIterator[ first ].skipTo( n ) ) == END_OF_LIST ) { // Remove it queue.dequeue(); // If nothing else remains, we are done if ( queue.isEmpty() ) return curr = END_OF_LIST; } else { // Advance the top element, and signal this fact to the queue refArray[ first ] = res; queue.changed(); } } return curr = refArray[ first ]; }
refArray[i] += sourceDelta; prevTarget[i] = -1; queue.changed();
protected int nextDocumentInternal() throws IOException { currentIterators.clear(); frontSize = -1; // Invalidate front // The least element int first, c = refArray[ queue.first() ]; // Advance all elements equal to the least one while( refArray[ first = queue.first() ] == c ) { if ( ( refArray[ first ] = documentIterator[ first ].nextDocument() ) != - 1 ) queue.changed(); else { // Remove it queue.dequeue(); // If nothing else remains, we are done if ( queue.isEmpty() ) { curr = END_OF_LIST; return -1; } } } return curr = refArray[ first ]; }
public Interval nextInterval() { if ( next != null ) { final Interval result = next; next = null; return result; } if ( positionQueue.isEmpty() ) return null; int first = positionQueue.first(); final int previous = curr[ first ]; do if ( ++currPos[ first ] == count[ first ] ) { positionQueue.dequeue(); if ( positionQueue.isEmpty() ) return null; } else { curr[ first ] = position[ first ][ currPos[ first ] ]; positionQueue.changed(); } while ( curr[ first = positionQueue.first() ] == previous ); return Interval.valueOf( curr[ first ] ); }
public int skipTo( final int p ) throws IOException { ahead = false; if ( curr >= p ) return curr; if ( p >= indexReader.index.numberOfDocuments ) return curr = END_OF_LIST; int i, d; //System.err.println( "Advancing to " + n + " doc: " + Arrays.toString( doc ) + " first: " + queue.first() ); while( ! queue.isEmpty() && globalDocumentPointer[ i = queue.first() ] < p ) { d = documentIterator[ i ].skipTo( strategy.localPointer( p ) ); if ( d == Integer.MAX_VALUE ) queue.dequeue(); else { globalDocumentPointer[ i ] = strategy.globalPointer( usedIndex[ i ], d ); if ( globalDocumentPointer[ i ] < p ) queue.dequeue(); // This covers the case of getting to the end of list without finding p else queue.changed(); } } if ( queue.isEmpty() ) return curr = END_OF_LIST; return curr = globalDocumentPointer[ currentIterator = queue.first() ]; }
public int skipTo( final int p ) throws IOException { if ( curr >= p ) return curr; if ( p >= indexReader.index.numberOfDocuments ) return curr = END_OF_LIST; int i, d; //System.err.println( "Advancing to " + n + " doc: " + Arrays.toString( doc ) + " first: " + queue.first() ); while( ! queue.isEmpty() && globalDocumentPointer[ i = queue.first() ] < p ) { d = documentIterator[ i ].skipTo( strategy.localPointer( p ) ); if ( d == END_OF_LIST ) queue.dequeue(); else { globalDocumentPointer[ i ] = strategy.globalPointer( usedIndex[ i ], d ); if ( globalDocumentPointer[ i ] < p ) queue.dequeue(); // This covers the case of getting to the end of list without finding p else queue.changed(); } } if ( queue.isEmpty() ) return curr = END_OF_LIST; return curr = globalDocumentPointer[ currentIterator = queue.first() ]; }
else { doc[ currIndex ] = ir.nextDocument(); documentQueue.changed();
else { doc[ currIndex ] = ir.nextDocument(); documentQueue.changed();