@API(value=UNSTABLE) public class CursorLimitManager extends Object
BaseCursor
.
In contrast to the individual cursors, which may react to out-of-band limits in various ways (including ignoring them
entirely), the limit manager merely tracks the limit state and provides a coherent answer to the questions:
1) Can the cursor advance without exceeding the limit?
2) What limit has been exceeded?
This class also tracks whether or not the base cursor has produced any records. Except when reaching a limit throws
an exception, a base cursor is always permitted to load at least one record before it is stopped by an out-of-band
limit. This contract ensures that cursors with multiple child cursors (such as UnionCursor
and IntersectionCursor
) can always make progress. This "free initial pass" is provided per cursor, not per
limit: all out-band-limits share the same initial pass.Constructor and Description |
---|
CursorLimitManager(FDBRecordContext context,
ScanProperties scanProperties) |
CursorLimitManager(RecordScanLimiter recordScanLimiter,
boolean failOnScanLimitReached,
ByteScanLimiter byteScanLimiter,
TimeScanLimiter timeScanLimiter) |
CursorLimitManager(ScanProperties scanProperties) |
Modifier and Type | Method and Description |
---|---|
Optional<RecordCursor.NoNextReason> |
getStoppedReason()
Report a single reason associated with a limit that has been exceeded.
|
boolean |
isStopped()
Report whether any limit handled by this manager has been exceeded.
|
void |
reportScannedBytes(long byteSize)
Record that the specified number of bytes have been scanned and update the relevant limiters with this information.
|
boolean |
tryRecordScan()
Inform the limit manager that a cursor is trying to scan a record.
|
public CursorLimitManager(@Nullable RecordScanLimiter recordScanLimiter, boolean failOnScanLimitReached, @Nullable ByteScanLimiter byteScanLimiter, @Nullable TimeScanLimiter timeScanLimiter)
public CursorLimitManager(@Nonnull ScanProperties scanProperties)
public CursorLimitManager(@Nullable FDBRecordContext context, @Nonnull ScanProperties scanProperties)
public boolean isStopped()
true
if any limit has been exceeded and false
otherwisepublic Optional<RecordCursor.NoNextReason> getStoppedReason()
Optional.emtpy()
.Optional.empty()
if no limit has been exceededpublic boolean tryRecordScan()
true
and update the internal state to reflect that record scan.
If a limit would be exceeded by scanning another record, return false
and update the state
accordingly.true
if another record scan would not exceed any limit and false
if it wouldScanLimitReachedException
- if the scan limit was reached and ExecuteProperties.isFailOnScanLimitReached()
public void reportScannedBytes(long byteSize)
byteSize
- the number of bytes scanned