Class RowSetWriterImpl
java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractTupleWriter
org.apache.drill.exec.physical.rowSet.RowSetWriterImpl
- All Implemented Interfaces:
RowSetWriter
,ColumnWriter
,TupleWriter
,WriterEvents
,WriterPosition
Implementation of a row set writer. Only available for newly-created,
empty, direct, single row sets. Rewriting is not allowed, nor is writing
to a hyper row set.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractTupleWriter
AbstractTupleWriter.TupleObjectWriter, AbstractTupleWriter.TupleWriterListener
Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.accessor.TupleWriter
TupleWriter.UndefinedColumnException
Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.accessor.writer.WriterEvents
WriterEvents.ColumnWriterListener, WriterEvents.State
-
Field Summary
Fields inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractTupleWriter
childIndex, listener, logger, state, tupleSchema, vectorIndex, writers
-
Constructor Summary
ModifierConstructorDescriptionprotected
RowSetWriterImpl
(RowSet.ExtendableRowSet rowSet, TupleMetadata schema, org.apache.drill.exec.physical.rowSet.RowSetWriterImpl.WriterIndexImpl index, List<AbstractObjectWriter> writers) -
Method Summary
Modifier and TypeMethodDescriptionWrite a row of values, given by Java objects.addSingleCol
(Object value) done()
Finish writing and finalize the row set being written.boolean
isFull()
Indicates if the current row position is valid for writing.int
Return the last write position in the vector.int
rowIndex()
void
save()
Saves the current row and moves to the next row.schema()
Returns the schema of the column associated with this writer.Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractTupleWriter
addColumn, addColumn, addColumnWriter, array, array, bindIndex, bindIndex, bindListener, bindListener, column, column, copy, dict, dict, dump, endArrayValue, endWrite, isProjected, isProjected, listener, nullable, postRollover, preRollover, restartRow, rowStartIndex, saveRow, scalar, scalar, set, setNull, setObject, size, startRow, startWrite, tuple, tuple, tupleSchema, type, type, type, variant, variant, writeIndex
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.vector.accessor.ColumnWriter
copy, isProjected, nullable, setNull, setObject, type
-
Constructor Details
-
RowSetWriterImpl
protected RowSetWriterImpl(RowSet.ExtendableRowSet rowSet, TupleMetadata schema, org.apache.drill.exec.physical.rowSet.RowSetWriterImpl.WriterIndexImpl index, List<AbstractObjectWriter> writers)
-
-
Method Details
-
addRow
Description copied from interface:RowSetWriter
Write a row of values, given by Java objects. Object type must match expected column type. Stops writing, and returns false, if any value causes vector overflow. Value format:- For scalars, the value as a suitable Java type (int or Integer, say, for INTEGER values.)
- For scalar arrays, an array of a suitable Java primitive type for scalars. For example, int[] for an INTEGER column.
- For a Map, an Object array with values encoded as above. (In fact, the list here is the same as the map format.
- For a list (repeated map, list of list), an Object array with values encoded as above. (So, for a repeated map, an outer Object map encodes the array, an inner one encodes the map members.
- Specified by:
addRow
in interfaceRowSetWriter
- Parameters:
values
- variable-length argument list of column values
-
addSingleCol
- Specified by:
addSingleCol
in interfaceRowSetWriter
-
rowIndex
public int rowIndex()- Specified by:
rowIndex
in interfaceRowSetWriter
-
save
public void save()Description copied from interface:RowSetWriter
Saves the current row and moves to the next row. Done automatically if using setRow().- Specified by:
save
in interfaceRowSetWriter
-
isFull
public boolean isFull()Description copied from interface:RowSetWriter
Indicates if the current row position is valid for writing. Will be false on the first row, and all subsequent rows until either the maximum number of rows are written, or a vector overflows. After that, will return true. The method returns false as soon as any column writer overflows even in the middle of a row write. That is, this writer does not automatically handle overflow rows because that added complexity is seldom needed for tests.- Specified by:
isFull
in interfaceRowSetWriter
- Returns:
- true if the current row can be written, false if not
-
done
Description copied from interface:RowSetWriter
Finish writing and finalize the row set being written.- Specified by:
done
in interfaceRowSetWriter
- Returns:
- the completed, read-only row set without a selection vector
-
lastWriteIndex
public int lastWriteIndex()Description copied from interface:WriterPosition
Return the last write position in the vector. This may be the same as the writer index position (if the vector was written at that point), or an earlier point. In either case, this value points to the last valid value in the vector.- Specified by:
lastWriteIndex
in interfaceWriterPosition
- Overrides:
lastWriteIndex
in classAbstractTupleWriter
- Returns:
- index of the last valid value in the vector
-
schema
Description copied from interface:ColumnWriter
Returns the schema of the column associated with this writer.- Specified by:
schema
in interfaceColumnWriter
- Returns:
- schema for this writer's column
-