Class ShortChunk<ATTR extends Any>
- All Implemented Interfaces:
Chunk<ATTR>
- Direct Known Subclasses:
ResettableShortChunk
,ShortChunkPage
,WritableShortChunk
Chunk
implementation for short data.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.chunk.Chunk
Chunk.Visitor<ATTR extends Any>
-
Field Summary
Fields inherited from interface io.deephaven.chunk.Chunk
MAXIMUM_SIZE, SYSTEM_ARRAYCOPY_THRESHOLD, SYSTEM_ARRAYFILL_THRESHOLD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal int
binarySearch
(int fromIndexInclusive, int toIndexExclusive, short key) Search forkey
in this chunk in the index range[fromIndexInclusive, toIndexExclusive)
using Java's primitive ordering.final int
binarySearch
(short key) Search forkey
in this chunk in the index range [0,size
) using Java's primitive ordering.static <ATTR extends Any>
ShortChunk<ATTR>chunkWrap
(short[] data) static <ATTR extends Any>
ShortChunk<ATTR>chunkWrap
(short[] data, int offset, int capacity) final void
copyToArray
(int srcOffset, Object dest, int destOffset, int length) Copy a subrange of this Chunk to the subrange of the 'dest' array.final void
copyToBuffer
(int srcOffset, @NotNull Buffer destBuffer, int destOffset, int length) Copy a sub-range of this chunk to aBuffer
.final void
copyToChunk
(int srcOffset, WritableChunk<? super ATTR> dest, int destOffset, int length) Copy a subrange of this Chunk to the subrange of the 'dest' writable chunk.final void
copyToTypedArray
(int srcOffset, short[] destData, int destOffset, int length) final void
copyToTypedBuffer
(int srcOffset, @NotNull ShortBuffer destBuffer, int destOffset, int length) Copy a sub-range of this ShortChunk to aShortBuffer
.static <ATTR extends Any,
ATTR_DERIV extends ATTR>
ShortChunk<ATTR_DERIV>downcast
(ShortChunk<ATTR> self) final short
get
(int index) final ChunkType
static <ATTR extends Any>
ShortChunk<ATTR>final boolean
final boolean
static short[]
makeArray
(int capacity) 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.final <V extends Chunk.Visitor<ATTR>>
Vwalk
(V visitor) Methods inherited from class io.deephaven.chunk.ChunkBase
internalCapacity, internalSetSize, size
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.deephaven.chunk.Chunk
asBooleanChunk, asByteChunk, asCharChunk, asDoubleChunk, asFloatChunk, asIntChunk, asLongChunk, asObjectChunk, asShortChunk, checkChunkType
-
Constructor Details
-
ShortChunk
protected ShortChunk(short[] data, int offset, int capacity)
-
-
Method Details
-
getEmptyChunk
-
makeArray
public static short[] makeArray(int capacity) -
chunkWrap
-
chunkWrap
-
getChunkType
- Returns:
- The underlying chunk type
-
get
public final short get(int index) -
slice
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).- 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
public final void copyToChunk(int srcOffset, WritableChunk<? super ATTR> dest, int destOffset, int length) Description copied from interface:Chunk
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.length
- Number of values to copy
-
copyToArray
Description copied from interface:Chunk
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.length
- Number of values to copy
-
copyToTypedArray
public final void copyToTypedArray(int srcOffset, short[] destData, int destOffset, int length) -
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
-
copyToBuffer
public final void copyToBuffer(int srcOffset, @NotNull @NotNull Buffer destBuffer, int destOffset, int length) Description copied from interface:Chunk
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
-
copyToTypedBuffer
public final void copyToTypedBuffer(int srcOffset, @NotNull @NotNull ShortBuffer destBuffer, int destOffset, int length) Copy a sub-range of this ShortChunk to a
ShortBuffer
.See
copyToBuffer(int, Buffer, int, int)
for general documentation.- Parameters:
srcOffset
- The offset into this chunk to start copying fromdestBuffer
- The destinationShortBuffer
destOffset
- The absolute offset intodestBuffer
to start copying tolength
- The number of elements to copy
-
downcast
public static <ATTR extends Any,ATTR_DERIV extends ATTR> ShortChunk<ATTR_DERIV> downcast(ShortChunk<ATTR> self) -
binarySearch
public final int binarySearch(short key) Search forkey
in this chunk in the index range [0,size
) using Java's primitive ordering. This chunk must be sorted as byWritableShortChunk.sort()
prior to this call.This method does not compare
null
orNaN
values according to Deephaven ordering rules.- Parameters:
key
- The key to search for- Returns:
- The index of the key in this chunk, or else
(-(insertion point) - 1)
as defined byArrays.binarySearch(long[], long)
-
binarySearch
public final int binarySearch(int fromIndexInclusive, int toIndexExclusive, short key) Search forkey
in this chunk in the index range[fromIndexInclusive, toIndexExclusive)
using Java's primitive ordering. This chunk must be sorted over the search index range as byWritableShortChunk.sort(int, int)
prior to this call.This method does not compare
null
orNaN
values according to Deephaven ordering rules.- Parameters:
fromIndexInclusive
- The first index to be searchedtoIndexExclusive
- The index after the last index to be searchedkey
- The key to search for- Returns:
- The index of the key in this chunk, or else
(-(insertion point) - 1)
as defined byArrays.binarySearch(short[], int, int, short)
-