Interface Chunk<ATTR extends Any>

Type Parameters:
ATTR - Descriptive attribute that applies to the elements stored within 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 Any>
Data structure for a contiguous region of data.
  • Field Details


      static final int SYSTEM_ARRAYCOPY_THRESHOLD
      The threshold at which we should use System.arrayCopy rather than our own copy
      See Also:
      Constant Field Values

      static final int SYSTEM_ARRAYFILL_THRESHOLD
      The threshold at which we should use Array.fill rather than our own fill
      See Also:
      Constant Field Values

      static final int MAXIMUM_SIZE
      The maximum number of elements a chunk can contain.
      See Also:
      Constant Field Values
  • 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).
      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.
      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.
      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.
      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.

      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()
      The length of the data in the chunk
    • getChunkType

      ChunkType getChunkType()
      The underlying chunk type
    • checkChunkType

      default void checkChunkType​(ChunkType expected)
    • isAlias

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

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

      <V extends Chunk.Visitor<ATTR>> V walk​(V visitor)
    • 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 Any,​ ATTR_DERIV extends ATTR> Chunk<ATTR_DERIV> downcast​(Chunk<? extends 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 RowKeys chunk which you sort, and now want to treat it as an OrderedRowKeys.
      Upcast should not be necessary on read-only chunks, as a read-only chunk method should accept an upper bound wildcard.