Package org.apache.arrow.vector.complex
Class FixedSizeListVector
java.lang.Object
org.apache.arrow.vector.BaseValueVector
org.apache.arrow.vector.complex.FixedSizeListVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,BaseListVector
,PromotableVector
,FieldVector
,ValueIterableVector<List<?>>
,ValueVector
public class FixedSizeListVector
extends BaseValueVector
implements BaseListVector, PromotableVector, ValueIterableVector<List<?>>
A ListVector where every list value is of the same size.
-
Field Summary
Fields inherited from class org.apache.arrow.vector.BaseValueVector
allocator, fieldReader, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTY
-
Constructor Summary
ConstructorDescriptionFixedSizeListVector
(String name, BufferAllocator allocator, FieldType fieldType, CallBack unusedSchemaChangeCallback) Creates a new instance.FixedSizeListVector
(Field field, BufferAllocator allocator, CallBack unusedSchemaChangeCallback) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescription<OUT,
IN> OUT accept
(VectorVisitor<OUT, IN> visitor, IN value) Accept a genericVectorVisitor
and return the result.<T extends ValueVector>
AddOrGetResult<T>addOrGetVector
(FieldType type) void
Allocate new buffers.boolean
Allocates new buffers.void
clear()
Release any owned ArrowBuf and reset the ValueVector to the initial state.void
copyFrom
(int fromIndex, int thisIndex, 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 FixedSizeListVector
empty
(String name, int size, BufferAllocator allocator) 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 valueCount) Returns the number of bytes that is used by this vector if it holds the given number of values.The 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.int
getElementEndIndex
(int index) Get data vector end index with the given list index.int
getElementStartIndex
(int index) Get data vector start index with the given list index.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.int
Get the fixed size for each list.getName()
Gets the name of the vector.int
Returns number of null elements in the vector.List<?>
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.Default implementation to create a reader for the vector.protected FieldReader
Each vector has a different reader that implements the FieldReader interface.getTransferPair
(String ref, BufferAllocator allocator) To transfer quota responsibility.getTransferPair
(String ref, BufferAllocator allocator, CallBack callBack) 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
Returns the maximum number of values that can be stored in this vector instance.int
Gets the number of values.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) Returns whether the value at index null.int
isSet
(int index) Returns non-zero when the value at index is non-null.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.void
reset()
Reset the ValueVector to the initial state without releasing any owned ArrowBuf.void
setInitialCapacity
(int numRecords) Set the initial record capacity.void
setNotNull
(int index) Sets the value at index to not-null.void
setNull
(int index) Sets the value at index to null.void
setValueCount
(int valueCount) Set number of values in the vector.int
size()
Get value indicating if inner vector is set.int
startNewValue
(int index) Start a new value in the list vector.Methods inherited from class org.apache.arrow.vector.BaseValueVector
checkBufRefs, close, getAllocator, getTransferPair, getValidityBufferSizeFromCount, releaseBuffer, toString, transferBuffer
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
close, getAllocator, getTransferPair, validate, validateFull
-
Constructor Details
-
FixedSizeListVector
public FixedSizeListVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack unusedSchemaChangeCallback) Creates a new instance.- Parameters:
name
- The name for the vector.allocator
- The allocator to use for creating/reallocating buffers for the vector.fieldType
- The underlying data type of the vector.unusedSchemaChangeCallback
- Currently unused.
-
FixedSizeListVector
public FixedSizeListVector(Field field, BufferAllocator allocator, CallBack unusedSchemaChangeCallback) Creates a new instance.- Parameters:
field
- The field materialized by this vector.allocator
- The allocator to use for creating/reallocating buffers for the vector.unusedSchemaChangeCallback
- Currently unused.
-
-
Method Details
-
empty
-
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
-
getMinorType
- Specified by:
getMinorType
in interfaceValueVector
-
getName
Description copied from interface:ValueVector
Gets the name of the vector.- Specified by:
getName
in interfaceValueVector
- Specified by:
getName
in classBaseValueVector
- Returns:
- the name of the vector.
-
getListSize
public int getListSize()Get the fixed size for each list. -
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.Get the inner vectors.- Specified by:
getFieldInnerVectors
in interfaceFieldVector
- Returns:
- the inner vectors for this field as defined by the TypeLayout
-
getReaderImpl
Description copied from class:BaseValueVector
Each vector has a different reader that implements the FieldReader interface. Overridden methods must make sure to return the correct concrete reader implementation.- Specified by:
getReaderImpl
in classBaseValueVector
- Returns:
- Returns a lambda that initializes a reader when called.
-
getReader
Description copied from class:BaseValueVector
Default implementation to create a reader for the vector. Depends on the individual vector class' implementation ofBaseValueVector.getReaderImpl()
to initialize the reader appropriately.- Specified by:
getReader
in interfaceValueVector
- Overrides:
getReader
in classBaseValueVector
- Returns:
- Concrete instance of FieldReader by using double-checked locking.
-
allocateNew
Description copied from interface:ValueVector
Allocate new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNew
in interfaceValueVector
- 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
-
getDataVector
-
startNewValue
public int startNewValue(int index) Start a new value in the list vector.- Parameters:
index
- index of the value to start
-
getWriter
-
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.
-
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 valueCount) 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:
valueCount
- the number of values to assume this vector contains- Returns:
- the buffer size if this vector is holding valueCount values
-
iterator
- Specified by:
iterator
in interfaceIterable<ValueVector>
- Overrides:
iterator
in classBaseValueVector
-
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
- Overrides:
clear
in classBaseValueVector
-
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
-
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.
-
size
public int size()Get value indicating if inner vector is set.- Returns:
- 1 if inner vector is explicitly set via #addOrGetVector else 0
-
addOrGetVector
- Specified by:
addOrGetVector
in interfacePromotableVector
-
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 classBaseValueVector
- Parameters:
inIndex
- position to copy from in source vectoroutIndex
- position to copy to in this vectorfrom
- source 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 classBaseValueVector
- Parameters:
fromIndex
- position to copy from in source vectorthisIndex
- position to copy to in this vectorfrom
- source vector
-
promoteToUnion
- Specified by:
promoteToUnion
in interfacePromotableVector
-
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
- Returns:
- buffer
-
getDataBuffer
Description copied from interface:ValueVector
Gets the underlying buffer associated with data vector.- Specified by:
getDataBuffer
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
-
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
-
isNull
public boolean isNull(int index) Returns whether the value at index null.- Specified by:
isNull
in interfaceValueVector
- Parameters:
index
- index to check for null- Returns:
- true if element is null
-
isSet
public int isSet(int index) Returns non-zero when the value at index is non-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
-
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
-
setNull
public void setNull(int index) Sets the value at index to null. Reallocates if index is larger than capacity.- Specified by:
setNull
in interfaceFieldVector
- Parameters:
index
- the value to change
-
setNotNull
public void setNotNull(int index) Sets the value at index to not-null. Reallocates if index is larger than capacity. -
setValueCount
public void setValueCount(int valueCount) Description copied from interface:ValueVector
Set number of values in the vector.- Specified by:
setValueCount
in interfaceValueVector
-
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:
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:
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 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.
-
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
-
hashCode
Description copied from interface:ValueVector
Returns hashCode of element in index with the given 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.
-
getElementStartIndex
public int getElementStartIndex(int index) Description copied from interface:BaseListVector
Get data vector start index with the given list index.- Specified by:
getElementStartIndex
in interfaceBaseListVector
-
getElementEndIndex
public int getElementEndIndex(int index) Description copied from interface:BaseListVector
Get data vector end index with the given list index.- Specified by:
getElementEndIndex
in interfaceBaseListVector
-