Package org.apache.arrow.vector.complex
Class StructVector
java.lang.Object
org.apache.arrow.vector.complex.AbstractContainerVector
org.apache.arrow.vector.complex.AbstractStructVector
org.apache.arrow.vector.complex.NonNullableStructVector
org.apache.arrow.vector.complex.StructVector
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<ValueVector>,DensityAwareVector,FieldVector,ValueIterableVector<Map<String,,?>> ValueVector
public class StructVector
extends NonNullableStructVector
implements FieldVector, ValueIterableVector<Map<String,?>>
A Struct vector consists of nullability/validity buffer and children vectors that make up the
struct's fields. The children vectors are handled by the parent class.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.arrow.vector.complex.NonNullableStructVector
NonNullableStructVector.StructTransferPairNested classes/interfaces inherited from class org.apache.arrow.vector.complex.AbstractStructVector
AbstractStructVector.ConflictPolicy -
Field Summary
FieldsFields inherited from class org.apache.arrow.vector.complex.NonNullableStructVector
field, valueCountFields inherited from class org.apache.arrow.vector.complex.AbstractStructVector
allowConflictPolicyChangesFields inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
allocator, callBack, name -
Constructor Summary
ConstructorsConstructorDescriptionStructVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) Constructs a new instance.StructVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Constructs a new instance.StructVector(Field field, BufferAllocator allocator, CallBack callBack) Constructs a new instance.StructVector(Field field, BufferAllocator allocator, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAllocates new buffers.voidclear()Same asclose().voidclose()Close the vector and release the associated buffers.static StructVectorempty(String name, BufferAllocator allocator) Construct a new empty instance which replaces an existing field with the new one in case of name conflict.static StructVectoremptyWithDuplicates(String name, BufferAllocator allocator) Construct a new empty instance which preserve fields with identical names.voidget(int index, ComplexHolder holder) ArrowBuf[]getBuffers(boolean clear) Return the underlying buffers associated with this vector.intGet the size (number of bytes) of underlying buffers used by this vector.intgetBufferSizeFor(int valueCount) Get the potential buffer size for a particular number of records.Gets the underlying buffer associated with data vector.longGets the starting address of the underlying buffer associated with data vector.Get the buffers of the fields, (same size as getFieldVectors() since it is their content).Deprecated.This API will be removed as the current implementations no longer support inner vectors.intReturn the number of null values in the vector.getObject(int index) Get friendly type object from the vector.Gets the underlying buffer associated with offset vector.longGets the starting address of the underlying buffer associated with offset vector.Get a reader for this vector.getTransferPair(String ref, BufferAllocator allocator) To transfer quota responsibility.getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) To transfer quota responsibility.getTransferPair(BufferAllocator allocator) To transfer quota responsibility.getTransferPair(Field field, BufferAllocator allocator) To transfer quota responsibility.getTransferPair(Field field, BufferAllocator allocator, CallBack callBack) To transfer quota responsibility.Gets the underlying buffer associated with validity vector.longGets the starting address of the underlying buffer associated with validity vector.intGet the current value capacity for the vector.inthashCode(int index) Returns hashCode of element in index with the default hasher.inthashCode(int index, ArrowBufHasher hasher) Returns hashCode of element in index with the given hasher.booleanisNull(int index) Returns true if the value at the provided index is null.intisSet(int index) Returns true the value at the given index is set (i.e.voidloadFieldBuffers(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers) Loads data in the vectors.Makes a new transfer pair used to transfer underlying buffers.voidreAlloc()Allocate new buffer with double capacity, and copy data into the new buffer.voidreset()Reset this vector to empty, does not release buffers.voidsetIndexDefined(int index) Marks the value at index as being set.voidsetInitialCapacity(int numRecords) Set the initial record capacity.voidsetInitialCapacity(int numRecords, double density) Set value with density.voidsetNull(int index) Marks the value at index as null/not set.voidsetValueCount(int valueCount) Set number of values in the vector.Methods inherited from class org.apache.arrow.vector.complex.NonNullableStructVector
accept, copyFrom, copyFromSafe, fieldNameIterator, getChildrenFromFields, getField, getMinorType, getValueCount, getVectorById, getVectorById, initializeChildrenFromFields, supportsDirectReadMethods inherited from class org.apache.arrow.vector.complex.AbstractStructVector
add, addOrGet, getChild, getChildByOrdinal, getChildFieldNames, getChildren, getChildVectorWithOrdinal, getConflictPolicy, getPrimitiveVectors, iterator, putChild, putVector, setConflictPolicy, size, toStringMethods inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
addOrGetFixedSizeList, addOrGetList, addOrGetMap, addOrGetStruct, addOrGetUnion, allocateNew, getAllocator, getChild, getName, typeifyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.arrow.vector.FieldVector
exportBuffer, exportCDataBuffers, getChildrenFromFields, getExportedCDataBufferCount, initializeChildrenFromFieldsMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface org.apache.arrow.vector.ValueIterableVector
getValueIterable, getValueIteratorMethods inherited from interface org.apache.arrow.vector.ValueVector
accept, allocateNew, copyFrom, copyFromSafe, getAllocator, getField, getMinorType, getName, getValueCount, validate, validateFull
-
Field Details
-
validityBuffer
-
-
Constructor Details
-
StructVector
Constructs a new instance.- Parameters:
name- The name of the instance.allocator- The allocator to use to allocating/reallocating buffers.fieldType- The type of this list.callBack- A schema change callback.
-
StructVector
public StructVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Constructs a new instance.- Parameters:
name- The name of the instance.allocator- The allocator to use to allocating/reallocating buffers.fieldType- The type of this list.callBack- A schema change callback.conflictPolicy- policy to determine how duplicate names are handled.allowConflictPolicyChanges- whether duplicate names are allowed at all.
-
StructVector
Constructs a new instance.- Parameters:
field- The field materialized by this vector.allocator- The allocator to use to allocating/reallocating buffers.callBack- A schema change callback.
-
StructVector
public StructVector(Field field, BufferAllocator allocator, CallBack callBack, AbstractStructVector.ConflictPolicy conflictPolicy, boolean allowConflictPolicyChanges) Constructs a new instance.- Parameters:
field- The field materialized by this vector.allocator- The allocator to use to allocating/reallocating buffers.callBack- A schema change callback.conflictPolicy- policy to determine how duplicate names are handled.allowConflictPolicyChanges- whether duplicate names are allowed at all.
-
-
Method Details
-
empty
Construct a new empty instance which replaces an existing field with the new one in case of name conflict. -
emptyWithDuplicates
Construct a new empty instance which preserve fields with identical names. -
loadFieldBuffers
Description copied from interface:FieldVectorLoads data in the vectors. (ownBuffers must be the same size as getFieldVectors())- Specified by:
loadFieldBuffersin interfaceFieldVector- Parameters:
fieldNode- the fieldNodeownBuffers- the buffers for this Field (own buffers only, children not included)
-
getFieldBuffers
Description copied from interface:FieldVectorGet the buffers of the fields, (same size as getFieldVectors() since it is their content).- Specified by:
getFieldBuffersin interfaceFieldVector- Returns:
- the buffers containing the data for this vector (ready for reading)
-
getFieldInnerVectors
Deprecated.This API will be removed as the current implementations no longer support inner vectors.Get the inner vectors.- Specified by:
getFieldInnerVectorsin interfaceFieldVector- Returns:
- the inner vectors for this field as defined by the TypeLayout
-
getReader
Description copied from interface:ValueVectorGet a reader for this vector.- Specified by:
getReaderin interfaceValueVector- Overrides:
getReaderin classNonNullableStructVector- Returns:
- a
field readerthat supports reading values from this vector.
-
getWriter
-
getTransferPair
Description copied from interface:ValueVectorTo transfer quota responsibility.- Specified by:
getTransferPairin interfaceValueVector- Overrides:
getTransferPairin classNonNullableStructVector- Parameters:
allocator- the target allocator- Returns:
- a
transfer pair, creating a new target vector of the same type.
-
makeTransferPair
Description copied from interface:ValueVectorMakes a new transfer pair used to transfer underlying buffers.- Specified by:
makeTransferPairin interfaceValueVector- Overrides:
makeTransferPairin classNonNullableStructVector- Parameters:
to- the target for the transfer- Returns:
- a new
transfer pairthat is used to transfer underlying buffers into the target vector.
-
getTransferPair
Description copied from interface:ValueVectorTo transfer quota responsibility.- Specified by:
getTransferPairin interfaceValueVector- Overrides:
getTransferPairin classNonNullableStructVector- Parameters:
ref- the name of the vectorallocator- the target allocator- Returns:
- a
transfer pair, creating a new target vector of the same type.
-
getTransferPair
Description copied from interface:ValueVectorTo transfer quota responsibility.- Specified by:
getTransferPairin interfaceValueVector- Overrides:
getTransferPairin classNonNullableStructVector- Parameters:
ref- the name of the vectorallocator- the target allocatorcallBack- A schema change callback.- Returns:
- a
transfer pair, creating a new target vector of the same type.
-
getTransferPair
Description copied from interface:ValueVectorTo transfer quota responsibility.- Specified by:
getTransferPairin interfaceValueVector- Overrides:
getTransferPairin classNonNullableStructVector- Parameters:
field- the Field object used by the target vectorallocator- the target allocator- Returns:
- a
transfer pair, creating a new target vector of the same type.
-
getTransferPair
Description copied from interface:ValueVectorTo transfer quota responsibility.- Specified by:
getTransferPairin interfaceValueVector- Overrides:
getTransferPairin classNonNullableStructVector- Parameters:
field- the Field object used by the target vectorallocator- the target allocatorcallBack- A schema change callback.- Returns:
- a
transfer pair, creating a new target vector of the same type.
-
getValueCapacity
public int getValueCapacity()Get the current value capacity for the vector.- Specified by:
getValueCapacityin interfaceValueVector- Overrides:
getValueCapacityin classNonNullableStructVector- Returns:
- number of elements that vector can hold.
-
getBuffers
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).- Specified by:
getBuffersin interfaceValueVector- Overrides:
getBuffersin classAbstractStructVector- 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
buffersthat is used by this vector instance.
-
close
public void close()Close the vector and release the associated buffers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceValueVector- Overrides:
closein classNonNullableStructVector
-
clear
public void clear()Same asclose().- Specified by:
clearin interfaceValueVector- Overrides:
clearin classNonNullableStructVector
-
reset
public void reset()Reset this vector to empty, does not release buffers.- Specified by:
resetin interfaceValueVector- Overrides:
resetin classNonNullableStructVector
-
getBufferSize
public int getBufferSize()Get the size (number of bytes) of underlying buffers used by this vector.- Specified by:
getBufferSizein interfaceValueVector- Overrides:
getBufferSizein classNonNullableStructVector- Returns:
- size of underlying buffers.
-
getBufferSizeFor
public int getBufferSizeFor(int valueCount) Get the potential buffer size for a particular number of records.- Specified by:
getBufferSizeForin interfaceValueVector- Overrides:
getBufferSizeForin classNonNullableStructVector- Parameters:
valueCount- desired number of elements in the vector- Returns:
- estimated size of underlying buffers if the vector holds a given number of elements
-
setInitialCapacity
public void setInitialCapacity(int numRecords) Description copied from interface:ValueVectorSet the initial record capacity.- Specified by:
setInitialCapacityin interfaceValueVector- Overrides:
setInitialCapacityin classNonNullableStructVector- Parameters:
numRecords- the initial record capacity.
-
setInitialCapacity
public void setInitialCapacity(int numRecords, double density) Description copied from interface:DensityAwareVectorSet value with density.- Specified by:
setInitialCapacityin interfaceDensityAwareVector- Overrides:
setInitialCapacityin classNonNullableStructVector- Parameters:
numRecords- the number of values in this vectordensity- the density of the vector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVectorAllocates new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewSafein interfaceValueVector- Overrides:
allocateNewSafein classAbstractStructVector- Returns:
- Returns true if allocation was successful.
-
reAlloc
public void reAlloc()Description copied from interface:ValueVectorAllocate new buffer with double capacity, and copy data into the new buffer. Replace vector's buffer with new buffer, and release old one- Specified by:
reAllocin interfaceValueVector- Overrides:
reAllocin classAbstractStructVector
-
getValidityBufferAddress
public long getValidityBufferAddress()Description copied from interface:FieldVectorGets the starting address of the underlying buffer associated with validity vector.- Specified by:
getValidityBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
getDataBufferAddress
public long getDataBufferAddress()Description copied from interface:FieldVectorGets the starting address of the underlying buffer associated with data vector.- Specified by:
getDataBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
getOffsetBufferAddress
public long getOffsetBufferAddress()Description copied from interface:FieldVectorGets the starting address of the underlying buffer associated with offset vector.- Specified by:
getOffsetBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
getValidityBuffer
Description copied from interface:ValueVectorGets the underlying buffer associated with validity vector.- Specified by:
getValidityBufferin interfaceValueVector- Overrides:
getValidityBufferin classNonNullableStructVector- Returns:
- buffer
-
getDataBuffer
Description copied from interface:ValueVectorGets the underlying buffer associated with data vector.- Specified by:
getDataBufferin interfaceValueVector- Overrides:
getDataBufferin classNonNullableStructVector- Returns:
- buffer
-
getOffsetBuffer
Description copied from interface:ValueVectorGets the underlying buffer associated with offset vector.- Specified by:
getOffsetBufferin interfaceValueVector- Overrides:
getOffsetBufferin classNonNullableStructVector- Returns:
- buffer
-
getObject
Description copied from interface:ValueVectorGet friendly type object from the vector.- Specified by:
getObjectin interfaceValueVector- Overrides:
getObjectin classNonNullableStructVector- Parameters:
index- index of object to get- Returns:
- friendly type object
-
hashCode
public int hashCode(int index) Description copied from interface:ValueVectorReturns hashCode of element in index with the default hasher.- Specified by:
hashCodein interfaceValueVector- Overrides:
hashCodein classNonNullableStructVector
-
hashCode
Description copied from interface:ValueVectorReturns hashCode of element in index with the given hasher.- Specified by:
hashCodein interfaceValueVector- Overrides:
hashCodein classNonNullableStructVector
-
get
- Overrides:
getin classNonNullableStructVector
-
getNullCount
public int getNullCount()Return the number of null values in the vector.- Specified by:
getNullCountin interfaceValueVector- Overrides:
getNullCountin classNonNullableStructVector- Returns:
- number of null elements
-
isNull
public boolean isNull(int index) Returns true if the value at the provided index is null.- Specified by:
isNullin interfaceValueVector- Overrides:
isNullin classNonNullableStructVector- Parameters:
index- index to check for null- Returns:
- true if element is null
-
isSet
public int isSet(int index) Returns true the value at the given index is set (i.e. not null). -
setIndexDefined
public void setIndexDefined(int index) Marks the value at index as being set. Reallocates the validity buffer if index is larger than current capacity. -
setNull
public void setNull(int index) Marks the value at index as null/not set.- Specified by:
setNullin interfaceFieldVector- Parameters:
index- the value to change
-
setValueCount
public void setValueCount(int valueCount) Description copied from interface:ValueVectorSet number of values in the vector.- Specified by:
setValueCountin interfaceValueVector- Overrides:
setValueCountin classNonNullableStructVector
-