Class NullableIntVector

All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, FixedWidthVector, NullableVector, ValueVector

public final class NullableIntVector extends BaseDataValueVector implements FixedWidthVector, NullableVector
NullableInt implements a vector of values which could be null. Elements in the vector are first checked against a fixed length vector of boolean values. Then the element is retrieved from the base class (if not null). NB: this class is automatically generated from NullableValueVectors.java and ValueVectorTypes.tdd using FreeMarker.
  • Constructor Details

  • Method Details

    • getReader

      public FieldReader getReader()
      Description copied from interface: ValueVector
      Returns a field reader that supports reading values from this vector.
      Specified by:
      getReader in interface ValueVector
    • 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 interface ValueVector
    • getBuffers

      public DrillBuf[] getBuffers(boolean clear)
      Description copied from interface: ValueVector
      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 interface ValueVector
      Overrides:
      getBuffers in class BaseDataValueVector
      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.
    • close

      public void close()
      Description copied from interface: ValueVector
      Alternative to clear(). Allows use as an AutoCloseable in try-with-resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ValueVector
      Overrides:
      close in class BaseDataValueVector
    • clear

      public void clear()
      Description copied from interface: ValueVector
      Release the underlying DrillBuf and reset the ValueVector to empty.
      Specified by:
      clear in interface ValueVector
      Overrides:
      clear in class BaseDataValueVector
    • 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 interface ValueVector
      Overrides:
      getBufferSize in class BaseDataValueVector
    • 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 interface ValueVector
      Parameters:
      valueCount - the number of values to assume this vector contains
      Returns:
      the buffer size if this vector is holding valueCount values
    • getAllocatedSize

      public int getAllocatedSize()
      Description copied from interface: ValueVector
      Returns the total size of buffers allocated by this vector. Has meaning only when vectors are directly allocated and each vector has its own buffer. Does not have meaning for vectors deserialized from the network or disk in which multiple vectors share the same vector.
      Specified by:
      getAllocatedSize in interface ValueVector
      Overrides:
      getAllocatedSize in class BaseDataValueVector
      Returns:
      allocated buffer size, in bytes
    • getBuffer

      public DrillBuf getBuffer()
      Overrides:
      getBuffer in class BaseDataValueVector
    • getValuesVector

      public IntVector getValuesVector()
      Specified by:
      getValuesVector in interface NullableVector
    • getBitsVector

      public UInt1Vector getBitsVector()
      Specified by:
      getBitsVector in interface NullableVector
    • setInitialCapacity

      public void setInitialCapacity(int numRecords)
      Description copied from interface: ValueVector
      Set the initial record capacity
      Specified by:
      setInitialCapacity in interface ValueVector
    • getMetadataBuilder

      public UserBitShared.SerializedField.Builder getMetadataBuilder()
      Overrides:
      getMetadataBuilder in class BaseValueVector
    • 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 interface ValueVector
    • 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 interface ValueVector
      Returns:
      Returns true if allocation was successful.
    • reallocRaw

      public DrillBuf reallocRaw(int newAllocationSize)
      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 class BaseDataValueVector
      Parameters:
      newAllocationSize - new buffer size as a power of two
      Returns:
      the new buffer
    • collectLedgers

      public void collectLedgers(Set<AllocationManager.BufferLedger> ledgers)
      Description copied from interface: ValueVector
      Add the ledgers underlying the buffers underlying the components of the vector to the set provided. Used to determine actual memory allocation.
      Specified by:
      collectLedgers in interface ValueVector
      Overrides:
      collectLedgers in class BaseDataValueVector
      Parameters:
      ledgers - set of ledgers to which to add ledgers for this vector
    • 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 interface ValueVector
    • getValueWidth

      public int getValueWidth()
      Description copied from interface: FixedWidthVector
      The width of a record in bytes.
      Specified by:
      getValueWidth in interface FixedWidthVector
      Returns:
      The width of a record in bytes.
    • allocateNew

      public void allocateNew(int valueCount)
      Description copied from interface: FixedWidthVector
      Allocate a new memory space for this vector. Must be called prior to using the ValueVector.
      Specified by:
      allocateNew in interface FixedWidthVector
      Parameters:
      valueCount - Number of values in the vector.
    • 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 class BaseDataValueVector
    • zeroVector

      public void zeroVector()
      Zero out the underlying buffer backing this vector.
      Specified by:
      zeroVector in interface FixedWidthVector
    • load

      public void load(UserBitShared.SerializedField metadata, DrillBuf buffer)
      Description copied from interface: ValueVector
      Load the data provided in the buffer. Typically used when deserializing from the wire.
      Specified by:
      load in interface ValueVector
      Parameters:
      metadata - Metadata used to decode the incoming buffer.
      buffer - The buffer that contains the ValueVector.
    • getTransferPair

      public TransferPair getTransferPair(BufferAllocator allocator)
      Description copied from interface: ValueVector
      Returns a transfer pair, creating a new target vector of the same type.
      Specified by:
      getTransferPair in interface ValueVector
      Overrides:
      getTransferPair in class BaseValueVector
    • getTransferPair

      public TransferPair getTransferPair(String ref, BufferAllocator allocator)
      Specified by:
      getTransferPair in interface ValueVector
    • makeTransferPair

      public TransferPair makeTransferPair(ValueVector to)
      Description copied from interface: ValueVector
      Returns a new transfer pair that is used to transfer underlying buffers into the target vector.
      Specified by:
      makeTransferPair in interface ValueVector
    • transferTo

      public void transferTo(NullableIntVector target)
    • splitAndTransferTo

      public void splitAndTransferTo(int startIndex, int length, NullableIntVector target)
    • getAccessor

      public NullableIntVector.Accessor getAccessor()
      Description copied from interface: ValueVector
      Returns an accessor that is used to read from this vector instance.
      Specified by:
      getAccessor in interface ValueVector
    • getMutator

      public NullableIntVector.Mutator getMutator()
      Description copied from interface: ValueVector
      Returns an mutator that is used to write to this vector instance.
      Specified by:
      getMutator in interface ValueVector
    • convertToRequiredVector

      public IntVector convertToRequiredVector()
    • getBitsValueCapacity

      public int getBitsValueCapacity()
      Returns:
      Underlying "bits" vector value capacity
    • copyFrom

      public void copyFrom(int fromIndex, int thisIndex, NullableIntVector from)
    • copyFromSafe

      public void copyFromSafe(int fromIndex, int thisIndex, IntVector from)
    • copyFromSafe

      public void copyFromSafe(int fromIndex, int thisIndex, NullableIntVector from)
    • copyEntry

      public void copyEntry(int toIndex, ValueVector from, int fromIndex)
      Specified by:
      copyEntry in interface ValueVector
    • exchange

      public void exchange(ValueVector other)
      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 interface ValueVector
      Overrides:
      exchange in class BaseDataValueVector
    • toNullable

      public void toNullable(ValueVector nullableVector)
      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 interface ValueVector
      Overrides:
      toNullable in class BaseValueVector
      Parameters:
      nullableVector - nullable vector of the same minor type as this vector