Class ArrayReaderImpl
java.lang.Object
org.apache.drill.exec.vector.accessor.reader.ArrayReaderImpl
- All Implemented Interfaces:
ArrayReader
,ColumnReader
,ReaderEvents
- Direct Known Subclasses:
DictReaderImpl
Reader for an array-valued column. This reader provides access to specific
array members via an array index. This class implements all arrays. The
behavior for specific array types (scalar, map, lists, etc.) is provided
through composition.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Object representation of an array reader.static class
Index into the vector of elements for a repeated vector. -
Field Summary
Modifier and TypeFieldDescriptionprotected ArrayReaderImpl.ElementReaderIndex
protected final AbstractObjectReader
protected NullStateReader
-
Constructor Summary
ConstructorDescriptionArrayReaderImpl
(ColumnMetadata schema, VectorAccessor va, AbstractObjectReader elementReader) -
Method Summary
Modifier and TypeMethodDescriptionarray()
void
void
bindIndex
(ColumnReaderIndex index) void
bindNullState
(NullStateReader nullStateReader) static AbstractObjectReader
buildList
(ColumnMetadata schema, VectorAccessor listAccessor, AbstractObjectReader elementReader) Build a list reader.static AbstractObjectReader
buildRepeatedList
(ColumnMetadata schema, VectorAccessor listAccessor, AbstractObjectReader elementReader) Build a 2+D array reader.buildScalar
(ColumnMetadata schema, VectorAccessor arrayAccessor, BaseScalarReader elementReader) Build a scalar array for a Repeated type.static AbstractObjectReader
buildTuple
(ColumnMetadata schema, VectorAccessor arrayAccessor, AbstractObjectReader elementReader) Build a repeated map reader.entry()
Return the generic object reader for the array element.The object type of the list entry.Return the entire object as a string.Return the value of the underlying data as a Java object.boolean
isNull()
Determine if this value is null.boolean
next()
Move forward one position.void
void
rewind()
scalar()
schema()
void
setPosn
(int posn) Set the array reader to read a given array entry.int
size()
Number of elements in the array.tuple()
type()
The type of this reader.variant()
-
Field Details
-
elementReader
-
elementIndex
-
nullStateReader
-
-
Constructor Details
-
ArrayReaderImpl
public ArrayReaderImpl(ColumnMetadata schema, VectorAccessor va, AbstractObjectReader elementReader)
-
-
Method Details
-
buildScalar
public static ArrayReaderImpl.ArrayObjectReader buildScalar(ColumnMetadata schema, VectorAccessor arrayAccessor, BaseScalarReader elementReader) Build a scalar array for a Repeated type. Such arrays are not nullable.- Parameters:
arrayAccessor
- vector accessor for the repeated vector that holds the scalar valueselementReader
- scalar reader used to decode each scalar value- Returns:
- object reader which wraps the scalar array reader
-
buildTuple
public static AbstractObjectReader buildTuple(ColumnMetadata schema, VectorAccessor arrayAccessor, AbstractObjectReader elementReader) Build a repeated map reader.- Parameters:
arrayAccessor
- vector accessor for the repeated map vectorelementReader
- tuple reader that provides access to each tuple in the array- Returns:
- object reader that wraps the map array reader
-
buildList
public static AbstractObjectReader buildList(ColumnMetadata schema, VectorAccessor listAccessor, AbstractObjectReader elementReader) Build a list reader. Lists entries can be null. The reader can be a simple scalar, a map, a union, or another list.- Parameters:
listAccessor
-elementReader
-- Returns:
-
buildRepeatedList
public static AbstractObjectReader buildRepeatedList(ColumnMetadata schema, VectorAccessor listAccessor, AbstractObjectReader elementReader) Build a 2+D array reader. The backing vector must be a repeated list. The element reader must itself be a repeated list, or a repeated of some other type.- Parameters:
schema
-listAccessor
-elementReader
-- Returns:
-
bindIndex
- Specified by:
bindIndex
in interfaceReaderEvents
-
bindNullState
- Specified by:
bindNullState
in interfaceReaderEvents
-
type
Description copied from interface:ColumnReader
The type of this reader.- Specified by:
type
in interfaceColumnReader
- Returns:
- type of reader
-
schema
- Specified by:
schema
in interfaceColumnReader
-
nullStateReader
- Specified by:
nullStateReader
in interfaceReaderEvents
-
isNull
public boolean isNull()Description copied from interface:ColumnReader
Determine if this value is null.- Nullable scalar: determine if the value is null.
- Non-nullable scalar: always returns false.
- Arrays: always returns false</tt.>
- Lists: determine if the list for the current row is null. In a list, an array entry can be null, empty, or can contain items. In repeated types, the array itself is never null. If the array is null, then it implicitly has no entries.
- Map or Repeated Map: Always returns false.
- Map inside a union, or in a list that contains a union, the tuple itself can be null.
- Union: Determine if the current value is null. Null values have no type and no associated reader.
- Specified by:
isNull
in interfaceColumnReader
- Returns:
- true if this value is null; false otherwise
-
reposition
public void reposition()- Specified by:
reposition
in interfaceReaderEvents
-
next
public boolean next()Description copied from interface:ArrayReader
Move forward one position.- Specified by:
next
in interfaceArrayReader
- Returns:
- true if another position is available, false if the end of the array is reached
-
elementIndex
-
size
public int size()Description copied from interface:ArrayReader
Number of elements in the array.- Specified by:
size
in interfaceArrayReader
- Returns:
- the number of elements
-
setPosn
public void setPosn(int posn) Description copied from interface:ArrayReader
Set the array reader to read a given array entry. Not used for scalars, only for maps and arrays when using the non-indexed methodsArrayReader.entry()
,ArrayReader.tuple()
andArrayReader.array()
.- Specified by:
setPosn
in interfaceArrayReader
-
rewind
public void rewind()- Specified by:
rewind
in interfaceArrayReader
-
bindBuffer
public void bindBuffer()- Specified by:
bindBuffer
in interfaceReaderEvents
-
entry
Description copied from interface:ArrayReader
Return the generic object reader for the array element. This version does not position the reader, the client must callArrayReader.setPosn(int)
to set the position. This form allows up-front setup of the readers when convenient for the caller.- Specified by:
entry
in interfaceArrayReader
-
entryType
Description copied from interface:ArrayReader
The object type of the list entry. All entries have the same type.- Specified by:
entryType
in interfaceArrayReader
- Returns:
- the object type of each entry
-
scalar
- Specified by:
scalar
in interfaceArrayReader
-
tuple
- Specified by:
tuple
in interfaceArrayReader
-
array
- Specified by:
array
in interfaceArrayReader
-
variant
- Specified by:
variant
in interfaceArrayReader
-
getObject
Description copied from interface:ColumnReader
Return the value of the underlying data as a Java object. Primarily for testing- Array: Return the entire array as an List of objects. Note, even if the array is scalar, the elements are still returned as a list.
- Specified by:
getObject
in interfaceColumnReader
- Returns:
- the value as a Java object
-
getAsString
Description copied from interface:ColumnReader
Return the entire object as a string. Primarily for debugging.- Specified by:
getAsString
in interfaceColumnReader
- Returns:
- string representation of the object
-