Class VecBufferBlocks


  • public class VecBufferBlocks
    extends CompoundVecBuffer
    VecBufferBlocks provides storage and retrieval of a set of potentially random VecBuffer blocks in a single backing ByteBuffer. Its is assumeed that the backing ByteBuffer already contains the necessary data, and the caller defines which regions in the ByteBuffer define each individual VecBuffer. VecBuffers are defined by calling addBlock(int, int), where the positions define the byte range containing a VecBuffer's data.
    • Field Detail

      • coordsPerVec

        protected int coordsPerVec
      • dataType

        protected java.lang.String dataType
      • buffer

        protected java.nio.ByteBuffer buffer
    • Constructor Detail

      • VecBufferBlocks

        public VecBufferBlocks​(int coordsPerVec,
                               java.lang.String dataType,
                               java.nio.ByteBuffer buffer,
                               int capacity)
        Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, backing ByteBuffer and the specified initial capacity. This interprets the ByteBuffer according to the specified primitive data type and number of coordinates per logical vector, and does not modify the ByteBuffer in any way. This assumes the buffer's position and limit are not changed by the caller for the lifetime of this instance.
        Parameters:
        coordsPerVec - the number of coordinates per logical vector.
        dataType - the primitive data type.
        buffer - the backing ByteBuffer.
        capacity - the PackedCompoundVecBuffer's initial capacity, in number of sub-buffers.
        Throws:
        java.lang.IllegalArgumentException - if the coordsPerVec is less than 1, if the dataType is null, if the buffer is null, or if the capacity is less than 1.
      • VecBufferBlocks

        public VecBufferBlocks​(int coordsPerVec,
                               java.lang.String dataType,
                               java.nio.ByteBuffer buffer)
        Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, and backing ByteBuffer. This interprets the ByteBuffer according to the specified primitive data type and number of coordinates per logical vector, and does not modify the ByteBuffer in any way. This assumes the buffer's position and limit are not changed by the caller for the lifetime of this instance.
        Parameters:
        coordsPerVec - the number of coordinates per logical vector.
        dataType - the primitive data type.
        buffer - the backing ByteBuffer.
        Throws:
        java.lang.IllegalArgumentException - if the coordsPerVec is less than 1, if the dataType is null, or if the buffer is null.
      • VecBufferBlocks

        protected VecBufferBlocks​(VecBufferBlocks that,
                                  int beginIndex,
                                  int endIndex)
      • VecBufferBlocks

        protected VecBufferBlocks​(VecBufferBlocks that,
                                  int[] indices,
                                  int offset,
                                  int length)
    • Method Detail

      • subBufferSize

        public int subBufferSize​(int index)
        Returns the size in logical vectors of the VecBuffer with the specified index.
        Specified by:
        subBufferSize in class CompoundVecBuffer
        Parameters:
        index - the index for the VecBuffer who's size is returned.
        Returns:
        the size of the specified VecBuffer.
      • getCoordsPerVec

        public int getCoordsPerVec()
        Returns the number of coordinates per logical vector element.
        Specified by:
        getCoordsPerVec in class CompoundVecBuffer
        Returns:
        the cardinality of a logical vector element.
      • getDataType

        public java.lang.String getDataType()
        Returns the primitive data type used to interpret the elements of this VecBufferBlocks' backing ByteBuffer.
        Returns:
        this VecBufferBlocks' primitive data type.
      • getBuffer

        public java.nio.ByteBuffer getBuffer()
        Returns the ByteBuffer that stores this VecBufferBlocks' sub-buffers.
        Returns:
        this VecBufferBlocks' backing ByteBuffer.
      • addBlock

        public int addBlock​(int beginPos,
                            int endPos)
        Adds a range of bytes that define a new sub-buffer within this VecBufferBlocks. This contents of this buffer's backing ByteBuffer is not changed, nor are its position and limit. The specified range must define a sequence of bytes representing logical vector elements according to this buffer's number of coordinates per logical vector, and this buffer's primitive data type.
        Parameters:
        beginPos - the byte range's beginning position.
        endPos - the byte range's ending position (inclusive).
        Returns:
        the sub-buffer's index.
        Throws:
        java.lang.IllegalArgumentException - if either the position are less than zero, if either position is greater than the backing buffer's capacity, or if the begin position is greater than the end position.