Interface WritableChunk<ATTR extends Any>

Type Parameters:
ATTR - Descriptive attribute that applies to the elements stored within this WritableChunk
All Superinterfaces:
AutoCloseable, Chunk<ATTR>, PoolableChunk, SafeCloseable
All Known Subinterfaces:
ResettableWritableChunk<ATTR_BASE>
All Known Implementing Classes:
ResettableWritableBooleanChunk, ResettableWritableByteChunk, ResettableWritableCharChunk, ResettableWritableDoubleChunk, ResettableWritableFloatChunk, ResettableWritableIntChunk, ResettableWritableLongChunk, ResettableWritableObjectChunk, ResettableWritableShortChunk, WritableBooleanChunk, WritableByteChunk, WritableCharChunk, WritableDoubleChunk, WritableFloatChunk, WritableIntChunk, WritableLongChunk, WritableObjectChunk, WritableShortChunk

public interface WritableChunk<ATTR extends Any> extends Chunk<ATTR>, PoolableChunk
Data structure for a contiguous region of data that may be mutated.
  • Method Details

    • slice

      WritableChunk<ATTR> slice(int offset, int capacity)
      Description copied from interface: Chunk
      Make a new Chunk that represents either exactly the same view on the underlying data as this Chunk, or a subrange of that view. The view is defined as [0..size) (in the coordinate space of this Chunk).
      Specified by:
      slice in interface Chunk<ATTR extends Any>
      Parameters:
      offset - Offset of the new Chunk, relative to this Chunk. 0 ≤ offset ≤ this.size
      capacity - Capacity and initial size of the new Chunk. 0 ≤ capacity ≤ this.size - offset.
      Returns:
      The new Chunk. A new Chunk will always be returned, even if the Chunks represent the same view.
    • fillWithNullValue

      default void fillWithNullValue(int offset, int size)
      Fill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.
      Parameters:
      offset - Starting offset
      size - Number of values to fill
    • fillWithBoxedValue

      default void fillWithBoxedValue(int offset, int size, Object value)
      Fill a sub-range of this writable chunk with the given value, unboxing it as appropriate.
      Parameters:
      offset - Starting offset
      size - Number of values to fill
    • copyFromChunk

      void copyFromChunk(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length)
    • copyFromArray

      void copyFromArray(Object srcArray, int srcOffset, int destOffset, int length)
    • copyFromBuffer

      default void copyFromBuffer(Buffer srcBuffer, int srcOffset, int destOffset, int length)

      Fill a sub-range of this writable chunk with values from a Buffer. This is an optional method, as some chunk types do not have a corresponding buffer type.

      Implementations are free to copy data as efficiently as they may, and will use absolute rather than positional access where possible. To facilitate this pattern, srcOffset is an absolute offset from position 0, rather than a relative offset from srcBuffer.position().

      It is required that srcBuffer.limit() is at least srcOffset + length.

      srcBuffer's position may be modified, but will always be restored to its initial value upon successful return.

      Parameters:
      srcBuffer - The source buffer, which will be cast to the appropriate type for this chunk
      srcOffset - The offset into srcBuffer (from position 0, not srcBuffer.position()) to start copying from
      destOffset - The offset into this chunk to start copying to
      length - The number of elements to copy
    • setSize

      default void setSize(int newSize)
    • internalSetSize

      void internalSetSize(int newSize, long password)
      DO NOT CALL THIS INTERNAL METHOD. If you want to set a size, call setSize(int). That method is the only legal caller of this method in the entire system.
    • capacity

      default int capacity()
    • internalCapacity

      int internalCapacity(long password)
      DO NOT CALL THIS INTERNAL METHOD. Call capacity() That method is the only legal caller of this method in the entire system.
    • sort

      void sort()
      Sort this chunk in-place using Java's primitive defined ordering.

      Of note is that nulls or NaNs are not sorted according to Deephaven ordering rules.

    • sort

      default void sort(int start, int length)
      Sort this chunk in-place using Java's primitive defined ordering.

      Of note is that nulls or NaNs are not sorted according to Deephaven ordering rules.

    • asWritableByteChunk

      default WritableByteChunk<ATTR> asWritableByteChunk()
    • asWritableBooleanChunk

      default WritableBooleanChunk<ATTR> asWritableBooleanChunk()
    • asWritableCharChunk

      default WritableCharChunk<ATTR> asWritableCharChunk()
    • asWritableShortChunk

      default WritableShortChunk<ATTR> asWritableShortChunk()
    • asWritableIntChunk

      default WritableIntChunk<ATTR> asWritableIntChunk()
    • asWritableLongChunk

      default WritableLongChunk<ATTR> asWritableLongChunk()
    • asWritableFloatChunk

      default WritableFloatChunk<ATTR> asWritableFloatChunk()
    • asWritableDoubleChunk

      default WritableDoubleChunk<ATTR> asWritableDoubleChunk()
    • asWritableObjectChunk

      default <T> WritableObjectChunk<T,ATTR> asWritableObjectChunk()
    • upcast

      static <ATTR extends Any, ATTR_DERIV extends ATTR> WritableChunk<ATTR> upcast(WritableChunk<ATTR_DERIV> self)
      Upcast the attribute.

      When you know the data you will receive in this chunk from another source is a more specific sub-type than the source provides, you can upcast the attribute with this helper method (such as reading RowKeys from a ColumnSource which thinks they are just Values.)

      ApiNote:
      Downcast should not be necessary on WritableChunks, as a WritableChunk filling method should accept an lower bound wildcard.