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
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum number of elements a chunk can contain.static final int
The threshold at which we should use System.arrayCopy rather than our own copystatic final int
The threshold at which we should use Array.fill rather than our own fill -
Method Summary
Modifier and TypeMethodDescriptiondefault BooleanChunk<ATTR>
default DoubleChunk<ATTR>
default FloatChunk<ATTR>
default <T> ObjectChunk<T,
ATTR> default ShortChunk<ATTR>
default void
checkChunkType
(ChunkType expected) void
copyToArray
(int srcOffset, Object dest, int destOffset, int size) Copy a subrange of this Chunk to the subrange of the 'dest' array.default void
copyToBuffer
(int srcOffset, @NotNull Buffer destBuffer, int destOffset, int length) Copy a sub-range of this chunk to aBuffer
.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.Downcast the attribute.boolean
boolean
int
size()
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.<V extends Chunk.Visitor<ATTR>>
Vwalk
(V visitor)
-
Field Details
-
SYSTEM_ARRAYCOPY_THRESHOLD
static final int SYSTEM_ARRAYCOPY_THRESHOLDThe threshold at which we should use System.arrayCopy rather than our own copy- See Also:
-
SYSTEM_ARRAYFILL_THRESHOLD
static final int SYSTEM_ARRAYFILL_THRESHOLDThe threshold at which we should use Array.fill rather than our own fill- See Also:
-
MAXIMUM_SIZE
static final int MAXIMUM_SIZEThe maximum number of elements a chunk can contain.- See Also:
-
-
Method Details
-
slice
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.sizecapacity
- 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
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
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 @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 fromdestBuffer.position()
.It is required that
destBuffer.limit()
is at leastdestOffset + 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 fromdestBuffer
- The destinationBuffer
destOffset
- The absolute offset intodestBuffer
to start copying tolength
- 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
-
checkChunkType
-
isAlias
- Returns:
- true iff this and array are aliases, that is they refer to the same underlying data
-
isAlias
- Returns:
- true iff this and chunk are aliases, that is they refer to the same underlying data
-
walk
-
asByteChunk
-
asBooleanChunk
-
asCharChunk
-
asShortChunk
-
asIntChunk
-
asLongChunk
-
asFloatChunk
-
asDoubleChunk
-
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.
- ApiNote:
- Upcast should not be necessary on read-only chunks, as a read-only chunk method should accept an upper bound wildcard.
-