Class WritableCharChunk<ATTR extends Attributes.Any>

java.lang.Object
com.illumon.iris.db.v2.sources.chunk.ChunkBase<ATTR>
com.illumon.iris.db.v2.sources.chunk.CharChunk<ATTR>
com.illumon.iris.db.v2.sources.chunk.WritableCharChunk<ATTR>
All Implemented Interfaces:
Chunk<ATTR>, PoolableChunk, WritableChunk<ATTR>, SafeCloseable, AutoCloseable
Direct Known Subclasses:
ResettableWritableCharChunk

public class WritableCharChunk<ATTR extends Attributes.Any> extends CharChunk<ATTR> implements WritableChunk<ATTR>
WritableChunk implementation for char data.
  • Method Details

    • makeWritableChunk

      public static <ATTR extends Attributes.Any> WritableCharChunk<ATTR> makeWritableChunk(int size)
      Retrieve a WritableCharChunk of the specified size.

      Note that the returned chunk may have a larger capacity than requested, and its size will be set to size.

      Users must take care to close() the chunk when finished.

      Parameters:
      size - the desired size of the chunk.
      Returns:
      A WritableCharChunk of the requested size.
    • makeWritableChunkForPool

      public static <ATTR extends Attributes.Any> WritableCharChunk<ATTR> makeWritableChunkForPool(int size)
      Create a WritableCharChunk of the specified size. The returned chunk will have exactly the requested capacity, and its size will be set to size.
      Parameters:
      size - the desired size of the chunk.
      Returns:
      A WritableCharChunk of the requested size.
    • writableChunkWrap

      public static <ATTR extends Attributes.Any> WritableCharChunk<ATTR> writableChunkWrap(@NotNull char[] data)
      Wrap the specified array in a WritableCharChunk. The ChunkBase.size() will be initialized to the data length.
      Parameters:
      data - the array to wrap
      Returns:
      A new WritableCharChunk backed by the specified array.
    • writableChunkWrap

      public static <ATTR extends Attributes.Any> WritableCharChunk<ATTR> writableChunkWrap(@NotNull char[] data, int offset, int size)
      Wrap the specified array in a WritableCharChunk.
      Parameters:
      data - the array to wrap
      Returns:
      A new WritableCharChunk backed by the specified array.
    • set

      public final void set(int index, char value)
    • add

      public final void add(char value)
      Add the specified value to the chunk. The value will be added at the position ChunkBase.size(), and the ChunkBase.size() will be incremented.
      Parameters:
      value - the value to add
    • slice

      public WritableCharChunk<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 Attributes.Any>
      Specified by:
      slice in interface WritableChunk<ATTR extends Attributes.Any>
      Overrides:
      slice in class CharChunk<ATTR extends Attributes.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

      public final void fillWithNullValue(int offset, int length)
      Description copied from interface: WritableChunk
      Fill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.
      Specified by:
      fillWithNullValue in interface WritableChunk<ATTR extends Attributes.Any>
      Parameters:
      offset - Starting offset
      length - Number of values to fill
    • fillWithBoxedValue

      public final void fillWithBoxedValue(int offset, int size, Object value)
      Description copied from interface: WritableChunk
      Fill a sub-range of this writable chunk with the given value, unboxing it as appropriate.
      Specified by:
      fillWithBoxedValue in interface WritableChunk<ATTR extends Attributes.Any>
      Parameters:
      offset - Starting offset
      size - Number of values to fill
    • fillWithValue

      public final void fillWithValue(int offset, int length, char value)
    • appendTypedChunk

      public final void appendTypedChunk(CharChunk<? extends ATTR> src, int srcOffset, int length)
    • copyFromChunk

      public final void copyFromChunk(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length)
      Specified by:
      copyFromChunk in interface WritableChunk<ATTR extends Attributes.Any>
    • copyFromTypedChunk

      public final void copyFromTypedChunk(CharChunk<? extends ATTR> src, int srcOffset, int destOffset, int length)
    • copyFromArray

      public final void copyFromArray(Object srcArray, int srcOffset, int destOffset, int length)
      Specified by:
      copyFromArray in interface WritableChunk<ATTR extends Attributes.Any>
    • copyFromTypedArray

      public final void copyFromTypedArray(char[] src, int srcOffset, int destOffset, int length)
    • copyFromBuffer

      public final void copyFromBuffer(@NotNull Buffer srcBuffer, int srcOffset, int destOffset, int length)
      Description copied from interface: WritableChunk

      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.

      Specified by:
      copyFromBuffer in interface WritableChunk<ATTR extends Attributes.Any>
      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
    • copyFromTypedBuffer

      public final void copyFromTypedBuffer(@NotNull CharBuffer srcBuffer, int srcOffset, int destOffset, int length)

      Fill a sub-range of this WritableCharChunk with values from a CharBuffer.

      See copyFromBuffer(Buffer, int, int, int) for general documentation.

      Parameters:
      srcBuffer - The source CharBuffer
      srcOffset - The absolute offset into srcBuffer to start copying from
      destOffset - The offset into this chunk to start copying to
      length - The number of elements to copy
    • getChunkFiller

      public final ChunkFiller getChunkFiller()
      Description copied from interface: WritableChunk
      Our ChunkFiller "plugin".
      Specified by:
      getChunkFiller in interface WritableChunk<ATTR extends Attributes.Any>
    • sort

      public final void sort()
      Description copied from interface: WritableChunk
      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.
      Specified by:
      sort in interface WritableChunk<ATTR extends Attributes.Any>
    • sort

      public final void sort(int start, int length)
      Description copied from interface: WritableChunk
      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.
      Specified by:
      sort in interface WritableChunk<ATTR extends Attributes.Any>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • upcast

      public static <ATTR extends Attributes.Any, ATTR_DERIV extends ATTR> WritableCharChunk<ATTR> upcast(WritableCharChunk<ATTR_DERIV> self)
    • downcast

      public static <ATTR extends Attributes.Any, ATTR_DERIV extends ATTR> WritableCharChunk<ATTR_DERIV> downcast(WritableCharChunk<ATTR> self)