Class RspRangeIterator

All Implemented Interfaces:
LongRangeIterator, SafeCloseable, AutoCloseable

public class RspRangeIterator
extends Object
implements LongRangeIterator, SafeCloseable
  • Constructor Details

  • Method Details

    • start

      public long start()
      Specified by:
      start in interface LongRangeIterator
      start point of the current interval.
    • end

      public long end()
      Specified by:
      end in interface LongRangeIterator
      end point of the current interval, inclusive.
    • postpone

      public void postpone​(long v)
      At call, start() <= v <= end()
      v - Next call to start will return this value.
    • hasNext

      public boolean hasNext()
      This method should be called: * After the iterator is created and before calling any other methods; it returns false, calling any other methods results in undefined behavior. * Right after a call to next, similar to above.
      Specified by:
      hasNext in interface LongRangeIterator
      true if a call to next leads to a valid range to be read from start() and end().
    • next

      public void next()
      Specified by:
      next in interface LongRangeIterator
    • forEachLongRange

      public boolean forEachLongRange​(LongRangeAbortableConsumer lrc)
      Specified by:
      forEachLongRange in interface LongRangeIterator
    • advance

      public boolean advance​(long key)
      Advance the current iterator position while the current range end is less than key. This results in either (a) true, leaving a current range whose start value is greater or equal than key, or (b) false, leaving an exhausted, invalid iterator. Note if the iterator is not exhausted, true is returned and the satisfying range is left as the iterator's current range: no need to call next to get to it. Also note the iterator may not move if at call entry the current range already satisfies (a). If this method returns false, it implies the iterator has been exhausted, the current range is invalid, and subsequent calls to hasNext will return false; there is no guarantee as to where the start and end positions are left in this case.
      key - a key to search forward from the current iterator position
      true if case (a), false if case (b).
    • search

      public void search​(RowSetUtils.Comparator comp)
      Advance the current iterator (start) position to the rightmost (last) value v that maintains comp.directionToTargetFrom(v) >= 0. I.e, either hasNext() returns false after this call, or the next value in the iterator nv would be such that comp.directionToTargetFrom(nv) < 0. Note this method should be called only after calling hasNext() and next() at least once, eg, from a valid current position in a non-empty and also non-exhausted iterator.
      comp - a comparator used to search forward from the current iterator position
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • rangeIteratorView

      public RspRangeIterator.RangeIteratorView rangeIteratorView​(long startOffset, long rangesEnd)
      Create a RangeIterator that is a view into this iterator; the returned rangeIterator has current start() - startOffset as it initial start value (note the iterator needs to have a valid current position at the time of the call). The returned RangeIterator includes all the ranges until the end parameter (exclusive), and as it advances it will make the underlying iterator advance. Once the RangeIterator is exhausted, the underlying iterator will have a current value that is one after the last range returned by the range iterator (not this may have been truncated to a partial, still valid, range).
      startOffset - The resulting range iterator returns ranges offset with this value.
      rangesEnd - boundary (exclusive) on the underlying iterator ranges for the ranges returned.