Class RspArray.OverlapProbe
- All Implemented Interfaces:
SafeCloseable,AutoCloseable
RspArray.overlapsRange(int, long, long), carrying both cursors a caller would otherwise
re-establish on every call.
The one-shot form has nowhere to keep a span view, so it takes one from the thread's work data and gives it back
on each call. A caller testing one key per span pays that for every key, which is what makes probing lose to
simply walking this array's ranges. This holds a view of its own, as RspRangeIterator does, and
re-initializes it only on moving to a different span; it also carries the span index, so an ascending caller
searches from where the last probe stopped.
A probe reads the array directly and takes no reference on it, as RspArray.overlaps(RspArray, RspArray) does not
either: it belongs to one operation and is closed before that operation returns, so the array cannot be mutated
while one is open. Cursors that do outlive their caller, such as RspArray.SpanCursorForwardImpl, acquire instead,
which marks the array shared and makes the next mutation of it copy.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanoverlapsRange(long start, long end) Whether the array holds any key in[start, end].longThe first key of the block the next probe will start on.
-
Method Details
-
overlapsRange
public boolean overlapsRange(long start, long end) Whether the array holds any key in[start, end].Ranges must be presented in ascending order: the search resumes where the last one stopped.
-
resumeBlockKey
public long resumeBlockKey()The first key of the block the next probe will start on. Every key this array still has to offer is at or above it, so a caller that has just missed can skip its own keys below that point. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-