public interface RowSetWriter extends TupleWriter
Typical usage:
void writeABatch() {
RowSetWriter writer = ...
while (! writer.isFull()) {
writer.scalar(0).setInt(10);
writer.scalar(1).setString("foo");
...
writer.save();
}
}
The above writes until the batch is full, based on size. If values
are large enough to potentially cause vector overflow, do the
following instead:
void writeABatch() {
RowSetWriter writer = ...
while (! writer.isFull()) {
writer.column(0).setInt(10);
try {
writer.column(1).setString("foo");
} catch (VectorOverflowException e) { break; }
...
writer.save();
}
// Do something with the partially-written last row.
}
This writer is for testing, so no provision is available to handle a partial last row. (Elsewhere n Drill there are classes that handle that case.)
TupleWriter.UndefinedColumnException| Modifier and Type | Method and Description |
|---|---|
RowSetWriter |
addRow(Object... values)
Write a row of values, given by Java objects.
|
RowSetWriter |
addSingleCol(Object value) |
RowSet.SingleRowSet |
done()
Finish writing and finalize the row set being
written.
|
boolean |
isFull()
Indicates if the current row position is valid for
writing.
|
int |
rowIndex() |
void |
save()
Saves the current row and moves to the next row.
|
addColumn, addColumn, array, array, column, column, dict, dict, isProjected, scalar, scalar, set, size, tuple, tuple, tupleSchema, type, type, variant, variantcopy, isProjected, nullable, schema, setNull, setObject, typeRowSetWriter addRow(Object... values)
values - variable-length argument list of column valuesRowSetWriter addSingleCol(Object value)
boolean isFull()
int rowIndex()
void save()
RowSet.SingleRowSet done()
Copyright © 2021 The Apache Software Foundation. All rights reserved.