public interface ManagedReader
RecordReader
interface.
This interface is used to create readers that work with the projection mechanism to provide services for handling projection, setting up the result set loader, handling schema smoothing, sharing vectors across batches, etc.
Note that this interface reads a batch of rows, not a single row. (The
original RecordReader
could be confusing in this aspect.)
The expected lifecycle is:
ScanBatch
which created all readers at the start of the
scan.)SchemaNegotiator
to configure the
scanner framework for this reader by specifying a schema (if known), desired
row counts and other configuration options. Call SchemaNegotiator.build()
to obtain a RowSetLoader
to use to capture the rows that the reader reads.next()
: called for each batch. The batch is written using the
result set loader obtained above. The scanner framework handles details of
tracking version changes, handling overflow, limiting record counts, and
so on. Return true to indicate a batch is available, false
to indicate EOF. The first call to next() can return false
if the data source has no rows.close()
: called to release resources. May be called before
next() returns false.
If an error occurs, the reader can throw a RuntimeException
from any method. A UserException is preferred to provide
detailed information about the source of the problem.
Modifier and Type | Interface and Description |
---|---|
static class |
ManagedReader.EarlyEofException
Exception thrown from the constructor if the data source is empty and
can produce no data or schema.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Release resources.
|
boolean |
next()
Read the next batch.
|
boolean next()
This somewhat complex protocol avoids the need to allocate a final batch just to find out that no more data is available; it allows EOF to be returned along with the final batch.
RuntimeException
- (UserException preferred) if an
error occurs that should fail the query.void close()
RuntimeException
- (UserException preferred) if an
error occurs that should fail the query.Copyright © 1970 The Apache Software Foundation. All rights reserved.