java.lang.Object
org.apache.arrow.vector.BaseValueVector
org.apache.arrow.vector.BaseFixedWidthVector
org.apache.arrow.vector.Decimal256Vector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,ElementAddressableVector
,FieldVector
,FixedWidthVector
,ValueIterableVector<BigDecimal>
,ValueVector
,VectorDefinitionSetter
public final class Decimal256Vector
extends BaseFixedWidthVector
implements ValueIterableVector<BigDecimal>
Decimal256Vector implements a fixed width vector (32 bytes) of decimal values which could be
null. A validity buffer (bit vector) is maintained to track which elements in the vector are
null.
-
Field Summary
Fields inherited from class org.apache.arrow.vector.BaseFixedWidthVector
actualValueCapacity, field, lastValueCapacity, validityBuffer, valueBuffer, valueCount
Fields inherited from class org.apache.arrow.vector.BaseValueVector
allocator, fieldReader, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE, MAX_ALLOCATION_SIZE_PROPERTY
-
Constructor Summary
ConstructorDescriptionDecimal256Vector
(String name, BufferAllocator allocator, int precision, int scale) Instantiate a Decimal256Vector.Decimal256Vector
(String name, FieldType fieldType, BufferAllocator allocator) Instantiate a Decimal256Vector.Decimal256Vector
(Field field, BufferAllocator allocator) Instantiate a Decimal256Vector. -
Method Summary
Modifier and TypeMethodDescriptionget
(int index) Get the element at the given index from the vector.void
get
(int index, NullableDecimal256Holder holder) Get the element at the given index from the vector and sets the state in holder.Get minor type for this vector.getObject
(int index) Same asget(int)
.getObjectNotNull
(int index) Same asgetObject(int)
, but does not check for null.int
Return precision for the decimal value.protected FieldReader
Each vector has a different reader that implements the FieldReader interface.int
getScale()
Return scale for the decimal value.getTransferPair
(String ref, BufferAllocator allocator) Construct a TransferPair comprising this and a target vector of the same type.getTransferPair
(Field field, BufferAllocator allocator) Construct a TransferPair comprising this and a target vector of the same type.Construct a TransferPair with a desired target vector of the same type.void
Store the given value at a particular position in the vector.void
set
(int index, long value) Set the element at the given index to the given value.void
Set the element at the given index to the given value.void
set
(int index, BigDecimal value) Set the element at the given index to the given value.void
Set the element at the given index to the given value.void
set
(int index, Decimal256Holder holder) Set the element at the given index to the value set in data holder.void
set
(int index, NullableDecimal256Holder holder) Set the element at the given index to the value set in data holder.void
setBigEndian
(int index, byte[] value) Set the decimal element at given index to the provided array of bytes.void
setBigEndianSafe
(int index, byte[] value) Same assetBigEndian(int, byte[])
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
setBigEndianSafe
(int index, long start, ArrowBuf buffer, int length) Sets the element at given index using the buffer whose size maybe <= 32 bytes.void
Same assetSafe(int, int, int, ArrowBuf)
except that it handles the case when the position of new value is beyond the current value capacity of the vector.void
setSafe
(int index, long value) Same asset(int, long)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
Same asset(int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
Sets the element at given index using the buffer whose size maybe <= 32 bytes.void
setSafe
(int index, BigDecimal value) Same asset(int, BigDecimal)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
Same asset(int, ArrowBuf)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
setSafe
(int index, Decimal256Holder holder) Same asset(int, Decimal256Holder)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
setSafe
(int index, NullableDecimal256Holder holder) Same asset(int, NullableDecimalHolder)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.void
Validate the scalar values held by this vector.Methods inherited from class org.apache.arrow.vector.BaseFixedWidthVector
accept, allocateNew, allocateNew, allocateNewSafe, clear, close, copyFrom, copyFromSafe, decrementAllocationMonitor, getBuffers, getBufferSize, getBufferSizeFor, getChildrenFromFields, getDataBuffer, getDataBufferAddress, getDataPointer, getDataPointer, getField, getFieldBuffers, getFieldInnerVectors, getName, getNullCount, getOffsetBuffer, getOffsetBufferAddress, getTransferPair, getTransferPair, getTransferPair, getTypeWidth, getValidityBuffer, getValidityBufferAddress, getValidityBufferValueCapacity, getValueBufferValueCapacity, getValueCapacity, getValueCount, handleSafe, hashCode, hashCode, incrementAllocationMonitor, initializeChildrenFromFields, isNull, isSafe, isSet, loadFieldBuffers, reAlloc, refreshValueCapacity, reset, set, set, setIndexDefined, setInitialCapacity, setNull, setSafe, setSafe, setValueCount, splitAndTransferTo, transferTo, zeroVector
Methods inherited from class org.apache.arrow.vector.BaseValueVector
checkBufRefs, getAllocator, getReader, 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, exportCDataBuffers, getExportedCDataBufferCount
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.arrow.vector.ValueIterableVector
getValueIterable, getValueIterator
Methods inherited from interface org.apache.arrow.vector.ValueVector
accept, allocateNew, allocateNewSafe, clear, close, copyFrom, copyFromSafe, getAllocator, getBuffers, getBufferSize, getBufferSizeFor, getDataBuffer, getField, getName, getNullCount, getOffsetBuffer, getReader, getTransferPair, getTransferPair, getTransferPair, getValidityBuffer, getValueCapacity, getValueCount, hashCode, hashCode, isNull, reAlloc, reset, setInitialCapacity, setValueCount, validate, validateFull
-
Field Details
-
MAX_PRECISION
public static final int MAX_PRECISION- See Also:
-
TYPE_WIDTH
public static final byte TYPE_WIDTH- See Also:
-
-
Constructor Details
-
Decimal256Vector
Instantiate a Decimal256Vector. This doesn't allocate any memory for the data in vector.- Parameters:
name
- name of the vectorallocator
- allocator for memory management.
-
Decimal256Vector
Instantiate a Decimal256Vector. This doesn't allocate any memory for the data in vector.- Parameters:
name
- name of the vectorfieldType
- type of Field materialized by this vectorallocator
- allocator for memory management.
-
Decimal256Vector
Instantiate a Decimal256Vector. This doesn't allocate any memory for the data in vector.- Parameters:
field
- field materialized by this vectorallocator
- allocator for memory management.
-
-
Method Details
-
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.
-
getMinorType
Get minor type for this vector. The vector holds values belonging to a particular type.- Specified by:
getMinorType
in interfaceValueVector
- Returns:
Types.MinorType
-
get
Get the element at the given index from the vector.- Parameters:
index
- position of element- Returns:
- element at given index
- Throws:
IllegalStateException
-
get
Get the element at the given index from the vector and sets the state in holder. If element at given index is null, holder.isSet will be zero.- Parameters:
index
- position of element
-
getObject
Same asget(int)
.- Specified by:
getObject
in interfaceValueVector
- Parameters:
index
- position of element- Returns:
- element at given index
-
getObjectNotNull
Same asgetObject(int)
, but does not check for null.- Parameters:
index
- position of element- Returns:
- element at given index
-
getPrecision
public int getPrecision()Return precision for the decimal value. -
getScale
public int getScale()Return scale for the decimal value. -
set
Set the element at the given index to the given value.- Parameters:
index
- position of elementbuffer
- ArrowBuf containing decimal value.
-
setBigEndian
public void setBigEndian(int index, byte[] value) Set the decimal element at given index to the provided array of bytes. Decimal256 is now implemented as Native Endian. This API allows the user to pass a decimal value in the form of byte array in BE byte order.Consumers of Arrow code can use this API instead of first swapping the source bytes (doing a write and read) and then finally writing to ArrowBuf of decimal vector.
This method takes care of adding the necessary padding if the length of byte array is less than 32 (length of decimal type).
- Parameters:
index
- position of elementvalue
- array of bytes containing decimal in big endian byte order.
-
set
Set the element at the given index to the given value.- Parameters:
index
- position of elementstart
- start index of data in the bufferbuffer
- ArrowBuf containing decimal value.
-
setSafe
Sets the element at given index using the buffer whose size maybe <= 32 bytes.- Parameters:
index
- index to write the decimal tostart
- start of value in the bufferbuffer
- contains the decimal in native endian byteslength
- length of the value in the buffer
-
setBigEndianSafe
Sets the element at given index using the buffer whose size maybe <= 32 bytes.- Parameters:
index
- index to write the decimal tostart
- start of value in the bufferbuffer
- contains the decimal in big endian byteslength
- length of the value in the buffer
-
set
Set the element at the given index to the given value.- Parameters:
index
- position of elementvalue
- BigDecimal containing decimal value.
-
set
public void set(int index, long value) Set the element at the given index to the given value.- Parameters:
index
- position of elementvalue
- long value.
-
set
Set the element at the given index to the value set in data holder. If the value in holder is not indicated as set, element in the at the given index will be null.- Parameters:
index
- position of elementholder
- nullable data holder for value of element- Throws:
IllegalArgumentException
-
set
Set the element at the given index to the value set in data holder.- Parameters:
index
- position of elementholder
- data holder for value of element
-
setSafe
Same asset(int, ArrowBuf)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementbuffer
- ArrowBuf containing decimal value.
-
setBigEndianSafe
public void setBigEndianSafe(int index, byte[] value) Same assetBigEndian(int, byte[])
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
. -
setSafe
Same asset(int, int, ArrowBuf)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementstart
- start index of data in the bufferbuffer
- ArrowBuf containing decimal value.
-
setSafe
Same asset(int, BigDecimal)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementvalue
- BigDecimal containing decimal value.
-
setSafe
public void setSafe(int index, long value) Same asset(int, long)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementvalue
- long value.
-
setSafe
Same asset(int, NullableDecimalHolder)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementholder
- nullable data holder for value of element- Throws:
IllegalArgumentException
-
setSafe
Same asset(int, Decimal256Holder)
except that it handles the case when index is greater than or equal to existing value capacityBaseFixedWidthVector.getValueCapacity()
.- Parameters:
index
- position of elementholder
- data holder for value of 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
- 0 for NULL value, 1 otherwisestart
- start position of the value in the bufferbuffer
- buffer containing the value to be stored in the vector
-
setSafe
Same assetSafe(int, int, int, ArrowBuf)
except that it handles the case when the position of new value is beyond the current value capacity of the vector.- Parameters:
index
- position of the new valueisSet
- 0 for NULL value, 1 otherwisestart
- start position of the value in the bufferbuffer
- buffer containing the value to be stored in the vector
-
validateScalars
public void validateScalars()Description copied from class:BaseFixedWidthVector
Validate the scalar values held by this vector.- Overrides:
validateScalars
in classBaseFixedWidthVector
-
getTransferPair
Construct a TransferPair comprising this and a target vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Specified by:
getTransferPair
in classBaseFixedWidthVector
- Parameters:
ref
- name of the target vectorallocator
- allocator for the target vector- Returns:
TransferPair
-
getTransferPair
Construct a TransferPair comprising this and a target vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Specified by:
getTransferPair
in classBaseFixedWidthVector
- Parameters:
field
- Field object used by the target vectorallocator
- allocator for the target vector- Returns:
TransferPair
-
makeTransferPair
Construct a TransferPair with a desired target vector of the same type.- Specified by:
makeTransferPair
in interfaceValueVector
- Parameters:
to
- target vector- Returns:
TransferPair
-