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 classes/interfaces inherited from class org.apache.arrow.vector.complex.NonNullableStructVector
NonNullableStructVector.StructTransferPair
Nested classes/interfaces inherited from class org.apache.arrow.vector.complex.AbstractStructVector
AbstractStructVector.ConflictPolicy
-
Field Summary
Fields inherited from class org.apache.arrow.vector.complex.NonNullableStructVector
field, valueCount
Fields inherited from class org.apache.arrow.vector.complex.AbstractStructVector
allowConflictPolicyChanges
Fields inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
allocator, callBack, name
-
Constructor Summary
ConstructorDescriptionStructVector
(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 TypeMethodDescriptionboolean
Allocates new buffers.void
clear()
Same asclose()
.void
close()
Close the vector and release the associated buffers.static StructVector
empty
(String name, BufferAllocator allocator) Construct a new empty instance which replaces an existing field with the new one in case of name conflict.static StructVector
emptyWithDuplicates
(String name, BufferAllocator allocator) Construct a new empty instance which preserve fields with identical names.void
get
(int index, ComplexHolder holder) ArrowBuf[]
getBuffers
(boolean clear) Return the underlying buffers associated with this vector.int
Get the size (number of bytes) of underlying buffers used by this vector.int
getBufferSizeFor
(int valueCount) Get the potential buffer size for a particular number of records.Gets the underlying buffer associated with data vector.long
Gets 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.int
Return 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.long
Gets 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.long
Gets the starting address of the underlying buffer associated with validity vector.int
Get the current value capacity for the vector.int
hashCode
(int index) Returns hashCode of element in index with the default hasher.int
hashCode
(int index, ArrowBufHasher hasher) Returns hashCode of element in index with the given hasher.boolean
isNull
(int index) Returns true if the value at the provided index is null.int
isSet
(int index) Returns true the value at the given index is set (i.e.void
loadFieldBuffers
(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers) Loads data in the vectors.Makes a new transfer pair used to transfer underlying buffers.void
reAlloc()
Allocate new buffer with double capacity, and copy data into the new buffer.void
reset()
Reset this vector to empty, does not release buffers.void
setIndexDefined
(int index) Marks the value at index as being set.void
setInitialCapacity
(int numRecords) Set the initial record capacity.void
setInitialCapacity
(int numRecords, double density) Set value with density.void
setNull
(int index) Marks the value at index as null/not set.void
setValueCount
(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, supportsDirectRead
Methods inherited from class org.apache.arrow.vector.complex.AbstractStructVector
add, addOrGet, getChild, getChildByOrdinal, getChildFieldNames, getChildren, getChildVectorWithOrdinal, getConflictPolicy, getPrimitiveVectors, iterator, putChild, putVector, setConflictPolicy, size, toString
Methods inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
addOrGetFixedSizeList, addOrGetList, addOrGetMap, addOrGetStruct, addOrGetUnion, allocateNew, getAllocator, getChild, getName, 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.FieldVector
exportBuffer, exportCDataBuffers, getChildrenFromFields, getExportedCDataBufferCount, initializeChildrenFromFields
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.arrow.vector.ValueIterableVector
getValueIterable, getValueIterator
Methods 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:FieldVector
Loads data in the vectors. (ownBuffers must be the same size as getFieldVectors())- Specified by:
loadFieldBuffers
in interfaceFieldVector
- Parameters:
fieldNode
- the fieldNodeownBuffers
- the buffers for this Field (own buffers only, children not included)
-
getFieldBuffers
Description copied from interface:FieldVector
Get the buffers of the fields, (same size as getFieldVectors() since it is their content).- Specified by:
getFieldBuffers
in 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:
getFieldInnerVectors
in interfaceFieldVector
- Returns:
- the inner vectors for this field as defined by the TypeLayout
-
getReader
Description copied from interface:ValueVector
Get a reader for this vector.- Specified by:
getReader
in interfaceValueVector
- Overrides:
getReader
in classNonNullableStructVector
- Returns:
- a
field reader
that supports reading values from this vector.
-
getWriter
-
getTransferPair
Description copied from interface:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in classNonNullableStructVector
- Parameters:
allocator
- the target allocator- Returns:
- a
transfer pair
, creating a new target vector of the same type.
-
makeTransferPair
Description copied from interface:ValueVector
Makes a new transfer pair used to transfer underlying buffers.- Specified by:
makeTransferPair
in interfaceValueVector
- Overrides:
makeTransferPair
in classNonNullableStructVector
- Parameters:
to
- the target for the transfer- Returns:
- a new
transfer pair
that is used to transfer underlying buffers into the target vector.
-
getTransferPair
Description copied from interface:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in 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:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in 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:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in 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:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in 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:
getValueCapacity
in interfaceValueVector
- Overrides:
getValueCapacity
in 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:
getBuffers
in interfaceValueVector
- Overrides:
getBuffers
in 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
buffers
that is used by this vector instance.
-
close
public void close()Close the vector and release the associated buffers.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceValueVector
- Overrides:
close
in classNonNullableStructVector
-
clear
public void clear()Same asclose()
.- Specified by:
clear
in interfaceValueVector
- Overrides:
clear
in classNonNullableStructVector
-
reset
public void reset()Reset this vector to empty, does not release buffers.- Specified by:
reset
in interfaceValueVector
- Overrides:
reset
in classNonNullableStructVector
-
getBufferSize
public int getBufferSize()Get the size (number of bytes) of underlying buffers used by this vector.- Specified by:
getBufferSize
in interfaceValueVector
- Overrides:
getBufferSize
in 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:
getBufferSizeFor
in interfaceValueVector
- Overrides:
getBufferSizeFor
in 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:ValueVector
Set the initial record capacity.- Specified by:
setInitialCapacity
in interfaceValueVector
- Overrides:
setInitialCapacity
in classNonNullableStructVector
- Parameters:
numRecords
- the initial record capacity.
-
setInitialCapacity
public void setInitialCapacity(int numRecords, double density) Description copied from interface:DensityAwareVector
Set value with density.- Specified by:
setInitialCapacity
in interfaceDensityAwareVector
- Overrides:
setInitialCapacity
in classNonNullableStructVector
- Parameters:
numRecords
- the number of values in this vectordensity
- the density of the vector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVector
Allocates new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewSafe
in interfaceValueVector
- Overrides:
allocateNewSafe
in classAbstractStructVector
- 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- Specified by:
reAlloc
in interfaceValueVector
- Overrides:
reAlloc
in classAbstractStructVector
-
getValidityBufferAddress
public long getValidityBufferAddress()Description copied from interface:FieldVector
Gets the starting address of the underlying buffer associated with validity vector.- Specified by:
getValidityBufferAddress
in interfaceFieldVector
- Returns:
- buffer address
-
getDataBufferAddress
public long getDataBufferAddress()Description copied from interface:FieldVector
Gets the starting address of the underlying buffer associated with data vector.- Specified by:
getDataBufferAddress
in interfaceFieldVector
- Returns:
- buffer address
-
getOffsetBufferAddress
public long getOffsetBufferAddress()Description copied from interface:FieldVector
Gets the starting address of the underlying buffer associated with offset vector.- Specified by:
getOffsetBufferAddress
in interfaceFieldVector
- Returns:
- buffer address
-
getValidityBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with validity vector.- Specified by:
getValidityBuffer
in interfaceValueVector
- Overrides:
getValidityBuffer
in classNonNullableStructVector
- Returns:
- buffer
-
getDataBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with data vector.- Specified by:
getDataBuffer
in interfaceValueVector
- Overrides:
getDataBuffer
in classNonNullableStructVector
- Returns:
- buffer
-
getOffsetBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with offset vector.- Specified by:
getOffsetBuffer
in interfaceValueVector
- Overrides:
getOffsetBuffer
in classNonNullableStructVector
- Returns:
- buffer
-
getObject
Description copied from interface:ValueVector
Get friendly type object from the vector.- Specified by:
getObject
in interfaceValueVector
- Overrides:
getObject
in classNonNullableStructVector
- Parameters:
index
- index of object to get- Returns:
- friendly type object
-
hashCode
public int hashCode(int index) Description copied from interface:ValueVector
Returns hashCode of element in index with the default hasher.- Specified by:
hashCode
in interfaceValueVector
- Overrides:
hashCode
in classNonNullableStructVector
-
hashCode
Description copied from interface:ValueVector
Returns hashCode of element in index with the given hasher.- Specified by:
hashCode
in interfaceValueVector
- Overrides:
hashCode
in classNonNullableStructVector
-
get
- Overrides:
get
in classNonNullableStructVector
-
getNullCount
public int getNullCount()Return the number of null values in the vector.- Specified by:
getNullCount
in interfaceValueVector
- Overrides:
getNullCount
in 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:
isNull
in interfaceValueVector
- Overrides:
isNull
in 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:
setNull
in interfaceFieldVector
- Parameters:
index
- the value to change
-
setValueCount
public void setValueCount(int valueCount) Description copied from interface:ValueVector
Set number of values in the vector.- Specified by:
setValueCount
in interfaceValueVector
- Overrides:
setValueCount
in classNonNullableStructVector
-