net.opentsdb.core
public interface SeekableView extends Iterator<DataPoint>
The iterator returned by classes that implement this interface must return
each DataPoint
in O(1)
and does not support remove()
.
Because no data is copied during iteration and no new object gets created,
the DataPoint
returned must not be stored and gets
invalidated as soon as next()
is called on the iterator (actually it
doesn't get invalidated but rather its contents changes). If you want to
store individual data points, you need to copy the timestamp and value out
of each DataPoint
into your own data structures.
In the vast majority of cases, the iterator will be used to go once through all the data points, which is why it's not a problem if the iterator acts just as a transient "view". Iterating will be very cheap since no memory allocation is required (except to instantiate the actual iterator at the beginning).
boolean hasNext()
true
if this view has more elements.DataPoint next()
next()
is called.next
in interface Iterator<DataPoint>
NoSuchElementException
- if there were no more elements to iterate
on (in which case hasNext()
would have returned false
.void remove()
remove
in interface Iterator<DataPoint>
UnsupportedOperationException
- always.void seek(long timestamp)
This allows the iterator to skip all the data points that are strictly before the given timestamp.
timestamp
- A strictly positive 32 bit UNIX timestamp (in seconds).IllegalArgumentException
- if the timestamp is zero, or negative,
or doesn't fit on 32 bits (think "unsigned int" -- yay Java!).