public class ListVector extends BaseRepeatedValueVector implements PromotableVector
| Modifier and Type | Field and Description |
|---|---|
protected Field |
field |
protected int |
lastSet
The maximum index that is actually set.
|
protected UnionListReader |
reader |
protected int |
validityAllocationSizeInBytes |
protected ArrowBuf |
validityBuffer |
DATA_VECTOR_NAME, DEFAULT_DATA_VECTOR, defaultDataVectorName, OFFSET_WIDTH, offsetAllocationSizeInBytes, offsetBuffer, valueCount, vectorallocator, fieldReader, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTYDEFAULT_REPEAT_PER_RECORD| Constructor and Description |
|---|
ListVector(Field field,
BufferAllocator allocator,
CallBack callBack)
Constructs a new instance.
|
ListVector(String name,
BufferAllocator allocator,
FieldType fieldType,
CallBack callBack)
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
<OUT,IN> OUT |
accept(VectorVisitor<OUT,IN> visitor,
IN value)
Accept a generic
VectorVisitor and return the result. |
<T extends ValueVector> |
addOrGetVector(FieldType fieldType)
Initialize the child data vector to field type.
|
void |
allocateNew()
Same as
allocateNewSafe(). |
boolean |
allocateNewSafe()
Allocate memory for the vector.
|
protected void |
allocateValidityBuffer(long size) |
void |
clear()
Release any owned ArrowBuf and reset the ValueVector to the initial state.
|
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 as
copyFrom(int, int, ValueVector) except that
it handles the case when the capacity of the vector needs to be expanded
before copy. |
static ListVector |
empty(String name,
BufferAllocator allocator) |
void |
endValue(int index,
int size)
End the current value.
|
ArrowBuf[] |
getBuffers(boolean clear)
Return the underlying buffers associated with this vector.
|
int |
getBufferSize()
Get the size (number of bytes) of underlying buffers 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.
|
List<FieldVector> |
getChildrenFromFields()
The returned list is the same size as the list passed to initializeChildrenFromFields.
|
ArrowBuf |
getDataBuffer()
Gets the underlying buffer associated with data vector.
|
long |
getDataBufferAddress()
Gets the starting address of the underlying buffer associated with data vector.
|
FieldVector |
getDataVector()
Get the inner data vector for this list vector.
|
double |
getDensity()
Get the density of this ListVector.
|
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.
|
Field |
getField()
Get information about how this field is materialized.
|
List<ArrowBuf> |
getFieldBuffers()
Get the buffers belonging to this vector.
|
List<BufferBacked> |
getFieldInnerVectors()
Deprecated.
This API will be removed as the current implementations no longer support inner vectors.
|
int |
getLastSet() |
Types.MinorType |
getMinorType() |
int |
getNullCount()
Get the number of elements that are null in the vector.
|
List<?> |
getObject(int index)
Get the element in the list vector at a particular index.
|
ArrowBuf |
getOffsetBuffer()
Gets the underlying buffer associated with offset vector.
|
long |
getOffsetBufferAddress()
Gets the starting address of the underlying buffer associated with offset vector.
|
UnionListReader |
getReader()
Default implementation to create a reader for the vector.
|
protected FieldReader |
getReaderImpl()
Each vector has a different reader that implements the FieldReader interface.
|
TransferPair |
getTransferPair(Field field,
BufferAllocator allocator)
To transfer quota responsibility.
|
TransferPair |
getTransferPair(Field field,
BufferAllocator allocator,
CallBack callBack)
To transfer quota responsibility.
|
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator)
To transfer quota responsibility.
|
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator,
CallBack callBack)
To transfer quota responsibility.
|
ArrowBuf |
getValidityBuffer()
Gets the underlying buffer associated with validity vector.
|
long |
getValidityBufferAddress()
Gets the starting address of the underlying buffer associated with validity vector.
|
int |
getValueCapacity()
Get the current value capacity for the vector.
|
UnionListWriter |
getWriter() |
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.
|
protected void |
invalidateReader() |
boolean |
isEmpty(int index)
Check if element at given index is empty list.
|
boolean |
isNull(int index)
Check if element at given index is null.
|
int |
isSet(int index)
Same as
isNull(int). |
void |
loadFieldBuffers(ArrowFieldNode fieldNode,
List<ArrowBuf> ownBuffers)
Load the buffers of this vector with provided source buffers.
|
TransferPair |
makeTransferPair(ValueVector target)
Makes a new transfer pair used to transfer underlying buffers.
|
UnionVector |
promoteToUnion() |
void |
reAlloc()
Resize the vector to increase the capacity.
|
protected void |
reallocValidityAndOffsetBuffers() |
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 numRecords,
double density)
Specialized version of setInitialCapacity() for ListVector.
|
void |
setInitialTotalCapacity(int numRecords,
int totalNumberOfElements)
Specialized version of setInitialTotalCapacity() for ListVector.
|
void |
setLastSet(int value) |
void |
setNotNull(int index)
Sets the list at index to be not-null.
|
void |
setNull(int index)
Sets list at index to be null.
|
void |
setValueCount(int valueCount)
Sets the value count for the vector.
|
int |
startNewValue(int index)
Start a new value in the list vector.
|
allocateOffsetBuffer, getInnerValueCount, getInnerValueCountAt, getName, getOffsetBufferValueCapacity, getOffsetVector, getValueCount, iterator, reallocOffsetBuffer, replaceDataVector, sizecheckBufRefs, close, getAllocator, getTransferPair, getValidityBufferSizeFromCount, releaseBuffer, toString, transferBufferclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, getAllocator, getTransferPair, validate, validateFullforEach, spliteratorprotected ArrowBuf validityBuffer
protected UnionListReader reader
protected Field field
protected int validityAllocationSizeInBytes
protected int lastSet
public ListVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack)
name - The name of the instance.allocator - The allocator to use for allocating/reallocating buffers.fieldType - The type of this list.callBack - A schema change callback.public ListVector(Field field, BufferAllocator allocator, CallBack callBack)
field - The field materialized by this vector.allocator - The allocator to use for allocating/reallocating buffers.callBack - A schema change callback.public static ListVector empty(String name, BufferAllocator allocator)
public void initializeChildrenFromFields(List<Field> children)
FieldVectorinitializeChildrenFromFields in interface FieldVectorchildren - the schemapublic void setInitialCapacity(int numRecords)
ValueVectorsetInitialCapacity in interface ValueVectorsetInitialCapacity in class BaseRepeatedValueVectornumRecords - the initial record capacity.public void setInitialCapacity(int numRecords,
double density)
setInitialCapacity in interface DensityAwareVectorsetInitialCapacity in class BaseRepeatedValueVectornumRecords - value countdensity - density of ListVector. Density is the average size of
list per position in the List vector. For example, a
density value of 10 implies each position in the list
vector has a list of 10 values.
A density value of 0.1 implies out of 10 positions in
the list vector, 1 position has a list of size 1 and
remaining positions are null (no lists) or empty lists.
This helps in tightly controlling the memory we provision
for inner data vector.public void setInitialTotalCapacity(int numRecords,
int totalNumberOfElements)
setInitialTotalCapacity in class BaseRepeatedValueVectornumRecords - value counttotalNumberOfElements - the total number of elements to to allow
for in this vector across all records.public double getDensity()
public List<FieldVector> getChildrenFromFields()
FieldVectorgetChildrenFromFields in interface FieldVectorpublic void loadFieldBuffers(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers)
loadFieldBuffers in interface FieldVectorfieldNode - the fieldNode indicating the value countownBuffers - the buffers for this Field (own buffers only, children not included)public List<ArrowBuf> getFieldBuffers()
getFieldBuffers in interface FieldVector@Deprecated public List<BufferBacked> getFieldInnerVectors()
getFieldInnerVectors in interface FieldVectorpublic UnionListWriter getWriter()
public void allocateNew()
throws OutOfMemoryException
allocateNewSafe().allocateNew in interface ValueVectorOutOfMemoryException - Thrown if no memory can be allocated.public boolean allocateNewSafe()
allocateNewSafe in interface ValueVectorallocateNewSafe in class BaseRepeatedValueVectorprotected void allocateValidityBuffer(long size)
public void reAlloc()
reAlloc in interface ValueVectorreAlloc in class BaseRepeatedValueVectorprotected void reallocValidityAndOffsetBuffers()
public void copyFromSafe(int inIndex,
int outIndex,
ValueVector from)
copyFrom(int, int, ValueVector) except that
it handles the case when the capacity of the vector needs to be expanded
before copy.copyFromSafe in interface ValueVectorcopyFromSafe in class BaseValueVectorinIndex - position to copy from in source vectoroutIndex - position to copy to in this vectorfrom - source vectorpublic void copyFrom(int inIndex,
int outIndex,
ValueVector from)
copyFrom in interface ValueVectorcopyFrom in class BaseValueVectorinIndex - position to copy from in source vectoroutIndex - position to copy to in this vectorfrom - source vectorpublic FieldVector getDataVector()
getDataVector in interface RepeatedValueVectorgetDataVector in class BaseRepeatedValueVectorpublic TransferPair getTransferPair(String ref, BufferAllocator allocator)
ValueVectorgetTransferPair in interface ValueVectorref - the name of the vectorallocator - the target allocatortransfer pair, creating a new target vector of
the same type.public TransferPair getTransferPair(Field field, BufferAllocator allocator)
ValueVectorgetTransferPair in interface ValueVectorfield - the Field object used by the target vectorallocator - the target allocatortransfer pair, creating a new target vector of
the same type.public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack)
ValueVectorgetTransferPair in interface ValueVectorref - the name of the vectorallocator - the target allocatorcallBack - A schema change callback.transfer pair, creating a new target vector of
the same type.public TransferPair getTransferPair(Field field, BufferAllocator allocator, CallBack callBack)
ValueVectorgetTransferPair in interface ValueVectorfield - the Field object used by the target vectorallocator - the target allocatorcallBack - A schema change callback.transfer pair, creating a new target vector of
the same type.public TransferPair makeTransferPair(ValueVector target)
ValueVectormakeTransferPair in interface ValueVectortarget - the target for the transfertransfer pair that is used to transfer underlying
buffers into the target vector.public long getValidityBufferAddress()
FieldVectorgetValidityBufferAddress in interface FieldVectorpublic long getDataBufferAddress()
FieldVectorgetDataBufferAddress in interface FieldVectorpublic long getOffsetBufferAddress()
FieldVectorgetOffsetBufferAddress in interface FieldVectorpublic ArrowBuf getValidityBuffer()
ValueVectorgetValidityBuffer in interface ValueVectorpublic ArrowBuf getDataBuffer()
ValueVectorgetDataBuffer in interface ValueVectorpublic ArrowBuf getOffsetBuffer()
ValueVectorgetOffsetBuffer in interface ValueVectorpublic int hashCode(int index)
ValueVectorhashCode in interface ValueVectorpublic int hashCode(int index,
ArrowBufHasher hasher)
ValueVectorhashCode in interface ValueVectorpublic <OUT,IN> OUT accept(VectorVisitor<OUT,IN> visitor, IN value)
ValueVectorVectorVisitor and return the result.accept in interface ValueVectorOUT - the output result type.IN - the input data together with visitor.protected FieldReader getReaderImpl()
BaseValueVectorgetReaderImpl in class BaseValueVectorpublic UnionListReader getReader()
BaseValueVectorBaseValueVector.getReaderImpl() to initialize the reader appropriately.getReader in interface ValueVectorgetReader in class BaseValueVectorpublic <T extends ValueVector> AddOrGetResult<T> addOrGetVector(FieldType fieldType)
addOrGetVector in interface PromotableVectoraddOrGetVector in class BaseRepeatedValueVectorpublic int getBufferSize()
getBufferSize in interface ValueVectorgetBufferSize in class BaseRepeatedValueVectorpublic int getBufferSizeFor(int valueCount)
ValueVectorgetBufferSizeFor in interface ValueVectorgetBufferSizeFor in class BaseRepeatedValueVectorvalueCount - the number of values to assume this vector containspublic Field getField()
ValueVectorgetField in interface ValueVectorpublic Types.MinorType getMinorType()
getMinorType in interface ValueVectorpublic void clear()
ValueVectorclear in interface ValueVectorclear in class BaseRepeatedValueVectorpublic void reset()
ValueVectorreset in interface ValueVectorreset in class BaseRepeatedValueVectorpublic ArrowBuf[] getBuffers(boolean clear)
getBuffers in interface ValueVectorgetBuffers in class BaseRepeatedValueVectorclear - Whether to clear vector before returning; the buffers will still be refcounted
but the returned array will be the only reference to thembuffers that is used by this
vector instance.public UnionVector promoteToUnion()
promoteToUnion in interface PromotableVectorprotected void invalidateReader()
public List<?> getObject(int index)
getObject in interface ValueVectorindex - position of the elementpublic boolean isNull(int index)
isNull in interface ValueVectorisNull in class BaseRepeatedValueVectorindex - position of elementpublic boolean isEmpty(int index)
isEmpty in class BaseRepeatedValueVectorindex - position of elementpublic int isSet(int index)
isNull(int).index - position of elementpublic int getNullCount()
getNullCount in interface ValueVectorpublic int getValueCapacity()
getValueCapacity in interface ValueVectorgetValueCapacity in class BaseRepeatedValueVectorpublic void setNotNull(int index)
public void setNull(int index)
setNull in interface FieldVectorindex - position in vectorpublic int startNewValue(int index)
startNewValue in class BaseRepeatedValueVectorindex - index of the value to startpublic void endValue(int index,
int size)
index - index of the value to endsize - number of elements in the list that was writtenpublic void setValueCount(int valueCount)
setValueCount in interface ValueVectorsetValueCount in class BaseRepeatedValueVectorvalueCount - value countpublic void setLastSet(int value)
public int getLastSet()
public int getElementStartIndex(int index)
BaseListVectorgetElementStartIndex in interface BaseListVectorpublic int getElementEndIndex(int index)
BaseListVectorgetElementEndIndex in interface BaseListVectorCopyright © 2024 The Apache Software Foundation. All rights reserved.