java.lang.Object
org.apache.arrow.vector.BaseValueVector
org.apache.arrow.vector.complex.RunEndEncodedVector
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<ValueVector>,FieldVector,ValueVector
A run-end encoded vector contains only two child vectors: a run_end vector of type int and a
values vector of any type. There are no buffers associated with the parent vector.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CallBackstatic final FieldVectorstatic final FieldVectorprotected Fieldprotected FieldVectorprotected intprotected FieldVectorFields inherited from class org.apache.arrow.vector.BaseValueVector
allocator, fieldReader, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTY, validityBuffer -
Constructor Summary
ConstructorsConstructorDescriptionRunEndEncodedVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) Constructs a new instance.RunEndEncodedVector(Field field, BufferAllocator allocator, FieldVector runEndsVector, FieldVector valuesVector, CallBack callBack) Constructs a new instance.RunEndEncodedVector(Field field, BufferAllocator allocator, CallBack callBack) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescription<OUT,IN> OUT accept(VectorVisitor<OUT, IN> visitor, IN value) Accept a genericVectorVisitorand return the result.voidAllocate new buffers.booleanAllocates new buffers.voidclear()Release any owned ArrowBuf and reset the ValueVector to the initial state.voidclose()Alternative to clear().static RunEndEncodedVectorempty(String name, BufferAllocator allocator) Get the allocator associated with the vector.ArrowBuf[]getBuffers(boolean clear) Return the underlying buffers associated with this vector.intGet the number of bytes used by this vector.intgetBufferSizeFor(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.longGets the starting address of the underlying buffer associated with data vector.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.getName()Gets the name of the vector.intReturns number of null elements in the vector.getObject(int index) Get friendly type object from the vector.Gets the underlying buffer associated with offset vector.longGets the starting address of the underlying buffer associated with offset vector.intgetPhysicalIndex(int logicalIndex) The physical index is the index of the first value that is larger than logical index. e.g. if run_ends is [1,2,3], the physical index of logical index from 0 to 5 is [0, 1, 1, 2, 2, 2]Get a reader for this vector.protected FieldReaderEach vector has a different reader that implements the FieldReader interface.intgetRunEnd(int index) Get the run end of giving index.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.longGets the starting address of the underlying buffer associated with validity vector.intReturns the maximum number of values that can be stored in this vector instance.intGets the number of values.Get a writer for this vector.inthashCode(int index) Returns hashCode of element in index with the default hasher.inthashCode(int index, ArrowBufHasher hasher) Returns hashCode of element in index with the given hasher.voidinitializeChildrenFromFields(List<Field> children) Initializes the child vectors to be later loaded with loadBuffers.booleanisNull(int index) Check whether an element in the vector is null.iterator()voidloadFieldBuffers(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers) Loads data in the vectors.makeTransferPair(ValueVector target) Makes a new transfer pair used to transfer underlying buffers.voidreAlloc()Allocate new buffer with double capacity, and copy data into the new buffer.voidreset()Reset the ValueVector to the initial state without releasing any owned ArrowBuf.voidsetInitialCapacity(int numRecords) Set the initial record capacity.voidsetNull(int index) Set the element at the given index to null.voidsetValueCount(int valueCount) Set number of values in the vector.Methods inherited from class org.apache.arrow.vector.BaseValueVector
allocateValidityBuffer, checkBufRefs, copyFrom, copyFromSafe, copyValidityBuffer, getTransferPair, getValidityBufferSizeFromCount, releaseBuffer, sliceAndTransferValidityBuffer, splitAndTransferValidityBuffer, toString, transferBufferMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.arrow.vector.FieldVector
exportBuffer, exportCDataBuffers, getExportedCDataBufferCountMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.arrow.vector.ValueVector
copyFrom, copyFromSafe, getTransferPair, validate, validateFull
-
Field Details
-
DEFAULT_VALUE_VECTOR
-
DEFAULT_RUN_END_VECTOR
-
callBack
-
field
-
runEndsVector
-
valuesVector
-
valueCount
protected int valueCount
-
-
Constructor Details
-
RunEndEncodedVector
public RunEndEncodedVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) Constructs a new instance.- Parameters:
name- The name of the instance.allocator- The allocator to use for allocating/reallocating buffers.fieldType- The type of the array that is run-end encoded.callBack- A schema change callback.
-
RunEndEncodedVector
Constructs a new instance.- Parameters:
field- The field materialized by this vector.allocator- The allocator to use for allocating/reallocating buffers.callBack- A schema change callback.
-
RunEndEncodedVector
public RunEndEncodedVector(Field field, BufferAllocator allocator, FieldVector runEndsVector, FieldVector valuesVector, CallBack callBack) Constructs a new instance.- Parameters:
field- The field materialized by this vector.allocator- The allocator to use for allocating/reallocating buffers.runEndsVector- The vector represents run ends. Only Zero vector or type int vector with size 16, 32 is allowedvaluesVector- The vector represents valuescallBack- A schema change callback.
-
-
Method Details
-
empty
-
allocateNew
Allocate new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewin interfaceValueVector- Throws:
OutOfMemoryException- Thrown if no memory can be allocated.
-
allocateNewSafe
public boolean allocateNewSafe()Allocates new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewSafein interfaceValueVector- Returns:
- Returns true if allocation was successful.
-
reAlloc
public void reAlloc()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:
reAllocin interfaceValueVector
-
getAllocator
Description copied from interface:ValueVectorGet 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:
getAllocatorin interfaceValueVector- Overrides:
getAllocatorin classBaseValueVector- Returns:
- Returns nullable allocator.
-
getReaderImpl
Description copied from class:BaseValueVectorEach vector has a different reader that implements the FieldReader interface. Overridden methods must make sure to return the correct concrete reader implementation.- Specified by:
getReaderImplin classBaseValueVector- Returns:
- Returns a lambda that initializes a reader when called.
-
setInitialCapacity
public void setInitialCapacity(int numRecords) Set the initial record capacity.- Specified by:
setInitialCapacityin interfaceValueVector- Parameters:
numRecords- the initial record capacity.
-
getValueCapacity
public int getValueCapacity()Returns the maximum number of values that can be stored in this vector instance.- Specified by:
getValueCapacityin interfaceValueVector- Returns:
- the maximum number of values that can be stored in this vector instance.
-
close
public void close()Alternative to clear(). Allows use as an AutoCloseable in try-with-resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceValueVector- Overrides:
closein classBaseValueVector
-
clear
public void clear()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:
clearin interfaceValueVector- Overrides:
clearin classBaseValueVector
-
reset
public void reset()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:
resetin interfaceValueVector
-
getField
Get information about how this field is materialized.- Specified by:
getFieldin interfaceValueVector- Returns:
- the field corresponding to this vector
-
getMinorType
- Specified by:
getMinorTypein interfaceValueVector
-
getTransferPair
To transfer quota responsibility.- Specified by:
getTransferPairin 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
To transfer quota responsibility.- Specified by:
getTransferPairin 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
To transfer quota responsibility.- Specified by:
getTransferPairin 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
To transfer quota responsibility.- Specified by:
getTransferPairin 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
Makes a new transfer pair used to transfer underlying buffers.- Specified by:
makeTransferPairin interfaceValueVector- Parameters:
target- the target for the transfer- Returns:
- a new
transfer pairthat is used to transfer underlying buffers into the target vector.
-
getReader
Get a reader for this vector.- Specified by:
getReaderin interfaceValueVector- Overrides:
getReaderin classBaseValueVector- Returns:
- a
field readerthat supports reading values from this vector.
-
getWriter
Get a writer for this vector.- Returns:
- a
field writerthat supports writing values to this vector.
-
getBufferSize
public int getBufferSize()Get the number of bytes used by this vector.- Specified by:
getBufferSizein interfaceValueVector- Returns:
- the number of bytes that is used by this vector instance.
-
getBufferSizeFor
public int getBufferSizeFor(int valueCount) 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:
getBufferSizeForin interfaceValueVector- Parameters:
valueCount- the number of values to assume this vector contains- Returns:
- the buffer size if this vector is holding valueCount values
-
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:
getBuffersin 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
buffersthat is used by this vector instance.
-
getValidityBuffer
Gets the underlying buffer associated with validity vector.- Specified by:
getValidityBufferin interfaceValueVector- Returns:
- buffer
-
getDataBuffer
Gets the underlying buffer associated with data vector.- Specified by:
getDataBufferin interfaceValueVector- Returns:
- buffer
-
getOffsetBuffer
Gets the underlying buffer associated with offset vector.- Specified by:
getOffsetBufferin interfaceValueVector- Returns:
- buffer
-
getValueCount
public int getValueCount()Gets the number of values.- Specified by:
getValueCountin interfaceValueVector- Returns:
- number of values in the vector
-
setValueCount
public void setValueCount(int valueCount) Set number of values in the vector.- Specified by:
setValueCountin interfaceValueVector
-
getObject
Get friendly type object from the vector.- Specified by:
getObjectin interfaceValueVector- Parameters:
index- index of object to get- Returns:
- friendly type object
-
getRunEnd
public int getRunEnd(int index) Get the run end of giving index.- Parameters:
index- index of the run end to get- Returns:
- the run end of giving index
-
getNullCount
public int getNullCount()Returns number of null elements in the vector.- Specified by:
getNullCountin interfaceValueVector- Returns:
- number of null elements
-
isNull
public boolean isNull(int index) Check whether an element in the vector is null.- Specified by:
isNullin interfaceValueVector- Parameters:
index- index to check for null- Returns:
- true if element is null
-
hashCode
public int hashCode(int index) Returns hashCode of element in index with the default hasher.- Specified by:
hashCodein interfaceValueVector
-
hashCode
Returns hashCode of element in index with the given hasher.- Specified by:
hashCodein interfaceValueVector
-
accept
Accept a genericVectorVisitorand return the result.- Specified by:
acceptin interfaceValueVector- Type Parameters:
OUT- the output result type.IN- the input data together with visitor.
-
getName
Gets the name of the vector.- Specified by:
getNamein interfaceValueVector- Specified by:
getNamein classBaseValueVector- Returns:
- the name of the vector.
-
iterator
- Specified by:
iteratorin interfaceIterable<ValueVector>- Overrides:
iteratorin classBaseValueVector
-
initializeChildrenFromFields
Initializes the child vectors to be later loaded with loadBuffers.- Specified by:
initializeChildrenFromFieldsin interfaceFieldVector- Parameters:
children- the schema containing the run_ends column first and the values column second
-
getChildrenFromFields
The returned list is the same size as the list passed to initializeChildrenFromFields.- Specified by:
getChildrenFromFieldsin interfaceFieldVector- Returns:
- the children according to schema (empty for primitive types)
-
loadFieldBuffers
Loads data in the vectors. (ownBuffers must be the same size as getFieldVectors())- Specified by:
loadFieldBuffersin interfaceFieldVector- Parameters:
fieldNode- the fieldNodeownBuffers- the buffers for this Field (own buffers only, children not included)
-
getFieldBuffers
Get the buffers of the fields, (same size as getFieldVectors() since it is their content).- Specified by:
getFieldBuffersin 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:
getFieldInnerVectorsin interfaceFieldVector- Returns:
- the inner vectors for this field as defined by the TypeLayout
-
getValidityBufferAddress
public long getValidityBufferAddress()Gets the starting address of the underlying buffer associated with validity vector.- Specified by:
getValidityBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
getDataBufferAddress
public long getDataBufferAddress()Gets the starting address of the underlying buffer associated with data vector.- Specified by:
getDataBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
getOffsetBufferAddress
public long getOffsetBufferAddress()Gets the starting address of the underlying buffer associated with offset vector.- Specified by:
getOffsetBufferAddressin interfaceFieldVector- Returns:
- buffer address
-
setNull
public void setNull(int index) Set the element at the given index to null.- Specified by:
setNullin interfaceFieldVector- Parameters:
index- the value to change
-
getRunEndsVector
-
getValuesVector
-
getPhysicalIndex
public int getPhysicalIndex(int logicalIndex) The physical index is the index of the first value that is larger than logical index. e.g. if run_ends is [1,2,3], the physical index of logical index from 0 to 5 is [0, 1, 1, 2, 2, 2]
-