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 Summary
Fields Modifier and Type Field Description static int
MAXIMUM_SIZE
The maximum number of elements a chunk can contain.static int
SYSTEM_ARRAYCOPY_THRESHOLD
The threshold at which we should use System.arrayCopy rather than our own copystatic int
SYSTEM_ARRAYFILL_THRESHOLD
The threshold at which we should use Array.fill rather than our own fill -
Method Summary
Modifier and Type Method Description default BooleanChunk<ATTR>
asBooleanChunk()
default ByteChunk<ATTR>
asByteChunk()
default CharChunk<ATTR>
asCharChunk()
default DoubleChunk<ATTR>
asDoubleChunk()
default FloatChunk<ATTR>
asFloatChunk()
default IntChunk<ATTR>
asIntChunk()
default LongChunk<ATTR>
asLongChunk()
default <T> ObjectChunk<T,ATTR>
asObjectChunk()
default ShortChunk<ATTR>
asShortChunk()
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, 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.static <ATTR extends Attributes.Any, ATTR_DERIV extends ATTR>
Chunk<ATTR_DERIV>downcast(Chunk<ATTR> self)
Downcast the attribute.ChunkType
getChunkType()
boolean
isAlias(Chunk chunk)
boolean
isAlias(Object object)
int
size()
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.
-
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:
- Constant Field Values
-
SYSTEM_ARRAYFILL_THRESHOLD
static final int SYSTEM_ARRAYFILL_THRESHOLDThe threshold at which we should use Array.fill rather than our own fill- See Also:
- Constant Field Values
-
MAXIMUM_SIZE
static final int MAXIMUM_SIZEThe maximum number of elements a chunk can contain.- See Also:
- Constant Field Values
-
-
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
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
-
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
-
asByteChunk
-
asBooleanChunk
-
asCharChunk
-
asShortChunk
-
asIntChunk
-
asLongChunk
-
asFloatChunk
-
asDoubleChunk
-
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.
-