Package org.apache.drill.exec.vector
Class BitVector
java.lang.Object
org.apache.drill.exec.vector.BaseValueVector
org.apache.drill.exec.vector.BaseDataValueVector
org.apache.drill.exec.vector.BitVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,FixedWidthVector
,ValueVector
Bit implements a vector of bit-width values. Elements in the vector are accessed by position from the logical start
of the vector. The width of each element is 1 bit. The equivalent Java primitive is an int containing the value '0'
or '1'.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
MutableBit implements a vector of bit-width values.Nested classes/interfaces inherited from class org.apache.drill.exec.vector.BaseValueVector
BaseValueVector.BaseAccessor, BaseValueVector.BaseMutator
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Maximum number of values that this fixed-width vector can hold and stay below the maximum vector size limit.static final int
Maximum number of values that this fixed-width vector can hold and stay below the maximum vector size limit and/or stay below the maximum item count.static final int
Actual maximum vector size, in bytes, given the number of fixed-width values that either fit in the maximum overall vector size, or that is no larger than the maximum vector item count.static final int
Width of each fixed-width value.Fields inherited from class org.apache.drill.exec.vector.BaseDataValueVector
data, emptyByteArray
Fields inherited from class org.apache.drill.exec.vector.BaseValueVector
allocator, field, INITIAL_VALUE_ALLOCATION, MAX_ALLOCATION_SIZE
Fields inherited from interface org.apache.drill.exec.vector.ValueVector
BITS_VECTOR_NAME, MAX_BUFFER_SIZE, MAX_ROW_COUNT, MIN_ROW_COUNT, OFFSETS_VECTOR_NAME, VALUES_VECTOR_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Allocate new buffers.void
allocateNew
(int valueCount) Allocate a new memory space for this vector.boolean
Allocates new buffers.void
clear()
Release the underlying DrillBuf and reset the ValueVector to empty.void
copyEntry
(int toIndex, ValueVector from, int fromIndex) void
void
copyFromSafe
(int inIndex, int outIndex, BitVector from) void
exchange
(ValueVector other) Exchange state with another value vector of the same type.Returns anaccessor
that is used to read from this vector instance.int
Returns the number of bytes that is used by this vector instance.int
getBufferSizeFor
(int valueCount) Returns the number of bytes that is used by this vector if it holds the given number of values.Returns anmutator
that is used to write to this vector instance.int
getPayloadByteCount
(int valueCount) Return the number of value bytes consumed by actual data.Returns afield reader
that supports reading values from this vector.static int
getSizeFromCount
(int valueCount) getTransferPair
(String ref, BufferAllocator allocator) getTransferPair
(BufferAllocator allocator) Returns atransfer pair
, creating a new target vector of the same type.int
Returns the maximum number of values that can be stored in this vector instance.int
The width of a record in bytes.void
load
(UserBitShared.SerializedField metadata, DrillBuf buffer) Load the data provided in the buffer.Returns a newtransfer pair
that is used to transfer underlying buffers into the target vector.void
reAlloc()
Allocate new buffer with double capacity, and copy data into the new buffer.reallocRaw
(int newAllocationSize) Core of vector allocation.void
reset()
This method has a similar effect of allocateNew() without actually clearing and reallocating the value vector.void
setInitialCapacity
(int valueCount) Set the initial record capacityvoid
splitAndTransferTo
(int startIndex, int length, BitVector target) void
toNullable
(ValueVector nullableVector) Convert a non-nullable vector to nullable by shuffling the data from one to the other.void
transferTo
(BitVector target) void
Zero out the underlying buffer backing this vector.Methods inherited from class org.apache.drill.exec.vector.BaseDataValueVector
close, collectLedgers, getAllocatedSize, getBuffer, getBuffers
Methods inherited from class org.apache.drill.exec.vector.BaseValueVector
checkBufRefs, fillBitsVector, getAllocator, getField, getField, getMetadata, getMetadataBuilder, iterator, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.drill.exec.vector.ValueVector
close, collectLedgers, getAllocatedSize, getAllocator, getBuffers, getField, getMetadata
-
Field Details
-
VALUE_WIDTH
public static final int VALUE_WIDTHWidth of each fixed-width value.- See Also:
-
MAX_CAPACITY
public static final int MAX_CAPACITYMaximum number of values that this fixed-width vector can hold and stay below the maximum vector size limit. This is the limit enforced when the vector is used to hold values in a repeated vector. -
MAX_COUNT
public static final int MAX_COUNTMaximum number of values that this fixed-width vector can hold and stay below the maximum vector size limit and/or stay below the maximum item count. This is the limit enforced when the vector is used to hold required or nullable values. -
NET_MAX_SIZE
public static final int NET_MAX_SIZEActual maximum vector size, in bytes, given the number of fixed-width values that either fit in the maximum overall vector size, or that is no larger than the maximum vector item count.
-
-
Constructor Details
-
BitVector
-
-
Method Details
-
getReader
Description copied from interface:ValueVector
Returns afield reader
that supports reading values from this vector.- Specified by:
getReader
in interfaceValueVector
-
getBufferSize
public int getBufferSize()Description copied from interface:ValueVector
Returns the number of bytes that is used by this vector instance. This is a bit of a misnomer. Returns the number of bytes used by data in this instance.- Specified by:
getBufferSize
in interfaceValueVector
- Overrides:
getBufferSize
in classBaseDataValueVector
-
getBufferSizeFor
public int getBufferSizeFor(int valueCount) Description copied from interface:ValueVector
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 Mutator.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:
getBufferSizeFor
in interfaceValueVector
- Parameters:
valueCount
- the number of values to assume this vector contains- Returns:
- the buffer size if this vector is holding valueCount values
-
getSizeFromCount
public static int getSizeFromCount(int valueCount) -
getValueCapacity
public int getValueCapacity()Description copied from interface:ValueVector
Returns the maximum number of values that can be stored in this vector instance.- Specified by:
getValueCapacity
in interfaceValueVector
-
setInitialCapacity
public void setInitialCapacity(int valueCount) Description copied from interface:ValueVector
Set the initial record capacity- Specified by:
setInitialCapacity
in interfaceValueVector
-
allocateNew
public void allocateNew()Description copied from interface:ValueVector
Allocate new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNew
in interfaceValueVector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVector
Allocates new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewSafe
in interfaceValueVector
- Returns:
- Returns true if allocation was successful.
-
reset
public void reset()Description copied from class:BaseDataValueVector
This method has a similar effect of allocateNew() without actually clearing and reallocating the value vector. The purpose is to move the value vector to a "mutate" state- Overrides:
reset
in classBaseDataValueVector
-
allocateNew
public void allocateNew(int valueCount) Allocate a new memory space for this vector. Must be called prior to using the ValueVector.- Specified by:
allocateNew
in interfaceFixedWidthVector
- Parameters:
valueCount
- The number of values which can be contained within this vector.
-
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 -
reallocRaw
Description copied from class:BaseDataValueVector
Core of vector allocation. Given a new size (which must be a power of two), allocate the new buffer, copy the current values, and leave the unused parts garbage-filled.- Specified by:
reallocRaw
in classBaseDataValueVector
- Parameters:
newAllocationSize
- new buffer size as a power of two- Returns:
- the new buffer
-
zeroVector
public void zeroVector()Zero out the underlying buffer backing this vector.- Specified by:
zeroVector
in interfaceFixedWidthVector
-
getValueWidth
public int getValueWidth()Description copied from interface:FixedWidthVector
The width of a record in bytes.- Specified by:
getValueWidth
in interfaceFixedWidthVector
- Returns:
- The width of a record in bytes.
-
copyFrom
-
copyFromSafe
-
copyEntry
- Specified by:
copyEntry
in interfaceValueVector
-
getMutator
Description copied from interface:ValueVector
Returns anmutator
that is used to write to this vector instance.- Specified by:
getMutator
in interfaceValueVector
-
getAccessor
Description copied from interface:ValueVector
Returns anaccessor
that is used to read from this vector instance.- Specified by:
getAccessor
in interfaceValueVector
-
getTransferPair
Description copied from interface:ValueVector
Returns atransfer pair
, creating a new target vector of the same type.- Specified by:
getTransferPair
in interfaceValueVector
- Overrides:
getTransferPair
in classBaseValueVector
-
getTransferPair
- Specified by:
getTransferPair
in interfaceValueVector
-
makeTransferPair
Description copied from interface:ValueVector
Returns a newtransfer pair
that is used to transfer underlying buffers into the target vector.- Specified by:
makeTransferPair
in interfaceValueVector
-
transferTo
-
splitAndTransferTo
-
exchange
Description copied from interface:ValueVector
Exchange state with another value vector of the same type. Used to implement look-ahead writers.- Specified by:
exchange
in interfaceValueVector
- Overrides:
exchange
in classBaseDataValueVector
-
clear
public void clear()Description copied from interface:ValueVector
Release the underlying DrillBuf and reset the ValueVector to empty.- Specified by:
clear
in interfaceValueVector
- Overrides:
clear
in classBaseDataValueVector
-
getPayloadByteCount
public int getPayloadByteCount(int valueCount) Description copied from interface:ValueVector
Return the number of value bytes consumed by actual data.- Specified by:
getPayloadByteCount
in interfaceValueVector
-
toNullable
Description copied from interface:ValueVector
Convert a non-nullable vector to nullable by shuffling the data from one to the other. Avoids the need to generate copy code just to change mode. If this vector is non-nullable, accepts a nullable dual (same minor type, different mode.) If the vector is non-nullable, or non-scalar, then throws an exception.- Specified by:
toNullable
in interfaceValueVector
- Overrides:
toNullable
in classBaseValueVector
- Parameters:
nullableVector
- nullable vector of the same minor type as this vector
-