public interface TupleWriter extends ColumnWriter
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.
SingleMapWriter}, the class which this class replaces
Modifier and Type | Interface and Description |
---|---|
static class |
TupleWriter.UndefinedColumnException
Unchecked exception thrown when attempting to access a column writer by
name for an undefined columns.
|
Modifier and Type | Method and Description |
---|---|
int |
addColumn(ColumnMetadata column)
Add a column to the tuple (row or map) that backs this writer.
|
int |
addColumn(MaterializedField schema) |
ArrayWriter |
array(int colIndex) |
ArrayWriter |
array(String colName) |
ObjectWriter |
column(int colIndex) |
ObjectWriter |
column(String colName) |
DictWriter |
dict(int colIndex) |
DictWriter |
dict(String colName) |
boolean |
isProjected(String columnName)
Reports whether the given column is projected.
|
ScalarWriter |
scalar(int colIndex) |
ScalarWriter |
scalar(String colName) |
void |
set(int colIndex,
Object value)
Write a value to the given column, automatically calling the proper
setType method for the data. |
int |
size() |
TupleWriter |
tuple(int colIndex) |
TupleWriter |
tuple(String colName) |
TupleMetadata |
tupleSchema() |
ObjectType |
type(int colIndex) |
ObjectType |
type(String colName) |
VariantWriter |
variant(int colIndex) |
VariantWriter |
variant(String colName) |
copy, isProjected, nullable, schema, setNull, setObject, type
boolean isProjected(String columnName)
int addColumn(ColumnMetadata column)
column
- the metadata for the column to addint addColumn(MaterializedField schema)
TupleMetadata tupleSchema()
int size()
ObjectWriter column(int colIndex)
ObjectWriter column(String colName)
ScalarWriter scalar(int colIndex)
ScalarWriter scalar(String colName)
TupleWriter tuple(int colIndex)
TupleWriter tuple(String colName)
ArrayWriter array(int colIndex)
ArrayWriter array(String colName)
VariantWriter variant(int colIndex)
VariantWriter variant(String colName)
DictWriter dict(int colIndex)
DictWriter dict(String colName)
ObjectType type(int colIndex)
ObjectType type(String colName)
void set(int colIndex, Object value)
setType
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.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 columnCopyright © 1970 The Apache Software Foundation. All rights reserved.