Class BaseVariableWidthViewVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,DensityAwareVector
,ElementAddressableVector
,FieldVector
,ValueVector
,VariableWidthFieldVector
,VariableWidthVector
,VectorDefinitionSetter
- Direct Known Subclasses:
ViewVarBinaryVector
,ViewVarCharVector
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final byte[]
protected final Field
static final int
protected int
static final int
protected int
static final int
static final int
protected ArrowBuf
protected int
protected ArrowBuf
Fields inherited from class org.apache.arrow.vector.BaseValueVector
allocator, fieldReader, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTY
-
Constructor Summary
ConstructorDescriptionBaseVariableWidthViewVector
(Field field, BufferAllocator allocator) Constructs 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.void
Same asallocateNewSafe()
.void
allocateNew
(int valueCount) Allocate a new memory space for this vector.void
allocateNew
(long totalBytes, int valueCount) Allocate memory for the vector to support storing at least the provided number of elements in the vector.boolean
Allocate memory for the vector.protected ArrowBuf
allocateOrGetLastDataBuffer
(int length) void
clear()
Same asclose()
.void
Release the data buffers and clear the list.void
close()
Close the vector and release the associated buffers.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 fromIndex, int thisIndex, ValueVector from) Same ascopyFrom(int, int, ValueVector)
except that it handles the case when the capacity of the vector needs to be expanded before copy.void
exportCDataBuffers
(List<ArrowBuf> buffers, ArrowBuf buffersPtr, long nullValue) Get the data buffer of the vector.void
fillEmpties
(int index) Create holes in the vector upto the given index (exclusive).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.int
Get the size (number of bytes) of underlying view buffer.Get the inner child vectors.protected byte[]
getData
(int index) Retrieves the data of a variable-width element at a given index in the vector.protected void
getData
(int index, ReusableBuffer<?> buffer) Get the buffer that stores the data for elements in the vector.long
Get the memory address of buffer that stores the data for elements in the vector.Get the buffers that store the data for views in the vector.getDataPointer
(int index) Gets the pointer for the data at the given index.getDataPointer
(int index, ArrowBufPointer reuse) Gets the pointer for the data at the given index.double
Get the density of this ListVector.int
Retrieves the export buffer count for the C Data Interface.getField()
Get information about how this field is materialized.Get the buffers belonging to this vector.Deprecated.This API will be removed as the current implementations no longer support inner vectors.int
Get the index of the last non-null element in the vector.getName()
Gets the name of the vector.int
Get the number of elements that are null in the vector.BaseVariableWidthViewVector doesn't support offset buffer.long
BaseVariableWidthViewVector doesn't support offset buffer.final int
getTotalValueLengthUpToIndex
(int index) Get the total length of the elements up to the given index.abstract TransferPair
getTransferPair
(String ref, BufferAllocator allocator) Construct a transfer pair of this vector and another vector of the same type.getTransferPair
(String ref, BufferAllocator allocator, CallBack callBack) Construct a transfer pair of this vector and another vector of the same type.getTransferPair
(BufferAllocator allocator) Construct a transfer pair of this vector and another vector of the same type.abstract TransferPair
getTransferPair
(Field field, BufferAllocator allocator) Construct a transfer pair of this vector and another vector of the same type.getTransferPair
(Field field, BufferAllocator allocator, CallBack callBack) Construct a transfer pair of this vector and another vector of the same type.Get buffer that manages the validity (NULL or NON-NULL nature) of elements in the vector.long
Get the memory address of buffer that manages the validity (NULL or NON-NULL nature) of elements in the vector.int
Get the current capacity which does not exceed either validity buffer or value buffer.int
Get the value count of vector.int
getValueLength
(int index) Get the length of the element at specified index.protected final void
handleSafe
(int index, int dataLength) 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) Initialize the children in schema for this Field.boolean
isNull
(int index) Check if an element at given index is null.boolean
isSafe
(int index) Check if the given index is within the current value capacity of the vector.int
isSet
(int index) Same asisNull(int)
.void
loadFieldBuffers
(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers) Load the buffers of this vector with provided source buffers.void
reAlloc()
Resize the vector to increase the capacity.void
Reallocate Validity buffer.void
Reallocate the view buffer.void
reallocViewBuffer
(long desiredAllocSize) Reallocate the view buffer to given size.void
Reallocate the data buffer associated with view buffer.void
reallocViewDataBuffer
(long desiredAllocSize) Reallocate the data buffer for views.void
reset()
Reset the vector to initial state.void
set
(int index, byte[] value) Set the variable length element at the specified index to the supplied byte array.void
set
(int index, byte[] value, int start, int length) Set the variable length element at the specified index to the supplied byte array.void
Store the given value at a particular position in the vector.void
Store the given value at a particular position in the vector.void
set
(int index, ByteBuffer value, int start, int length) Set the variable length element at the specified index to the content in supplied ByteBuffer.protected final void
setBytes
(int index, byte[] value, int start, int length) This method is used to create a view buffer for a variable width vector.protected final void
This method is used to create a view buffer for a variable width vector.void
setIndexDefined
(int index) Mark the particular position in the vector as non-null.void
setInitialCapacity
(int valueCount) Sets the desired value capacity for the vector.void
setInitialCapacity
(int valueCount, double density) Sets the desired value capacity for the vector.void
setLastSet
(int value) Set the index of the last non-null element in the vector.void
setNull
(int index) Set the element at the given index to null.void
setSafe
(int index, byte[] value) Same asset(int, byte[])
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.void
setSafe
(int index, byte[] value, int start, int length) Same asset(int, byte[], int, int)
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.void
Same asset(int, int, int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to current value capacity of the vector.void
Same asset(int, int, int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to current value capacity of the vector.void
setSafe
(int index, ByteBuffer value, int start, int length) Same asset(int, ByteBuffer, int, int)
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.void
setValueCount
(int valueCount) Sets the value count for the vector.void
setValueLengthSafe
(int index, int length) Sets the value length for an element.int
Provide the number of bytes contained in the valueBuffer.int
Get the size (number of bytes) of underlying elements in the view buffer.void
splitAndTransferTo
(int startIndex, int length, BaseVariableWidthViewVector target) Slice this vector at desired index and length and transfer the corresponding data to the target vector.void
Transfer this vector's data to another vector.void
Validate the scalar values held by this vector.void
zero out the vector and the data in associated buffers.Methods inherited from class org.apache.arrow.vector.BaseValueVector
checkBufRefs, getAllocator, getReader, getReaderImpl, getValidityBufferSizeFromCount, iterator, 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
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.arrow.vector.ValueVector
getAllocator, getMinorType, getObject, getReader, makeTransferPair, validate, validateFull
Methods inherited from interface org.apache.arrow.vector.VariableWidthFieldVector
get, read
-
Field Details
-
ELEMENT_SIZE
public static final int ELEMENT_SIZE- See Also:
-
INITIAL_VIEW_VALUE_ALLOCATION
public static final int INITIAL_VIEW_VALUE_ALLOCATION- See Also:
-
INLINE_SIZE
public static final int INLINE_SIZE- See Also:
-
LENGTH_WIDTH
public static final int LENGTH_WIDTH- See Also:
-
PREFIX_WIDTH
public static final int PREFIX_WIDTH- See Also:
-
BUF_INDEX_WIDTH
public static final int BUF_INDEX_WIDTH- See Also:
-
EMPTY_BYTE_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY -
validityBuffer
-
viewBuffer
-
dataBuffers
-
initialDataBufferSize
protected int initialDataBufferSize -
valueCount
protected int valueCount -
lastSet
protected int lastSet -
field
-
-
Constructor Details
-
BaseVariableWidthViewVector
Constructs a new instance.- Parameters:
field
- The field materialized by this vectorallocator
- The allocator to use for creating/resizing buffers
-
-
Method Details
-
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.
-
getValidityBuffer
Get buffer that manages the validity (NULL or NON-NULL nature) of elements in the vector. Consider it as a buffer for internal bit vector data structure.- Specified by:
getValidityBuffer
in interfaceValueVector
- Returns:
- buffer
-
getDataBuffer
Get the buffer that stores the data for elements in the vector.- Specified by:
getDataBuffer
in interfaceValueVector
- Returns:
- buffer
-
getDataBuffers
Get the buffers that store the data for views in the vector.- Returns:
- list of ArrowBuf
-
getOffsetBuffer
BaseVariableWidthViewVector doesn't support offset buffer.- Specified by:
getOffsetBuffer
in interfaceValueVector
- Returns:
- throws UnsupportedOperationException
-
getOffsetBufferAddress
public long getOffsetBufferAddress()BaseVariableWidthViewVector doesn't support offset buffer.- Specified by:
getOffsetBufferAddress
in interfaceFieldVector
- Returns:
- throws UnsupportedOperationException
-
getValidityBufferAddress
public long getValidityBufferAddress()Get the memory address of buffer that manages the validity (NULL or NON-NULL nature) of elements in the vector.- Specified by:
getValidityBufferAddress
in interfaceFieldVector
- Returns:
- starting address of the buffer
-
getDataBufferAddress
public long getDataBufferAddress()Get the memory address of buffer that stores the data for elements in the vector.- Specified by:
getDataBufferAddress
in interfaceFieldVector
- Returns:
- starting address of the buffer
-
setInitialCapacity
public void setInitialCapacity(int valueCount) Sets the desired value capacity for the vector. This function doesn't allocate any memory for the vector.- Specified by:
setInitialCapacity
in interfaceValueVector
- Parameters:
valueCount
- desired number of elements in the vector
-
setInitialCapacity
public void setInitialCapacity(int valueCount, double density) Sets the desired value capacity for the vector. This function doesn't allocate any memory for the vector.- Specified by:
setInitialCapacity
in interfaceDensityAwareVector
- Parameters:
valueCount
- desired number of elements in the vectordensity
- average number of bytes per variable width view element
-
getDensity
public double getDensity()Get the density of this ListVector.- Returns:
- density
-
getValueCapacity
public int getValueCapacity()Get the current capacity which does not exceed either validity buffer or value buffer. Note: Here the `getValueCapacity` has a relationship with the value buffer.- Specified by:
getValueCapacity
in interfaceValueVector
- Returns:
- number of elements that vector can hold.
-
zeroVector
public void zeroVector()zero out the vector and the data in associated buffers. -
reset
public void reset()Reset the vector to initial state. Note that this method doesn't release any memory.- Specified by:
reset
in interfaceValueVector
-
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 classBaseValueVector
-
clear
public void clear()Same asclose()
.- Specified by:
clear
in interfaceValueVector
- Overrides:
clear
in classBaseValueVector
-
clearDataBuffers
public void clearDataBuffers()Release the data buffers and clear the list. -
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
-
initializeChildrenFromFields
Initialize the children in schema for this Field. This operation is a NO-OP for scalar types since they don't have any children.- Specified by:
initializeChildrenFromFields
in interfaceFieldVector
- Parameters:
children
- the schema- Throws:
IllegalArgumentException
- if children is a non-empty list for scalar types.
-
getChildrenFromFields
Get the inner child vectors.- Specified by:
getChildrenFromFields
in interfaceFieldVector
- Returns:
- list of child vectors for complex types, empty list for scalar vector types
-
loadFieldBuffers
Load the buffers of this vector with provided source buffers. The caller manages the source buffers and populates them before invoking this method.- Specified by:
loadFieldBuffers
in interfaceFieldVector
- Parameters:
fieldNode
- the fieldNode indicating the value countownBuffers
- the buffers for this Field (own buffers only, children not included)
-
getFieldBuffers
Get the buffers belonging to this vector.- Specified by:
getFieldBuffers
in interfaceFieldVector
- Returns:
- the inner buffers.
-
allocateNew
public void allocateNew()Same asallocateNewSafe()
.- Specified by:
allocateNew
in interfaceValueVector
-
allocateNewSafe
public boolean allocateNewSafe()Allocate memory for the vector. We internally use a default value count of 4096 to allocate memory for at least these many elements in the vector. SeeallocateNew(long, int)
for allocating memory for specific number of elements in the vector.- Specified by:
allocateNewSafe
in interfaceValueVector
- Returns:
- false if memory allocation fails, true otherwise.
-
allocateNew
public void allocateNew(long totalBytes, int valueCount) Allocate memory for the vector to support storing at least the provided number of elements in the vector. This method must be called prior to using the ValueVector.- Specified by:
allocateNew
in interfaceVariableWidthVector
- Parameters:
totalBytes
- desired total memory capacityvalueCount
- the desired number of elements in the vector- Throws:
OutOfMemoryException
- if memory allocation fails
-
allocateNew
public void allocateNew(int valueCount) Description copied from interface:VariableWidthVector
Allocate a new memory space for this vector. Must be called prior to using the ValueVector. The initial size in bytes is either default (or) reused from previous allocation- Specified by:
allocateNew
in interfaceVariableWidthVector
- Parameters:
valueCount
- Number of values in the vector.
-
reAlloc
public void reAlloc()Resize the vector to increase the capacity. The internal behavior is to double the current value capacity.- Specified by:
reAlloc
in interfaceValueVector
-
reallocViewBuffer
public void reallocViewBuffer()Reallocate the view buffer. View Buffer stores the views for VIEWVARCHAR or VIEWVARBINARY elements in the vector. The behavior is to double the size of buffer.- Throws:
OversizedAllocationException
- if the desired new size is more than max allowedOutOfMemoryException
- if the internal memory allocation fails
-
reallocViewDataBuffer
public void reallocViewDataBuffer()Reallocate the data buffer associated with view buffer. -
reallocViewBuffer
public void reallocViewBuffer(long desiredAllocSize) Reallocate the view buffer to given size. View Buffer stores the views for VIEWVARCHAR or VIEWVARBINARY elements in the vector. The actual allocated size may be larger than the request one because it will round up the provided value to the nearest power of two.- Parameters:
desiredAllocSize
- the desired new allocation size- Throws:
OversizedAllocationException
- if the desired new size is more than max allowedOutOfMemoryException
- if the internal memory allocation fails
-
reallocViewDataBuffer
public void reallocViewDataBuffer(long desiredAllocSize) Reallocate the data buffer for views.- Parameters:
desiredAllocSize
- allocation size in bytes
-
reallocValidityBuffer
public void reallocValidityBuffer()Reallocate Validity buffer. -
getByteCapacity
public int getByteCapacity()Get the size (number of bytes) of underlying view buffer.- Specified by:
getByteCapacity
in interfaceVariableWidthVector
- Returns:
- number of bytes in the view buffer
-
sizeOfValueBuffer
public int sizeOfValueBuffer()Description copied from interface:VariableWidthVector
Provide the number of bytes contained in the valueBuffer.- Specified by:
sizeOfValueBuffer
in interfaceVariableWidthVector
- Returns:
- the number of bytes in valueBuffer.
-
sizeOfViewBufferElements
public int sizeOfViewBufferElements()Get the size (number of bytes) of underlying elements in the view buffer.- Returns:
- number of bytes used by data in the view buffer
-
getBufferSize
public int getBufferSize()Get the size (number of bytes) of underlying buffers used by this vector.- Specified by:
getBufferSize
in interfaceValueVector
- 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
- Parameters:
valueCount
- desired number of elements in the vector- Returns:
- estimated size of underlying buffers if the vector holds a given number of elements
-
getField
Get information about how this field is materialized.- Specified by:
getField
in interfaceValueVector
- Returns:
- the field corresponding to this vector
-
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
- 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.
-
validateScalars
public void validateScalars()Validate the scalar values held by this vector. -
getTransferPair
Construct a transfer pair of this vector and another vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Parameters:
field
- The field materialized by this vector.allocator
- allocator for the target vectorcallBack
- not used- Returns:
- TransferPair
-
getTransferPair
Construct a transfer pair of this vector and another vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Parameters:
ref
- name of the target vectorallocator
- allocator for the target vectorcallBack
- not used- Returns:
- TransferPair
-
getTransferPair
Construct a transfer pair of this vector and another vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in classBaseValueVector
- Parameters:
allocator
- allocator for the target vector- Returns:
- TransferPair
-
getTransferPair
Construct a transfer pair of this vector and another vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Parameters:
ref
- name of the target vectorallocator
- allocator for the target vector- Returns:
- TransferPair
-
getTransferPair
Construct a transfer pair of this vector and another vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Parameters:
field
- The field materialized by this vector.allocator
- allocator for the target vector- Returns:
- TransferPair
-
transferTo
Transfer this vector's data to another vector. The memory associated with this vector is transferred to the allocator of target vector for accounting and management purposes.- Parameters:
target
- destination vector for transfer
-
splitAndTransferTo
Slice this vector at desired index and length and transfer the corresponding data to the target vector.- Parameters:
startIndex
- start position of the split in source vector.length
- length of the split.target
- destination vector
-
getNullCount
public int getNullCount()Get the number of elements that are null in the vector.- Specified by:
getNullCount
in interfaceValueVector
- Returns:
- the number of null elements.
-
isSafe
public boolean isSafe(int index) Check if the given index is within the current value capacity of the vector.- Parameters:
index
- position to check- Returns:
- true if the index is within the current value capacity
-
isNull
public boolean isNull(int index) Check if an element at given index is null.- Specified by:
isNull
in interfaceValueVector
- Parameters:
index
- position of an element- Returns:
- true if an element at given index is null
-
isSet
public int isSet(int index) Same asisNull(int)
.- Parameters:
index
- position of an element- Returns:
- 1 if element at given index is not null, 0 otherwise
-
getValueCount
public int getValueCount()Get the value count of vector. This will always be zero unless setValueCount(int) has been called prior to calling this.- Specified by:
getValueCount
in interfaceValueVector
- Returns:
- valueCount for the vector
-
setValueCount
public void setValueCount(int valueCount) Sets the value count for the vector.- Specified by:
setValueCount
in interfaceValueVector
- Parameters:
valueCount
- value count
-
fillEmpties
public void fillEmpties(int index) Create holes in the vector upto the given index (exclusive). Holes will be created from the current last-set position in the vector.- Specified by:
fillEmpties
in interfaceVariableWidthFieldVector
- Parameters:
index
- target index
-
setLastSet
public void setLastSet(int value) Set the index of the last non-null element in the vector. It is important to call this method with appropriate value before callingsetValueCount(int)
.- Specified by:
setLastSet
in interfaceVariableWidthFieldVector
- Parameters:
value
- desired index of last non-null element.
-
getLastSet
public int getLastSet()Get the index of the last non-null element in the vector.- Specified by:
getLastSet
in interfaceVariableWidthFieldVector
- Returns:
- index of the last non-null element
-
setIndexDefined
public void setIndexDefined(int index) Mark the particular position in the vector as non-null.- Specified by:
setIndexDefined
in interfaceVectorDefinitionSetter
- Parameters:
index
- position of the element.
-
setValueLengthSafe
public void setValueLengthSafe(int index, int length) Sets the value length for an element.- Specified by:
setValueLengthSafe
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setlength
- length of the element
-
getValueLength
public int getValueLength(int index) Get the length of the element at specified index.- Specified by:
getValueLength
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of an element to get- Returns:
- greater than length 0 for a non-null element, 0 otherwise
-
set
public void set(int index, byte[] value) Set the variable length element at the specified index to the supplied byte array. This is same as usingset(int, byte[], int, int)
with start as Zero and length as #value.length- Specified by:
set
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- array of bytes to write
-
setSafe
public void setSafe(int index, byte[] value) Same asset(int, byte[])
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.- Specified by:
setSafe
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- array of bytes to write
-
set
public void set(int index, byte[] value, int start, int length) Set the variable length element at the specified index to the supplied byte array.- Specified by:
set
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- array of bytes to writestart
- start index in an array of byteslength
- length of data in an array of bytes
-
setSafe
public void setSafe(int index, byte[] value, int start, int length) Same asset(int, byte[], int, int)
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.- Specified by:
setSafe
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- array of bytes to writestart
- start index in an array of byteslength
- length of data in an array of bytes
-
set
Set the variable length element at the specified index to the content in supplied ByteBuffer.- Specified by:
set
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- ByteBuffer with datastart
- start index in ByteBufferlength
- length of data in ByteBuffer
-
setSafe
Same asset(int, ByteBuffer, int, int)
except that it handles the case where index and length of a new element are beyond the existing capacity of the vector.- Specified by:
setSafe
in interfaceVariableWidthFieldVector
- Parameters:
index
- position of the element to setvalue
- ByteBuffer with datastart
- start index in ByteBufferlength
- length of data in ByteBuffer
-
setNull
public void setNull(int index) Set the element at the given index to null.- Specified by:
setNull
in interfaceFieldVector
- Parameters:
index
- position of an element
-
set
Store the given value at a particular position in the vector. isSet indicates whether the value is NULL or not.- Parameters:
index
- position of the new valueisSet
- Zero for NULL value, 1 otherwisestart
- start position of data in bufferend
- end position of data in bufferbuffer
- data buffer containing the variable width element to be stored in the vector
-
setSafe
Same asset(int, int, int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to current value capacity of the vector.- Parameters:
index
- position of the new valueisSet
- Zero for NULL value, 1 otherwisestart
- start position of data in bufferend
- end position of data in bufferbuffer
- data buffer containing the variable width element to be stored in the vector
-
set
Store the given value at a particular position in the vector. isSet indicates whether the value is NULL or not.- Parameters:
index
- position of the new valuestart
- start position of data in bufferlength
- length of data in bufferbuffer
- data buffer containing the variable width element to be stored in the vector
-
setSafe
Same asset(int, int, int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to current value capacity of the vector.- Parameters:
index
- position of the new valuestart
- start position of data in bufferlength
- length of data in bufferbuffer
- data buffer containing the variable width element to be stored in the vector
-
allocateOrGetLastDataBuffer
-
setBytes
protected final void setBytes(int index, byte[] value, int start, int length) This method is used to create a view buffer for a variable width vector. It handles both inline and data buffers.If the length of the value is less than or equal to
INLINE_SIZE
, the value is stored in the valueBuffer directly as an inline buffer. The valueBuffer stores the length of the value followed by the value itself. If the length of the value is greater thanINLINE_SIZE
, a new buffer is allocated and added to dataBuffers to hold the value. The viewBuffer in this case stores the length of the value, a prefix of the value, the index of the new buffer in dataBuffers, and the offset of the value in the new buffer.- Parameters:
index
- The index at which the new value will be inserted.value
- The byte array that contains the data to be inserted.start
- The start index in the byte array from where the data for the new value begins.length
- The length of the data in the byte array that belongs to the new value.
-
setBytes
This method is used to create a view buffer for a variable width vector. Similar tosetBytes(int index, byte[] value, int start, int length)
- Parameters:
index
- The index at which the new value will be inserted.valueBuf
- The byte array that contains the data to be inserted.start
- The start index in the byte array from where the data for the new value begins.length
- The length of the data in the byte array that belongs to the new value.
-
getTotalValueLengthUpToIndex
public final int getTotalValueLengthUpToIndex(int index) Get the total length of the elements up to the given index.- Parameters:
index
- The index of the element in the vector.- Returns:
- The total length up to the element at the given index.
-
handleSafe
protected final void handleSafe(int index, int dataLength) -
copyFrom
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
-
copyFromSafe
Same ascopyFrom(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:
fromIndex
- position to copy from in source vectorthisIndex
- position to copy to in this vectorfrom
- source vector
-
getDataPointer
Description copied from interface:ElementAddressableVector
Gets the pointer for the data at the given index.- Specified by:
getDataPointer
in interfaceElementAddressableVector
- Parameters:
index
- the index for the data.- Returns:
- the pointer to the data.
-
getDataPointer
Description copied from interface:ElementAddressableVector
Gets the pointer for the data at the given index.- Specified by:
getDataPointer
in interfaceElementAddressableVector
- Parameters:
index
- the index for the data.reuse
- the data pointer to fill, this avoids creating a new pointer object.- Returns:
- the pointer to the data, it should be the same one as the input parameter
-
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
-
getData
protected byte[] getData(int index) Retrieves the data of a variable-width element at a given index in the vector.If the length of the data is greater than
INLINE_SIZE
, the data is stored in an inline buffer. The method retrieves the buffer index and data offset from the viewBuffer, and then retrieves the data from the corresponding buffer in the dataBuffers list.If the length of the data is less than or equal to
INLINE_SIZE
, the data is stored directly in the viewBuffer. The method retrieves the data directly from the viewBuffer.- Parameters:
index
- position of the element in the vector- Returns:
- byte array containing the data of the element
-
getData
-
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.
-
getExportedCDataBufferCount
public int getExportedCDataBufferCount()Retrieves the export buffer count for the C Data Interface.For Variadic types, an additional buffer is kept to store the size of each variadic buffer since that information cannot be retrieved in the C Data import.
In the C Data Interface, the binary view import expects at least three buffers. The variadic size buffer is merely allocated to determine the number of elements per each variadic buffer, and it is not part of the imported data.
The count is set to 3 + dataBuffers.size(). Three is formed by validity, view, and variadic size buffer.
- Specified by:
getExportedCDataBufferCount
in interfaceFieldVector
- Returns:
- the number of buffers to be exported
-
exportCDataBuffers
Get the data buffer of the vector. Note that an additional buffer is appended to store the size of each variadic buffer's size.- Specified by:
exportCDataBuffers
in interfaceFieldVector
- Parameters:
buffers
- list of buffers to be exportedbuffersPtr
- buffer to store the pointers to the exported buffersnullValue
- null value
-