java.lang.Object
org.apache.arrow.vector.complex.AbstractContainerVector
org.apache.arrow.vector.complex.DenseUnionVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,DensityAwareVector
,FieldVector
,ValueIterableVector<Object>
,ValueVector
public class DenseUnionVector
extends AbstractContainerVector
implements FieldVector, ValueIterableVector<Object>
-
Field Summary
Fields inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
allocator, callBack, name
-
Constructor Summary
ConstructorDescriptionDenseUnionVector
(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) -
Method Summary
Modifier and TypeMethodDescription<OUT,
IN> OUT accept
(VectorVisitor<OUT, IN> visitor, IN value) Accept a genericVectorVisitor
and return the result.<T extends FieldVector>
TaddVector
(byte typeId, FieldVector v) void
Allocate new buffers.boolean
Allocates new buffers.void
clear()
Release any owned ArrowBuf and reset the ValueVector to the initial state.void
close()
Clears out all underlying child vectors.void
copyFrom
(int inIndex, int outIndex, ValueVector from) Copy a cell value from a particular index in source vector to a particular position in this vector.void
copyFromSafe
(int inIndex, int outIndex, ValueVector from) Same asValueVector.copyFrom(int, int, ValueVector)
except that it handles the case when the capacity of the vector needs to be expanded before copy.static DenseUnionVector
empty
(String name, BufferAllocator allocator) void
get
(int index, DenseUnionHolder holder) Get the allocator associated with the vector.getBigIntVector
(byte typeId) getBitVector
(byte typeId) ArrowBuf[]
getBuffers
(boolean clear) Return the underlying buffers associated with this vector.int
Get the number of bytes used by this vector.int
getBufferSizeFor
(int count) Returns the number of bytes that is used by this vector if it holds the given number of values.<T extends FieldVector>
TThe returned list is the same size as the list passed to initializeChildrenFromFields.Gets the underlying buffer associated with data vector.long
Gets the starting address of the underlying buffer associated with data vector.getDateDayVector
(byte typeId) getDateMilliVector
(byte typeId) getDecimal256Vector
(byte typeId, ArrowType arrowType) getDecimalVector
(byte typeId, ArrowType arrowType) getField()
Get information about how this field is materialized.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.getFloat2Vector
(byte typeId) getFloat4Vector
(byte typeId) getFloat8Vector
(byte typeId) getIntervalDayVector
(byte typeId) getIntervalMonthDayNanoVector
(byte typeId) getIntervalYearVector
(byte typeId) getIntVector
(byte typeId) getLargeVarBinaryVector
(byte typeId) getLargeVarCharVector
(byte typeId) getList
(byte typeId) getMap
(byte typeId) getName()
Gets the name of the vector.int
Returns number of null elements in the vector.getObject
(int index) Get friendly type object from the vector.int
getOffset
(int index) 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.getSmallIntVector
(byte typeId) getStruct
(byte typeId) getTimeMicroVector
(byte typeId) getTimeMilliVector
(byte typeId) getTimeNanoVector
(byte typeId) getTimeSecVector
(byte typeId) getTimeStampMicroVector
(byte typeId) getTimeStampMilliVector
(byte typeId) getTimeStampNanoVector
(byte typeId) getTimeStampSecVector
(byte typeId) getTinyIntVector
(byte typeId) 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.byte
getTypeId
(int index) getUInt1Vector
(byte typeId) getUInt2Vector
(byte typeId) getUInt4Vector
(byte typeId) getUInt8Vector
(byte typeId) Gets the underlying buffer associated with validity vector.long
Gets the starting address of the underlying buffer associated with validity vector.int
Returns the maximum number of values that can be stored in this vector instance.int
Gets the number of values.getVarBinaryVector
(byte typeId) getVarCharVector
(byte typeId) getVectorByType
(byte typeId) getViewVarBinaryVector
(byte typeId) getViewVarCharVector
(byte typeId) 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.void
initializeChildrenFromFields
(List<Field> children) Initializes the child vectors to be later loaded with loadBuffers.boolean
isNull
(int index) IMPORTANT: Union types always return non null as there is no validity buffer.int
isSet
(int index) iterator()
void
loadFieldBuffers
(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers) Loads data in the vectors.makeTransferPair
(ValueVector target) 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.byte
registerNewTypeId
(Field field) void
reset()
Reset the ValueVector to the initial state without releasing any owned ArrowBuf.void
setInitialCapacity
(int numRecords) Set the initial record capacity.void
setInitialCapacity
(int valueCount, double density) Set value with density.void
setNull
(int index) Set the element at the given index to null.void
setOffset
(int index, int offset) void
setSafe
(int index, DenseUnionHolder holder) void
setSafe
(int index, NullableBigIntHolder holder) void
setSafe
(int index, NullableBitHolder holder) void
setSafe
(int index, NullableDateDayHolder holder) void
setSafe
(int index, NullableDateMilliHolder holder) void
setSafe
(int index, NullableDecimal256Holder holder) void
setSafe
(int index, NullableDecimalHolder holder) void
setSafe
(int index, NullableFloat2Holder holder) void
setSafe
(int index, NullableFloat4Holder holder) void
setSafe
(int index, NullableFloat8Holder holder) void
setSafe
(int index, NullableIntervalDayHolder holder) void
setSafe
(int index, NullableIntervalMonthDayNanoHolder holder) void
setSafe
(int index, NullableIntervalYearHolder holder) void
setSafe
(int index, NullableIntHolder holder) void
setSafe
(int index, NullableLargeVarBinaryHolder holder) void
setSafe
(int index, NullableLargeVarCharHolder holder) void
setSafe
(int index, NullableSmallIntHolder holder) void
setSafe
(int index, NullableTimeMicroHolder holder) void
setSafe
(int index, NullableTimeMilliHolder holder) void
setSafe
(int index, NullableTimeNanoHolder holder) void
setSafe
(int index, NullableTimeSecHolder holder) void
setSafe
(int index, NullableTimeStampMicroHolder holder) void
setSafe
(int index, NullableTimeStampMilliHolder holder) void
setSafe
(int index, NullableTimeStampNanoHolder holder) void
setSafe
(int index, NullableTimeStampSecHolder holder) void
setSafe
(int index, NullableTinyIntHolder holder) void
setSafe
(int index, NullableUInt1Holder holder) void
setSafe
(int index, NullableUInt2Holder holder) void
setSafe
(int index, NullableUInt4Holder holder) void
setSafe
(int index, NullableUInt8Holder holder) void
setSafe
(int index, NullableVarBinaryHolder holder) void
setSafe
(int index, NullableVarCharHolder holder) void
setSafe
(int index, NullableViewVarBinaryHolder holder) void
setSafe
(int index, NullableViewVarCharHolder holder) void
setTypeId
(int index, byte typeId) void
setValueCount
(int valueCount) Set number of values in the vector.int
size()
Methods inherited from class org.apache.arrow.vector.complex.AbstractContainerVector
addOrGetFixedSizeList, addOrGetList, addOrGetListView, addOrGetMap, addOrGetStruct, addOrGetUnion, getChild, supportsDirectRead, toString, 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, getExportedCDataBufferCount
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.apache.arrow.vector.ValueIterableVector
getValueIterable, getValueIterator
Methods inherited from interface org.apache.arrow.vector.ValueVector
validate, validateFull
-
Field Details
-
TYPE_WIDTH
public static final byte TYPE_WIDTH- See Also:
-
OFFSET_WIDTH
public static final byte OFFSET_WIDTH- See Also:
-
-
Constructor Details
-
DenseUnionVector
public DenseUnionVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack)
-
-
Method Details
-
empty
-
getAllocator
Description copied from interface:ValueVector
Get the allocator associated with the vector. CAVEAT: Some ValueVector subclasses (e.g. NullVector) do not require an allocator for data storage and may return null.- Specified by:
getAllocator
in interfaceValueVector
- Overrides:
getAllocator
in classAbstractContainerVector
- Returns:
- Returns nullable allocator.
-
getMinorType
- Specified by:
getMinorType
in interfaceValueVector
-
initializeChildrenFromFields
Description copied from interface:FieldVector
Initializes the child vectors to be later loaded with loadBuffers.- Specified by:
initializeChildrenFromFields
in interfaceFieldVector
- Parameters:
children
- the schema
-
getChildrenFromFields
Description copied from interface:FieldVector
The returned list is the same size as the list passed to initializeChildrenFromFields.- Specified by:
getChildrenFromFields
in interfaceFieldVector
- Returns:
- the children according to schema (empty for primitive types)
-
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
-
registerNewTypeId
-
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
-
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
-
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
-
getValidityBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with validity vector.- Specified by:
getValidityBuffer
in interfaceValueVector
- Returns:
- buffer
-
getOffsetBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with offset vector.- Specified by:
getOffsetBuffer
in interfaceValueVector
- Returns:
- buffer
-
getTypeBuffer
-
getDataBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with data vector.- Specified by:
getDataBuffer
in interfaceValueVector
- Returns:
- buffer
-
getStruct
-
getTinyIntVector
-
getUInt1Vector
-
getUInt2Vector
-
getSmallIntVector
-
getFloat2Vector
-
getIntVector
-
getUInt4Vector
-
getFloat4Vector
-
getDateDayVector
-
getIntervalYearVector
-
getTimeSecVector
-
getTimeMilliVector
-
getBigIntVector
-
getUInt8Vector
-
getFloat8Vector
-
getDateMilliVector
-
getTimeStampSecVector
-
getTimeStampMilliVector
-
getTimeStampMicroVector
-
getTimeStampNanoVector
-
getTimeMicroVector
-
getTimeNanoVector
-
getIntervalDayVector
-
getIntervalMonthDayNanoVector
-
getDecimal256Vector
-
getDecimalVector
-
getVarBinaryVector
-
getVarCharVector
-
getViewVarBinaryVector
-
getViewVarCharVector
-
getLargeVarCharVector
-
getLargeVarBinaryVector
-
getBitVector
-
getList
-
getMap
-
getTypeId
public byte getTypeId(int index) -
getVectorByType
-
allocateNew
Description copied from interface:ValueVector
Allocate new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNew
in interfaceValueVector
- Overrides:
allocateNew
in classAbstractContainerVector
- Throws:
OutOfMemoryException
- Thrown if no memory can be allocated.
-
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
- 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
-
getOffset
public int getOffset(int index) -
setInitialCapacity
public void setInitialCapacity(int numRecords) Description copied from interface:ValueVector
Set the initial record capacity.- Specified by:
setInitialCapacity
in interfaceValueVector
- Parameters:
numRecords
- the initial record capacity.
-
getValueCapacity
public int getValueCapacity()Description copied from interface:ValueVector
Returns the maximum number of values that can be stored in this vector instance.- Specified by:
getValueCapacity
in interfaceValueVector
- Returns:
- the maximum number of values that can be stored in this vector instance.
-
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
-
clear
public void clear()Description copied from interface:ValueVector
Release any owned ArrowBuf and reset the ValueVector to the initial state. If the vector has any child vectors, they will also be cleared.- Specified by:
clear
in interfaceValueVector
-
reset
public void reset()Description copied from interface:ValueVector
Reset the ValueVector to the initial state without releasing any owned ArrowBuf. Buffer capacities will remain unchanged and any previous data will be zeroed out. This includes buffers for data, validity, offset, etc. If the vector has any child vectors, they will also be reset.- Specified by:
reset
in interfaceValueVector
-
getField
Description copied from interface:ValueVector
Get information about how this field is materialized.- Specified by:
getField
in interfaceValueVector
- Returns:
- the field corresponding to this vector
-
getTransferPair
Description copied from interface:ValueVector
To transfer quota responsibility.- Specified by:
getTransferPair
in interfaceValueVector
- Parameters:
allocator
- 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
- 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
- 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
- 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
- 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.
-
makeTransferPair
Description copied from interface:ValueVector
Makes a new transfer pair used to transfer underlying buffers.- Specified by:
makeTransferPair
in interfaceValueVector
- Parameters:
target
- the target for the transfer- Returns:
- a new
transfer pair
that is used to transfer underlying buffers into the target vector.
-
copyFrom
Description copied from interface:ValueVector
Copy a cell value from a particular index in source vector to a particular position in this vector.- Specified by:
copyFrom
in interfaceValueVector
- Overrides:
copyFrom
in classAbstractContainerVector
- Parameters:
inIndex
- position to copy from in source vectoroutIndex
- position to copy to in this vectorfrom
- source vector
-
copyFromSafe
Description copied from interface:ValueVector
Same asValueVector.copyFrom(int, int, ValueVector)
except that it handles the case when the capacity of the vector needs to be expanded before copy.- Specified by:
copyFromSafe
in interfaceValueVector
- Overrides:
copyFromSafe
in classAbstractContainerVector
- Parameters:
inIndex
- position to copy from in source vectoroutIndex
- position to copy to in this vectorfrom
- source vector
-
addVector
-
getReader
Description copied from interface:ValueVector
Get a reader for this vector.- Specified by:
getReader
in interfaceValueVector
- Returns:
- a
field reader
that supports reading values from this vector.
-
getWriter
-
getBufferSize
public int getBufferSize()Description copied from interface:ValueVector
Get the number of bytes used by this vector.- Specified by:
getBufferSize
in interfaceValueVector
- Returns:
- the number of bytes that is used by this vector instance.
-
getBufferSizeFor
public int getBufferSizeFor(int count) Description copied from interface:ValueVector
Returns the number of bytes that is used by this vector if it holds the given number of values. The result will be the same as if setValueCount() were called, followed by calling getBufferSize(), but without any of the closing side-effects that setValueCount() implies wrt finishing off the population of a vector. Some operations might wish to use this to determine how much memory has been used by a vector so far, even though it is not finished being populated.- Specified by:
getBufferSizeFor
in interfaceValueVector
- Parameters:
count
- the number of values to assume this vector contains- Returns:
- the buffer size if this vector is holding valueCount values
-
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).- Specified by:
getBuffers
in interfaceValueVector
- 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.
-
iterator
- Specified by:
iterator
in interfaceIterable<ValueVector>
-
getObject
Description copied from interface:ValueVector
Get friendly type object from the vector.- Specified by:
getObject
in interfaceValueVector
- Parameters:
index
- index of object to get- Returns:
- friendly type object
-
get
-
getValueCount
public int getValueCount()Description copied from interface:ValueVector
Gets the number of values.- Specified by:
getValueCount
in interfaceValueVector
- Returns:
- number of values in the vector
-
isNull
public boolean isNull(int index) IMPORTANT: Union types always return non null as there is no validity buffer. To check validity correctly you must check the underlying vector.- Specified by:
isNull
in interfaceValueVector
- Parameters:
index
- index to check for null- Returns:
- true if element is null
-
getNullCount
public int getNullCount()Description copied from interface:ValueVector
Returns number of null elements in the vector.- Specified by:
getNullCount
in interfaceValueVector
- Returns:
- number of null elements
-
isSet
public int isSet(int index) -
setValueCount
public void setValueCount(int valueCount) Description copied from interface:ValueVector
Set number of values in the vector.- Specified by:
setValueCount
in interfaceValueVector
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setSafe
-
setTypeId
public void setTypeId(int index, byte typeId) -
setOffset
public void setOffset(int index, int offset) -
hashCode
Description copied from interface:ValueVector
Returns hashCode of element in index with the given hasher.- Specified by:
hashCode
in interfaceValueVector
-
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
-
accept
Description copied from interface:ValueVector
Accept a genericVectorVisitor
and return the result.- Specified by:
accept
in interfaceValueVector
- Type Parameters:
OUT
- the output result type.IN
- the input data together with visitor.
-
getName
Description copied from interface:ValueVector
Gets the name of the vector.- Specified by:
getName
in interfaceValueVector
- Overrides:
getName
in classAbstractContainerVector
- Returns:
- the name of the vector.
-
addOrGet
- Specified by:
addOrGet
in classAbstractContainerVector
-
getChild
- Specified by:
getChild
in classAbstractContainerVector
-
getChildVectorWithOrdinal
- Specified by:
getChildVectorWithOrdinal
in classAbstractContainerVector
-
size
public int size()- Specified by:
size
in classAbstractContainerVector
-
setInitialCapacity
public void setInitialCapacity(int valueCount, double density) Description copied from interface:DensityAwareVector
Set value with density.- Specified by:
setInitialCapacity
in interfaceDensityAwareVector
- Parameters:
valueCount
- the number of values in this vectordensity
- the density of the vector
-
setNull
public void setNull(int index) Set the element at the given index to null. For DenseUnionVector, it throws an UnsupportedOperationException as nulls are not supported at the top level and isNull() always returns false.- Specified by:
setNull
in interfaceFieldVector
- Parameters:
index
- position of element- Throws:
UnsupportedOperationException
- whenever invoked
-