public interface ManagedReader<T extends SchemaNegotiator>
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:
open(SchemaNegotiator)
: Use the provided 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 | Method and Description |
---|---|
void |
close()
Release resources.
|
boolean |
next()
Read the next batch.
|
boolean |
open(T negotiator)
Setup the record reader.
|
boolean open(T negotiator)
negotiator
- mechanism to negotiate select and table
schemas, then create the row set reader used to load data into
value vectorsRuntimeException
- for "hard" errors that should terminate
the query. UserException preferred to explain the problem
better than the scan operator can by guessing at the causeboolean 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.