public abstract class AbstractArrayWriter extends Object implements ArrayWriter, WriterEvents
This class represents the array as a whole. In practice that means building the offset vector. The array is associated with an element object that manages writing to the scalar, array or tuple that is the array element. Note that this representation makes little use of the methods in the "Repeated" vector class: instead it works directly with the offset and element vectors.
An array has a one-to-many relationship with its children. Starting an array prepares for writing the first element. Each element must be saved by calling endValue(). This is done automatically for scalars (since there is exactly one value per element), but must be done via the client code for arrays of arrays or tuples. Valid state transitions:
Public API | Array Event | Offset Event | Element Event |
---|---|---|---|
startBatch() | startWrite() | startWrite() | startWrite() |
start() (new row) | startRow() | startRow() | startRow() |
start() (without save) | restartRow() | restartRow() | restartRow() |
save() (array) | saveValue() | saveValue() | saveValue() |
save() (row) | See subclasses. | ||
harvest() | endWrite() | endWrite() | endWrite() |
ArrayWriter.save()
on the array.
Without this call, the element value is discarded. This is necessary
because the array always has an active element: no "startElement"
method is necessary. This also means that any unsaved element values
can be discarded simply by omitting a call to save().WriterEvents.saveRow()
does not call saveValue(). This
is an important distinction between an array and a tuple.Modifier and Type | Class and Description |
---|---|
class |
AbstractArrayWriter.ArrayElementWriterIndex
Index into the vector of elements for a repeated vector.
|
static class |
AbstractArrayWriter.ArrayObjectWriter
Object representation of an array writer.
|
static class |
AbstractArrayWriter.BaseArrayWriter |
WriterEvents.ColumnWriterListener, WriterEvents.State
Modifier and Type | Field and Description |
---|---|
protected AbstractArrayWriter.ArrayElementWriterIndex |
elementIndex |
protected AbstractObjectWriter |
elementObjWriter |
protected OffsetVectorWriter |
offsetsWriter |
protected ColumnWriterIndex |
outerIndex |
Constructor and Description |
---|
AbstractArrayWriter(ColumnMetadata schema,
AbstractObjectWriter elementObjWriter,
OffsetVectorWriter offsetVectorWriter) |
Modifier and Type | Method and Description |
---|---|
ArrayWriter |
array() |
void |
bindListener(WriterEvents.ColumnWriterListener listener)
Bind a listener to the underlying vector writer.
|
void |
copy(ColumnReader from)
Copy a single value from the given reader, which must be of the
same type as this writer.
|
DictWriter |
dict() |
void |
dump(HierarchicalFormatter format) |
ObjectWriter |
entry()
The object type of the list entry.
|
ObjectType |
entryType()
Return a generic object writer for the array entry.
|
boolean |
isProjected()
Whether this writer is projected (is backed by a materialized vector),
or is unprojected (is just a dummy writer.) In most cases, clients can
ignore whether the column is projected and just write to the writer.
|
int |
lastWriteIndex()
Return the last write position in the vector.
|
boolean |
nullable()
Whether this writer allows nulls.
|
OffsetVectorWriter |
offsetWriter()
Return the writer for the offset vector for this array.
|
int |
rowStartIndex()
Position within the vector of the first value for the current row.
|
ScalarWriter |
scalar() |
ColumnMetadata |
schema()
Returns the schema of the column associated with this writer.
|
void |
setNull()
Set the current value to null.
|
void |
setNull(boolean isNull) |
int |
size()
Number of elements written thus far to the array.
|
TupleWriter |
tuple() |
ObjectType |
type()
Return the object (structure) type of this writer.
|
VariantWriter |
variant() |
int |
writeIndex()
Current write index for the writer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
save
setObject
bindIndex, endArrayValue, endWrite, postRollover, preRollover, restartRow, saveRow, startRow, startWrite
protected AbstractObjectWriter elementObjWriter
protected final OffsetVectorWriter offsetsWriter
protected ColumnWriterIndex outerIndex
protected AbstractArrayWriter.ArrayElementWriterIndex elementIndex
public AbstractArrayWriter(ColumnMetadata schema, AbstractObjectWriter elementObjWriter, OffsetVectorWriter offsetVectorWriter)
public void bindListener(WriterEvents.ColumnWriterListener listener)
WriterEvents
bindListener
in interface WriterEvents
listener
- the vector event listener to bindpublic ObjectType type()
ColumnWriter
type
in interface ColumnWriter
public ObjectType entryType()
ArrayWriter
entryType
in interface ArrayWriter
public ColumnMetadata schema()
ColumnWriter
schema
in interface ColumnWriter
public ObjectWriter entry()
ArrayWriter
entry
in interface ArrayWriter
public ScalarWriter scalar()
scalar
in interface ArrayWriter
public TupleWriter tuple()
tuple
in interface ArrayWriter
public ArrayWriter array()
array
in interface ArrayWriter
public VariantWriter variant()
variant
in interface ArrayWriter
public DictWriter dict()
dict
in interface ArrayWriter
public int size()
ArrayWriter
size
in interface ArrayWriter
public boolean nullable()
ColumnWriter
TypeProtos.DataMode.OPTIONAL
type in the schema. List entries
are nullable, if they are primitive, but not if they are maps or lists.
Unions are nullable, regardless of cardinality.nullable
in interface ColumnWriter
ColumnWriter.setNull()
is supported, false
if notpublic boolean isProjected()
ColumnWriter
isProjected
in interface ColumnWriter
public void setNull()
ColumnWriter
setNull
in interface ColumnWriter
public int rowStartIndex()
WriterPosition
rowStartIndex
in interface WriterPosition
public int lastWriteIndex()
WriterPosition
lastWriteIndex
in interface WriterPosition
public int writeIndex()
WriterPosition
writeIndex
in interface WriterPosition
public void setNull(boolean isNull)
setNull
in interface ArrayWriter
public void copy(ColumnReader from)
ColumnWriter
copy
in interface ColumnWriter
from
- reader to provide the datapublic OffsetVectorWriter offsetWriter()
public void dump(HierarchicalFormatter format)
dump
in interface WriterEvents
Copyright © 1970 The Apache Software Foundation. All rights reserved.