Modifier and Type | Class and Description |
---|---|
static class |
KuduScanner.KuduScannerBuilder
A Builder class to build
KuduScanner . |
Modifier and Type | Method and Description |
---|---|
RowResultIterator |
close()
Closes this scanner (don't forget to call this when you're done with it!).
|
long |
getBatchSizeBytes()
Returns the maximum number of bytes returned by the scanner, on each batch.
|
boolean |
getCacheBlocks()
Returns if this scanner was configured to cache data blocks or not.
|
long |
getLimit()
Returns the maximum number of rows that this scanner was configured to return.
|
Schema |
getProjectionSchema()
Returns the projection schema of this scanner.
|
AsyncKuduScanner.ReadMode |
getReadMode()
Returns the ReadMode for this scanner.
|
ResourceMetrics |
getResourceMetrics()
Returns the resource metrics of this scanner.
|
long |
getScanRequestTimeout()
Returns the current value of the scanner's scan request timeout.
|
boolean |
hasMoreRows()
Tells if the last rpc returned that there might be more rows to scan.
|
boolean |
isClosed() |
KuduScannerIterator |
iterator() |
void |
keepAlive()
Keep the current remote scanner alive.
|
RowResultIterator |
nextRows()
Scans a number of rows.
|
void |
setReuseRowResult(boolean reuseRowResult)
If set to true, the
RowResult object returned by the RowResultIterator
will be reused with each call to Iterator.next() . |
void |
setRowDataFormat(AsyncKuduScanner.RowDataFormat rowDataFormat)
Optionally set expected row data format.
|
boolean |
startKeepAlivePeriodically(int keepAliveIntervalMS)
Keep the current remote scanner alive by sending keep-alive requests periodically.
|
boolean |
stopKeepAlivePeriodically()
Stop keeping the current remote scanner alive periodically.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public boolean hasMoreRows()
public void setReuseRowResult(boolean reuseRowResult)
RowResult
object returned by the RowResultIterator
will be reused with each call to Iterator.next()
.
This can be a useful optimization to reduce the number of objects created.
Note: DO NOT use this if the RowResult is stored between calls to next().
Enabling this optimization means that a call to next() mutates the previously returned
RowResult. Accessing the previously returned RowResult after a call to next(), by storing all
RowResults in a collection and accessing them later for example, will lead to all of the
stored RowResults being mutated as per the data in the last RowResult returned.public void setRowDataFormat(AsyncKuduScanner.RowDataFormat rowDataFormat)
rowDataFormat
- Row data format to be expected.public RowResultIterator nextRows() throws KuduException
Once this method returns null
once (which indicates that this
Scanner
is done scanning), calling it again leads to an undefined
behavior.
KuduException
- if anything went wrong.public final void keepAlive() throws KuduException
Keep the current remote scanner alive on the Tablet server for an additional time-to-live. This is useful if the interval in between nextRows() calls is big enough that the remote scanner might be garbage collected. The scanner time-to-live can be configured on the tablet server via the --scanner_ttl_ms configuration flag and has a default of 60 seconds.
This does not invalidate any previously fetched results.
Note that an exception thrown by this method should not be taken as indication that the scan has failed. Subsequent calls to nextRows() might still be successful, particularly if the scanner is configured to be fault tolerant.
KuduException
- if anything went wrong.public final boolean startKeepAlivePeriodically(int keepAliveIntervalMS) throws KuduException
startKeepAlivePeriodically() uses a timer to call keepAlive() periodically, which is defined by parameter keepAliveIntervalMS. It sends keep-alive requests to the server periodically using a separate thread. This is useful if the client takes long time to handle the fetched data before having the chance to call keepAlive(). This can be called after the scanner is opened and the timer can be stopped by calling stopKeepAlivePeriodically().
KuduException
- if anything went wrong.
* @return true if starting keep-alive timer successfully.
public final boolean stopKeepAlivePeriodically()
This function stops to send keep-alive requests to the server periodically. After function startKeepAlivePeriodically is called, this function can be used to stop the keep-alive timer at any time. The timer will be stopped automatically after finishing scanning. But it can also be stopped manually by calling this function.
public boolean isClosed()
public RowResultIterator close() throws KuduException
Closing a scanner already closed has no effect.
KuduException
- if anything went wrong.public long getLimit()
public boolean getCacheBlocks()
public long getBatchSizeBytes()
public AsyncKuduScanner.ReadMode getReadMode()
public Schema getProjectionSchema()
public ResourceMetrics getResourceMetrics()
public long getScanRequestTimeout()
public KuduScannerIterator iterator()