Package com.qfs.chunk

Interface IWritableBuffer

    • Method Detail

      • allocateVector

        IVector allocateVector​(int position,
                               int size)
        Allocates a vector with the given size at the specified position of the buffer and returns it.

        Warning: The vector will be uninitialized. The caller has the responsibility to initialize it.

        The content at the specified position will be replaced by the returned vector.

        This method should be used instead of IVector.cloneOnHeap() as it may decide to allocate the vector off-heap.

        Parameters:
        position - position 0-based index in an array
        size - the size of the vector
        Returns:
        a new uninitialized vector
      • isVectorWritable

        boolean isVectorWritable​(int position)
        Checks if the vector stored at the given position can be modified.

        Vectors that are shared by several components should not be modified in general as it can cause concurrency issues.

        Parameters:
        position - position 0-based index in an array
        Returns:
        true if the vector can be edited, false otherwise
      • readVector

        default IVector readVector​(int position)
        Reads an IVector value from the array.

        An exception is thrown if the value is not of the right type.

        Warning: readWritableVector(int) must be called instead of this method when one needs to modify the returned vector.

        Specified by:
        readVector in interface IArrayReader
        Parameters:
        position - 0-based index in an array
        Returns:
        vector instance
        See Also:
        readWritableVector(int)
      • readWritableVector

        default IVector readWritableVector​(int position)
        Returns the IVector at the given position.

        This method returns a vector that can be safely edited. If the vector stored at the given position in the buffer is not writable, it will be replaced with a copy.

        This is useful to implement lazy cloning.

        Parameters:
        position - position 0-based index in an array
        Returns:
        a safely modifiable vector
      • write

        void write​(int position,
                   IVector vector)
        Writes a vector at the given position.
        Parameters:
        position - the position at which to write the vector
        vector - the vector to write
      • write

        void write​(int position,
                   Object value)
        Writes a piece of data at a position in the array.

        For better performance, use the primitive type operations.

        Warning: This method does not accept an IVector as value. Use write(int, IVector) instead.

        Specified by:
        write in interface IArrayWriter
        Parameters:
        position - 0-based index in the array
        value - the value to write
        See Also:
        write(int, IVector)