Interface TupleWriter
- All Superinterfaces:
ColumnWriter
- All Known Subinterfaces:
RowSetLoader
,RowSetWriter
- All Known Implementing Classes:
AbstractTupleWriter
,DictEntryWriter
,MapWriter
,MapWriter.ArrayMapWriter
,MapWriter.DummyArrayMapWriter
,MapWriter.DummyMapWriter
,MapWriter.SingleMapWriter
,RowSetLoaderImpl
,RowSetWriterImpl
Consumers of this interface can define the schema up front, or can define the
schema as the write progresses. To avoid redundant checks to see if a column
is already defined, consumers can simply ask for a column by name. The
column()
(and related) methods will throw an (unchecked)
TupleWriter.UndefinedColumnException
exception if the column is undefined. The
consumer can catch the exception, define the column, and fetch the column
writer again. New columns may be added via this interface at any time; the
new column takes the next available index.
Also provides a convenience method to set the column value from a Java object. The caller is responsible for providing the correct object type for each column. (The object type must match the column accessor type.)
Convenience methods allow getting a column as a scalar, tuple or array. These methods throw an exception if the column is not of the requested type.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Unchecked exception thrown when attempting to access a column writer by name for an undefined columns. -
Method Summary
Modifier and TypeMethodDescriptionint
addColumn
(MaterializedField schema) int
addColumn
(ColumnMetadata column) Add a column to the tuple (row or map) that backs this writer.array
(int colIndex) column
(int colIndex) dict
(int colIndex) boolean
isProjected
(String columnName) Reports whether the given column is projected.scalar
(int colIndex) void
Write a value to the given column, automatically calling the propersetType
method for the data.int
size()
tuple
(int colIndex) type
(int colIndex) variant
(int colIndex) Methods inherited from interface org.apache.drill.exec.vector.accessor.ColumnWriter
copy, isProjected, nullable, schema, setNull, setObject, type
-
Method Details
-
isProjected
Reports whether the given column is projected. Useful for clients that can simply skip over unprojected columns. -
addColumn
Add a column to the tuple (row or map) that backs this writer. Support for this operation depends on whether the client code has registered a listener to implement the addition. Throws an exception if no listener is implemented, or if the add request is otherwise invalid (duplicate name, etc.)- Parameters:
column
- the metadata for the column to add- Returns:
- the index of the newly added column which can be used to access the newly added writer
-
addColumn
-
tupleSchema
TupleMetadata tupleSchema() -
size
int size() -
column
-
column
-
scalar
-
scalar
-
tuple
-
tuple
-
array
-
array
-
variant
-
variant
-
dict
-
dict
-
type
-
type
-
set
Write a value to the given column, automatically calling the propersetType
method for the data. While this method is convenient for testing, it incurs quite a bit of type-checking overhead and is not suitable for production code.- Parameters:
colIndex
- the index of the column to setvalue
- the value to set. The type of the object must be compatible with the type of the target column
-