Package org.apache.drill.exec.store.pojo
Class AbstractPojoRecordReader<T>
java.lang.Object
org.apache.drill.exec.store.AbstractRecordReader
org.apache.drill.exec.store.pojo.AbstractPojoRecordReader<T>
- All Implemented Interfaces:
AutoCloseable
,Iterable<T>
,RecordReader
- Direct Known Subclasses:
DynamicPojoRecordReader
,PojoRecordReader
public abstract class AbstractPojoRecordReader<T>
extends AbstractRecordReader
implements Iterable<T>
Parent class for all pojo readers. Pojo readers can be based on java class (field list is predefined) or dynamic.
Contains general logic for initiating writers and reading values from each row fields.
-
Field Summary
Fields inherited from class org.apache.drill.exec.store.AbstractRecordReader
DEFAULT_TEXT_COLS_TO_READ
Fields inherited from interface org.apache.drill.exec.store.RecordReader
ALLOCATOR_INITIAL_RESERVATION, ALLOCATOR_MAX_RESERVATION
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractPojoRecordReader
(List<T> records) protected
AbstractPojoRecordReader
(List<T> records, int recordsPerBatch) -
Method Summary
Modifier and TypeMethodDescriptionvoid
allocate
(Map<String, ValueVector> vectorMap) void
close()
protected abstract Object
getFieldValue
(T row, int fieldPosition) Retrieves field value to be written based for given row and field position.protected PojoWriter
initWriter
(Class<?> type, String fieldName, OutputMutator output) Creates writer based input class type and then initiates it.iterator()
int
next()
Increments this record reader forward, writing via the provided output mutator into the output batch.void
setup
(OperatorContext context, OutputMutator output) Configure the RecordReader with the provided schema and the record batch that should be written to.protected abstract List<PojoWriter>
setupWriters
(OutputMutator output) Setups writers for each field in the row.Methods inherited from class org.apache.drill.exec.store.AbstractRecordReader
getColumns, getDefaultColumnsToRead, hasNext, isSkipQuery, isStarQuery, setColumns, toString, transformColumns
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_RECORDS_PER_BATCH
public static final int DEFAULT_RECORDS_PER_BATCH- See Also:
-
records
-
writers
-
-
Constructor Details
-
AbstractPojoRecordReader
-
AbstractPojoRecordReader
-
-
Method Details
-
setup
Description copied from interface:RecordReader
Configure the RecordReader with the provided schema and the record batch that should be written to.- Specified by:
setup
in interfaceRecordReader
- Parameters:
context
- operator context for the readeroutput
- The place where output for a particular scan should be written. The record reader is responsible for mutating the set of schema values for that particular record.- Throws:
ExecutionSetupException
-
next
public int next()Description copied from interface:RecordReader
Increments this record reader forward, writing via the provided output mutator into the output batch.- Specified by:
next
in interfaceRecordReader
- Returns:
- The number of additional records added to the output.
-
allocate
- Specified by:
allocate
in interfaceRecordReader
- Overrides:
allocate
in classAbstractRecordReader
- Throws:
OutOfMemoryException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
iterator
-
initWriter
protected PojoWriter initWriter(Class<?> type, String fieldName, OutputMutator output) throws ExecutionSetupException Creates writer based input class type and then initiates it.- Parameters:
type
- class typefieldName
- field nameoutput
- output mutator- Returns:
- pojo writer
- Throws:
ExecutionSetupException
-
setupWriters
protected abstract List<PojoWriter> setupWriters(OutputMutator output) throws ExecutionSetupException Setups writers for each field in the row.- Parameters:
output
- output mutator- Returns:
- list of pojo writers
- Throws:
ExecutionSetupException
-
getFieldValue
Retrieves field value to be written based for given row and field position.- Parameters:
row
- current rowfieldPosition
- current field position- Returns:
- field value to be written for given row
-