public interface ValueVector extends Closeable, Iterable<ValueVector>
value vector
stores underlying data in-memory in a
columnar fashion that is compact and efficient. The column whose data is
stored, is referred by getField()
.
A vector when instantiated, relies on a
dead buffer
. It is important
that vector is allocated before attempting to read or write.
There are a few "rules" around vectors:
MAX_BUFFER_SIZE
to prevent memory fragmentation. Use the
setBounded() methods in the mutator to enforce this rule.allocate > mutate > setvaluecount > access > clear (or allocate to start the process over).
Modifier and Type | Interface and Description |
---|---|
static interface |
ValueVector.Accessor
Reads from this vector instance.
|
static interface |
ValueVector.Mutator
Writes into this vector instance.
|
Modifier and Type | Field and Description |
---|---|
static String |
BITS_VECTOR_NAME |
static int |
MAX_BUFFER_SIZE
Maximum allowed size of the buffer backing a value vector.
|
static int |
MAX_ROW_COUNT
Maximum allowed row count in a vector.
|
static int |
MIN_ROW_COUNT |
static String |
OFFSETS_VECTOR_NAME |
static String |
VALUES_VECTOR_NAME
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
allocateNew()
Allocate new buffers.
|
boolean |
allocateNewSafe()
Allocates new buffers.
|
void |
clear()
Release the underlying DrillBuf and reset the ValueVector to empty.
|
void |
close()
Alternative to clear().
|
void |
collectLedgers(Set<AllocationManager.BufferLedger> ledgers)
Add the ledgers underlying the buffers underlying the components of the
vector to the set provided.
|
void |
copyEntry(int toIndex,
ValueVector from,
int fromIndex) |
void |
exchange(ValueVector other)
Exchange state with another value vector of the same type.
|
ValueVector.Accessor |
getAccessor()
Returns an
accessor that is used to read from this vector
instance. |
int |
getAllocatedSize()
Returns the total size of buffers allocated by this vector.
|
BufferAllocator |
getAllocator() |
DrillBuf[] |
getBuffers(boolean clear)
Return the underlying buffers associated with this vector.
|
int |
getBufferSize()
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.
|
MaterializedField |
getField()
Get information about how this field is materialized.
|
UserBitShared.SerializedField |
getMetadata()
Get the metadata for this field.
|
ValueVector.Mutator |
getMutator()
Returns an
mutator that is used to write to this vector
instance. |
int |
getPayloadByteCount(int valueCount)
Return the number of value bytes consumed by actual data.
|
FieldReader |
getReader()
Returns a
field reader that supports reading values
from this vector. |
TransferPair |
getTransferPair(BufferAllocator allocator)
Returns a
transfer pair , creating a new target vector of
the same type. |
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator) |
int |
getValueCapacity()
Returns the maximum number of values that can be stored in this vector instance.
|
void |
load(UserBitShared.SerializedField metadata,
DrillBuf buffer)
Load the data provided in the buffer.
|
TransferPair |
makeTransferPair(ValueVector target)
Returns a new
transfer pair that is used to transfer underlying
buffers into the target vector. |
void |
setInitialCapacity(int numRecords)
Set the initial record capacity
|
void |
toNullable(ValueVector nullableVector)
Convert a non-nullable vector to nullable by shuffling the data from
one to the other.
|
forEach, iterator, spliterator
static final int MAX_BUFFER_SIZE
static final int MAX_ROW_COUNT
static final int MIN_ROW_COUNT
static final String BITS_VECTOR_NAME
static final String OFFSETS_VECTOR_NAME
@Deprecated static final String VALUES_VECTOR_NAME
void allocateNew() throws OutOfMemoryException
OutOfMemoryException
- Thrown if no memory can be allocated.boolean allocateNewSafe()
BufferAllocator getAllocator()
void setInitialCapacity(int numRecords)
numRecords
- int getValueCapacity()
void close()
close
in interface AutoCloseable
close
in interface Closeable
void clear()
MaterializedField getField()
TransferPair getTransferPair(BufferAllocator allocator)
transfer pair
, creating a new target vector of
the same type.TransferPair getTransferPair(String ref, BufferAllocator allocator)
TransferPair makeTransferPair(ValueVector target)
transfer pair
that is used to transfer underlying
buffers into the target vector.ValueVector.Accessor getAccessor()
accessor
that is used to read from this vector
instance.ValueVector.Mutator getMutator()
mutator
that is used to write to this vector
instance.FieldReader getReader()
field reader
that supports reading values
from this vector.UserBitShared.SerializedField getMetadata()
int getBufferSize()
int getAllocatedSize()
int getBufferSizeFor(int valueCount)
valueCount
- the number of values to assume this vector containsDrillBuf[] getBuffers(boolean clear)
clear
- 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.void load(UserBitShared.SerializedField metadata, DrillBuf buffer)
metadata
- Metadata used to decode the incoming buffer.buffer
- The buffer that contains the ValueVector.void copyEntry(int toIndex, ValueVector from, int fromIndex)
void collectLedgers(Set<AllocationManager.BufferLedger> ledgers)
ledgers
- set of ledgers to which to add ledgers for this vectorint getPayloadByteCount(int valueCount)
void exchange(ValueVector other)
void toNullable(ValueVector nullableVector)
nullableVector
- nullable vector of the same minor type as
this vectorCopyright © 1970 The Apache Software Foundation. All rights reserved.