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
FieldsFields inherited from class org.apache.drill.exec.store.AbstractRecordReader
DEFAULT_TEXT_COLS_TO_READFields inherited from interface org.apache.drill.exec.store.RecordReader
ALLOCATOR_INITIAL_RESERVATION, ALLOCATOR_MAX_RESERVATION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPojoRecordReader(List<T> records) protectedAbstractPojoRecordReader(List<T> records, int recordsPerBatch) -
Method Summary
Modifier and TypeMethodDescriptionvoidallocate(Map<String, ValueVector> vectorMap) voidclose()protected abstract ObjectgetFieldValue(T row, int fieldPosition) Retrieves field value to be written based for given row and field position.protected PojoWriterinitWriter(Class<?> type, String fieldName, OutputMutator output) Creates writer based input class type and then initiates it.iterator()intnext()Increments this record reader forward, writing via the provided output mutator into the output batch.voidsetup(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, transformColumnsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:RecordReaderConfigure the RecordReader with the provided schema and the record batch that should be written to.- Specified by:
setupin 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:RecordReaderIncrements this record reader forward, writing via the provided output mutator into the output batch.- Specified by:
nextin interfaceRecordReader- Returns:
- The number of additional records added to the output.
-
allocate
- Specified by:
allocatein interfaceRecordReader- Overrides:
allocatein classAbstractRecordReader- Throws:
OutOfMemoryException
-
close
public void close()- Specified by:
closein 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
-