public class LargeListVector extends BaseValueVector implements RepeatedValueVector, FieldVector, PromotableVector
WARNING: Currently Arrow in Java doesn't support 64-bit vectors. This class follows the expected behaviour of a LargeList but doesn't actually support allocating a 64-bit vector. It has little use until 64-bit vectors are supported and should be used with caution. todo review checkedCastToInt usage in this class. Once int64 indexed vectors are supported these checks aren't needed.
| Modifier and Type | Field and Description |
|---|---|
protected CallBack |
callBack |
static String |
DATA_VECTOR_NAME |
static FieldVector |
DEFAULT_DATA_VECTOR |
protected String |
defaultDataVectorName |
static byte |
OFFSET_WIDTH |
protected long |
offsetAllocationSizeInBytes |
protected ArrowBuf |
offsetBuffer |
protected UnionLargeListReader |
reader |
protected ArrowBuf |
validityBuffer |
protected int |
valueCount |
protected FieldVector |
vector |
allocator, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTYDEFAULT_REPEAT_PER_RECORD| Constructor and Description |
|---|
LargeListVector(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 data vector (and execute callback) if it hasn't already been done,
returns the data vector.
|
void |
allocateNew()
Same as
allocateNewSafe(). |
boolean |
allocateNewSafe()
Allocate memory for the vector.
|
protected void |
allocateOffsetBuffer(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 LargeListVector |
empty(String name,
BufferAllocator allocator) |
void |
endValue(int index,
long 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.
|
long |
getElementEndIndex(int index) |
long |
getElementStartIndex(int 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.
|
int |
getLastSet() |
Types.MinorType |
getMinorType() |
String |
getName()
Gets the name of the vector.
|
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.
|
protected int |
getOffsetBufferValueCapacity() |
UInt4Vector |
getOffsetVector()
Get the offset vector.
|
UnionLargeListReader |
getReader()
Get a reader for this vector.
|
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator) |
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator,
CallBack callBack) |
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.
|
int |
getValueCount()
Gets the number of values.
|
UnionLargeListWriter |
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 |
reallocOffsetBuffer() |
protected void |
replaceDataVector(FieldVector v) |
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 |
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.
|
long |
startNewValue(long index)
Start a new value in the list vector.
|
checkBufRefs, close, getAllocator, getTransferPair, getValidityBufferSizeFromCount, iterator, releaseBuffer, toString, transferBufferclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, getAllocator, getTransferPairforEach, iterator, spliteratorpublic static final FieldVector DEFAULT_DATA_VECTOR
public static final String DATA_VECTOR_NAME
public static final byte OFFSET_WIDTH
protected ArrowBuf offsetBuffer
protected FieldVector vector
protected final CallBack callBack
protected int valueCount
protected long offsetAllocationSizeInBytes
protected String defaultDataVectorName
protected ArrowBuf validityBuffer
protected UnionLargeListReader reader
public LargeListVector(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 static LargeListVector empty(String name, BufferAllocator allocator)
public void initializeChildrenFromFields(List<Field> children)
FieldVectorinitializeChildrenFromFields in interface FieldVectorchildren - the schemapublic void setInitialCapacity(int numRecords)
ValueVectorsetInitialCapacity in interface ValueVectornumRecords - the initial record capacity.public void setInitialCapacity(int numRecords,
double density)
setInitialCapacity in interface DensityAwareVectornumRecords - 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 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()
FieldVectorgetFieldInnerVectors in interface FieldVectorpublic void allocateNew()
throws OutOfMemoryException
allocateNewSafe().allocateNew in interface ValueVectorOutOfMemoryException - Thrown if no memory can be allocated.public boolean allocateNewSafe()
allocateNewSafe in interface ValueVectorprotected void allocateOffsetBuffer(long size)
public void reAlloc()
reAlloc in interface ValueVectorprotected void reallocOffsetBuffer()
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 UInt4Vector getOffsetVector()
RepeatedValueVectorgetOffsetVector in interface RepeatedValueVectorpublic FieldVector getDataVector()
getDataVector in interface RepeatedValueVectorpublic TransferPair getTransferPair(String ref, BufferAllocator allocator)
getTransferPair in interface ValueVectorpublic TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack)
getTransferPair in interface ValueVectorpublic 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 getValueCount()
ValueVectorgetValueCount 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.public UnionLargeListWriter getWriter()
protected void replaceDataVector(FieldVector v)
public UnionVector promoteToUnion()
promoteToUnion in interface PromotableVectorpublic UnionLargeListReader getReader()
ValueVectorgetReader in interface ValueVectorfield reader that supports reading values
from this vector.public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(FieldType fieldType)
addOrGetVector in interface PromotableVectorpublic int getBufferSize()
getBufferSize in interface ValueVectorpublic int getBufferSizeFor(int valueCount)
ValueVectorgetBufferSizeFor in interface ValueVectorvalueCount - the number of values to assume this vector containspublic Field getField()
ValueVectorgetField in interface ValueVectorpublic Types.MinorType getMinorType()
getMinorType in interface ValueVectorpublic String getName()
ValueVectorgetName in interface ValueVectorgetName in class BaseValueVectorpublic void clear()
ValueVectorclear in interface ValueVectorclear in class BaseValueVectorpublic void reset()
ValueVectorreset in interface ValueVectorpublic ArrowBuf[] getBuffers(boolean clear)
getBuffers in interface ValueVectorclear - 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.protected void invalidateReader()
public List<?> getObject(int index)
getObject in interface ValueVectorindex - position of the elementpublic boolean isNull(int index)
isNull in interface ValueVectorindex - position of elementpublic boolean isEmpty(int index)
index - position of elementpublic int isSet(int index)
isNull(int).index - position of elementpublic int getNullCount()
getNullCount in interface ValueVectorpublic int getValueCapacity()
getValueCapacity in interface ValueVectorprotected int getOffsetBufferValueCapacity()
public void setNotNull(int index)
public void setNull(int index)
index - position in vectorpublic long startNewValue(long index)
index - index of the value to startpublic void endValue(int index,
long size)
index - index of the value to endsize - number of elements in the list that was writtenpublic void setValueCount(int valueCount)
Important note: The underlying vector does not support 64-bit allocations yet. This may throw if attempting to hold larger than what a 32-bit vector can store.
setValueCount in interface ValueVectorvalueCount - value countpublic void setLastSet(int value)
public int getLastSet()
public long getElementStartIndex(int index)
public long getElementEndIndex(int index)
Copyright © 2021 The Apache Software Foundation. All rights reserved.