Interface Chunk<ATTR extends Attributes.Any>

Type Parameters:
ATTR - Attributes that apply to this chunk
All Known Subinterfaces:
ChunkPage<ATTR>, ResettableChunk<ATTR_BASE>, ResettableReadOnlyChunk<ATTR_BASE>, ResettableWritableChunk<ATTR_BASE>, WritableChunk<ATTR>
All Known Implementing Classes:
BooleanChunk, BooleanChunkPage, ByteChunk, ByteChunkPage, CharChunk, CharChunkPage, ChunkBase, DoubleChunk, DoubleChunkPage, FloatChunk, FloatChunkPage, IntChunk, IntChunkPage, LongChunk, LongChunkPage, ObjectChunk, ObjectChunkPage, ResettableBooleanChunk, ResettableByteChunk, ResettableCharChunk, ResettableDoubleChunk, ResettableFloatChunk, ResettableIntChunk, ResettableLongChunk, ResettableObjectChunk, ResettableShortChunk, ResettableWritableBooleanChunk, ResettableWritableByteChunk, ResettableWritableCharChunk, ResettableWritableDoubleChunk, ResettableWritableFloatChunk, ResettableWritableIntChunk, ResettableWritableLongChunk, ResettableWritableObjectChunk, ResettableWritableShortChunk, ShortChunk, ShortChunkPage, WritableBooleanChunk, WritableByteChunk, WritableCharChunk, WritableDoubleChunk, WritableFloatChunk, WritableIntChunk, WritableLongChunk, WritableObjectChunk, WritableShortChunk

public interface Chunk<ATTR extends Attributes.Any>
Data structure for a contiguous region of data.
  • Field Details

  • Method Details

    • slice

      Chunk<ATTR> slice​(int offset, int capacity)
      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).
      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.
    • copyToChunk

      void copyToChunk​(int srcOffset, WritableChunk<? super ATTR> dest, int destOffset, int size)
      Copy a subrange of this Chunk to the subrange of the 'dest' writable chunk.
      Parameters:
      srcOffset - Starting position in 'this' (the source)
      dest - Destination writable chunk.
      destOffset - Starting offset in the destination.
      size - Number of values to copy
    • copyToArray

      void copyToArray​(int srcOffset, Object dest, int destOffset, int size)
      Copy a subrange of this Chunk to the subrange of the 'dest' array.
      Parameters:
      srcOffset - Starting position in 'this' (the source)
      dest - Destination array.
      destOffset - Starting offset in the destination.
      size - Number of values to copy
    • copyToBuffer

      default void copyToBuffer​(int srcOffset, @NotNull Buffer destBuffer, int destOffset, int length)

      Copy a sub-range of this chunk to 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, destOffset is an absolute offset from position 0, rather than a relative offset from destBuffer.position().

      It is required that destBuffer.limit() is at least destOffset + length.

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

      Parameters:
      srcOffset - The offset into this chunk to start copying from
      destBuffer - The destination Buffer
      destOffset - The absolute offset into destBuffer to start copying to
      length - The number of elements to copy
    • size

      int size()
      Returns:
      The length of the data in the chunk
    • getChunkType

      ChunkType getChunkType()
      Returns:
      The underlying chunk type
    • isAlias

      boolean isAlias​(Object object)
      Returns:
      true iff this and array are aliases, that is they refer to the same underlying data
    • isAlias

      boolean isAlias​(Chunk chunk)
      Returns:
      true iff this and chunk are aliases, that is they refer to the same underlying data
    • asByteChunk

      default ByteChunk<ATTR> asByteChunk()
    • asBooleanChunk

      default BooleanChunk<ATTR> asBooleanChunk()
    • asCharChunk

      default CharChunk<ATTR> asCharChunk()
    • asShortChunk

      default ShortChunk<ATTR> asShortChunk()
    • asIntChunk

      default IntChunk<ATTR> asIntChunk()
    • asLongChunk

      default LongChunk<ATTR> asLongChunk()
    • asFloatChunk

      default FloatChunk<ATTR> asFloatChunk()
    • asDoubleChunk

      default DoubleChunk<ATTR> asDoubleChunk()
    • asObjectChunk

      default <T> ObjectChunk<T,​ATTR> asObjectChunk()
    • downcast

      static <ATTR extends Attributes.Any,​ ATTR_DERIV extends ATTR> Chunk<ATTR_DERIV> downcast​(Chunk<ATTR> self)
      Downcast the attribute. When you know the data in this chunk which you plan to read is a more specific sub-type, you can downcast the attribute with this helper method. This might be necessary, for instance, when you have a KeyIndices chunk which you sort, and now want to treat it as an OrderedKeyIndices.
      ApiNote:
      Upcast should not be necessary on read-only chunks, as a read-only chunk method should accept an upper bound wildcard.