Package org.apache.arrow.vector.complex
Class AbstractStructVector
java.lang.Object
org.apache.arrow.vector.complex.AbstractContainerVector
org.apache.arrow.vector.complex.AbstractStructVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,DensityAwareVector
,ValueVector
- Direct Known Subclasses:
NonNullableStructVector
Base class for StructVectors. Currently used by NonNullableStructVector
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Policy to determine how to react when duplicate columns are encountered. -
Field Summary
Fields inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
allocator, callBack, name
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractStructVector
(String name, BufferAllocator allocator, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Base constructor that sets default conflict policy to APPEND. -
Method Summary
Modifier and TypeMethodDescriptionprotected ValueVector
<T extends FieldVector>
TAdds a new field with the given parameters or replaces the existing one and consequently returns the resultantValueVector
.boolean
Allocates new buffers.void
close()
Clears out all underlying child vectors.ArrowBuf[]
getBuffers
(boolean clear) Return the underlying buffers associated with this vector.int
Get the number of bytes used by this vector.<T extends FieldVector>
TReturns aValueVector
instance of subtype of T corresponding to the given field name if exists or null.getChildByOrdinal
(int id) Returns aValueVector
corresponding to the given ordinal identifier.Get child field names.protected List<FieldVector>
Get child vectors.Get a child vector by name.Get primitive child vectors.iterator()
protected void
putChild
(String name, FieldVector vector) Inserts the vector with the given name if it does not exist else replaces it with the new value.protected void
putVector
(String name, FieldVector vector) Inserts the input vector into the map if it does not exist.void
reAlloc()
Allocate new buffer with double capacity, and copy data into the new buffer.setConflictPolicy
(AbstractStructVector.ConflictPolicy conflictPolicy) Set conflict policy and return last conflict policy state.int
size()
Get the number of child vectors.toString()
Representation of vector suitable for debugging.Methods inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
addOrGetFixedSizeList, addOrGetList, addOrGetMap, addOrGetStruct, addOrGetUnion, allocateNew, copyFrom, copyFromSafe, getAllocator, getChild, getName, supportsDirectRead, typeify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.arrow.vector.DensityAwareVector
setInitialCapacity
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.apache.arrow.vector.ValueVector
accept, clear, getBufferSizeFor, getDataBuffer, getField, getMinorType, getNullCount, getObject, getOffsetBuffer, getReader, getTransferPair, getTransferPair, getTransferPair, getTransferPair, getTransferPair, getValidityBuffer, getValueCapacity, getValueCount, hashCode, hashCode, isNull, makeTransferPair, reset, setInitialCapacity, setValueCount, validate, validateFull
-
Field Details
-
allowConflictPolicyChanges
protected final boolean allowConflictPolicyChanges
-
-
Constructor Details
-
AbstractStructVector
protected AbstractStructVector(String name, BufferAllocator allocator, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Base constructor that sets default conflict policy to APPEND.
-
-
Method Details
-
setConflictPolicy
public AbstractStructVector.ConflictPolicy setConflictPolicy(AbstractStructVector.ConflictPolicy conflictPolicy) Set conflict policy and return last conflict policy state. -
getConflictPolicy
-
close
public void close()Description copied from class:AbstractContainerVector
Clears out all underlying child vectors.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceValueVector
- Overrides:
close
in classAbstractContainerVector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVector
Allocates new buffers. ValueVector implements logic to determine how much to allocate.- Returns:
- Returns true if allocation was successful.
-
reAlloc
public void reAlloc()Description copied from interface:ValueVector
Allocate new buffer with double capacity, and copy data into the new buffer. Replace vector's buffer with new buffer, and release old one -
addOrGet
Adds a new field with the given parameters or replaces the existing one and consequently returns the resultantValueVector
.Execution takes place in the following order:
- if field is new, create and insert a new vector of desired type.
- if field exists and existing vector is of desired vector type, return the vector.
- if field exists and null filled, clear the existing vector; create and insert a new vector of desired type.
- otherwise, throw an
IllegalStateException
- Specified by:
addOrGet
in classAbstractContainerVector
- Type Parameters:
T
- class type of expected vector type- Parameters:
childName
- the name of the fieldfieldType
- the type for the vectorclazz
- class of expected vector type- Returns:
- resultant
ValueVector
- Throws:
IllegalStateException
- raised if there is a hard schema change
-
getChildByOrdinal
Returns aValueVector
corresponding to the given ordinal identifier.- Parameters:
id
- the ordinal of the child to return- Returns:
- the corresponding child
-
getChild
Returns aValueVector
instance of subtype of T corresponding to the given field name if exists or null.If there is more than one element for name this will return the first inserted.
- Specified by:
getChild
in classAbstractContainerVector
- Parameters:
name
- the name of the child to returnclazz
- the expected type of the child- Returns:
- the child corresponding to this name
-
add
-
putChild
Inserts the vector with the given name if it does not exist else replaces it with the new value.Note that this method does not enforce any vector type check nor throws a schema change exception.
- Parameters:
name
- the name of the child to addvector
- the vector to add as a child
-
putVector
Inserts the input vector into the map if it does not exist.If the field name already exists the conflict is handled according to the currently set ConflictPolicy
- Parameters:
name
- field namevector
- vector to be inserted
-
getChildren
Get child vectors.- Returns:
- a sequence of underlying child vectors.
-
getChildFieldNames
Get child field names. -
size
public int size()Get the number of child vectors.- Specified by:
size
in classAbstractContainerVector
- Returns:
- the number of underlying child vectors.
-
iterator
-
getPrimitiveVectors
Get primitive child vectors.- Returns:
- a list of scalar child vectors recursing the entire vector hierarchy.
-
getChildVectorWithOrdinal
Get a child vector by name. If duplicate names this returns the first inserted.- Specified by:
getChildVectorWithOrdinal
in classAbstractContainerVector
- Parameters:
name
- the name of the child to return- Returns:
- a vector with its corresponding ordinal mapping if field exists or null.
-
getBuffers
Description copied from interface:ValueVector
Return the underlying buffers associated with this vector. Note that this doesn't impact the reference counts for this buffer so it only should be used for in-context access. Also note that this buffer changes regularly thus external classes shouldn't hold a reference to it (unless they change it).- Parameters:
clear
- Whether to clear vector before returning; the buffers will still be refcounted; but the returned array will be the only reference to them- Returns:
- The underlying
buffers
that is used by this vector instance.
-
getBufferSize
public int getBufferSize()Description copied from interface:ValueVector
Get the number of bytes used by this vector.- Returns:
- the number of bytes that is used by this vector instance.
-
toString
Description copied from class:AbstractContainerVector
Representation of vector suitable for debugging.- Overrides:
toString
in classAbstractContainerVector
-