Class WritableShortChunk<ATTR extends Any>
- All Implemented Interfaces:
Chunk<ATTR>,PoolableChunk<ATTR>,WritableChunk<ATTR>,SafeCloseable,AutoCloseable
- Direct Known Subclasses:
ResettableWritableShortChunk
WritableChunk 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
ConstructorsModifierConstructorDescriptionprotectedWritableShortChunk(short[] data, int offset, int capacity) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(short value) final voidappendTypedChunk(ShortChunk<? extends ATTR> src, int srcOffset, int length) final short[]array()Get the data array backing this WritableShortChunk.final intGet this WritableShortChunk's offset into the backing data array.voidclose()final voidcopyFromArray(Object srcArray, int srcOffset, int destOffset, int length) final voidcopyFromBuffer(@NotNull Buffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this writable chunk with values from aBuffer.final voidcopyFromChunk(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length) final voidcopyFromTypedArray(short[] src, int srcOffset, int destOffset, int length) final voidcopyFromTypedBuffer(@NotNull ShortBuffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this WritableShortChunk with values from aShortBuffer.final voidcopyFromTypedChunk(ShortChunk<? extends ATTR> src, int srcOffset, int destOffset, int length) final voidfillWithBoxedValue(int offset, int size, Object value) Fill a sub-range of this writable chunk with the given value, unboxing it as appropriate.final voidfillWithNullValue(int offset, int length) Fill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.final voidfillWithValue(int offset, int length, short value) static <ATTR extends Any>
WritableShortChunk<ATTR>makeWritableChunk(int size) final voidset(int index, short value) 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 voidsort()Sort this chunk in-place using Java's primitive defined ordering.final voidsort(int start, int length) Sort this chunk in-place using Java's primitive defined ordering.static <ATTR extends Any,ATTR_DERIV extends ATTR>
WritableShortChunk<ATTR>upcast(WritableShortChunk<ATTR_DERIV> self) static <ATTR extends Any>
WritableShortChunk<ATTR>writableChunkWrap(short[] data) static <ATTR extends Any>
WritableShortChunk<ATTR>writableChunkWrap(short[] data, int offset, int size) Methods inherited from class io.deephaven.chunk.ShortChunk
binarySearch, binarySearch, chunkWrap, chunkWrap, copyToArray, copyToBuffer, copyToChunk, copyToTypedArray, copyToTypedBuffer, downcast, get, getChunkType, getEmptyChunk, isAlias, isAlias, isNull, makeArray, walkMethods inherited from class io.deephaven.chunk.ChunkBase
internalCapacity, internalSetSize, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.chunk.Chunk
asBooleanChunk, asByteChunk, asCharChunk, asDoubleChunk, asFloatChunk, asIntChunk, asLongChunk, asObjectChunk, asShortChunk, checkChunkType, copyToArray, copyToBuffer, copyToChunk, getChunkType, isAlias, isAlias, size, walkMethods inherited from interface io.deephaven.chunk.WritableChunk
asWritableBooleanChunk, asWritableByteChunk, asWritableCharChunk, asWritableDoubleChunk, asWritableFloatChunk, asWritableIntChunk, asWritableLongChunk, asWritableObjectChunk, asWritableShortChunk, capacity, internalCapacity, internalSetSize, setSize
-
Constructor Details
-
WritableShortChunk
protected WritableShortChunk(short[] data, int offset, int capacity)
-
-
Method Details
-
makeWritableChunk
- Parameters:
size- TheChunkBase.size()and minimum capacity of the returned chunk- Returns:
- The chunk
-
writableChunkWrap
-
writableChunkWrap
public static <ATTR extends Any> WritableShortChunk<ATTR> writableChunkWrap(short[] data, int offset, int size) -
set
public final void set(int index, short value) -
add
public final void add(short value) -
slice
Description copied from interface:ChunkMake 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).- Specified by:
slicein interfaceChunk<ATTR extends Any>- Specified by:
slicein interfaceWritableChunk<ATTR extends Any>- Overrides:
slicein classShortChunk<ATTR extends Any>- 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.
-
array
public final short[] array()Get the data array backing this WritableShortChunk. The first element of this chunk corresponds toarray()[arrayOffset()].This WritableShortChunk must never be
closedwhile the array may be in use externally, because it must not be returned to any pool for re-use until that re-use is guaranteed to be exclusive.- Returns:
- The backing data array
-
arrayOffset
public final int arrayOffset()Get this WritableShortChunk's offset into the backing data array. The first element of this chunk corresponds toarray()[arrayOffset()].- Returns:
- The offset into the backing data array
-
fillWithNullValue
public final void fillWithNullValue(int offset, int length) Description copied from interface:WritableChunkFill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.- Specified by:
fillWithNullValuein interfaceWritableChunk<ATTR extends Any>- Parameters:
offset- Starting offsetlength- Number of values to fill
-
fillWithBoxedValue
Description copied from interface:WritableChunkFill a sub-range of this writable chunk with the given value, unboxing it as appropriate.- Specified by:
fillWithBoxedValuein interfaceWritableChunk<ATTR extends Any>- Parameters:
offset- Starting offsetsize- Number of values to fill
-
fillWithValue
public final void fillWithValue(int offset, int length, short value) -
appendTypedChunk
-
copyFromChunk
public final void copyFromChunk(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length) - Specified by:
copyFromChunkin interfaceWritableChunk<ATTR extends Any>
-
copyFromTypedChunk
public final void copyFromTypedChunk(ShortChunk<? extends ATTR> src, int srcOffset, int destOffset, int length) -
copyFromArray
- Specified by:
copyFromArrayin interfaceWritableChunk<ATTR extends Any>
-
copyFromTypedArray
public final void copyFromTypedArray(short[] src, int srcOffset, int destOffset, int length) -
copyFromBuffer
public final void copyFromBuffer(@NotNull @NotNull Buffer srcBuffer, int srcOffset, int destOffset, int length) Description copied from interface:WritableChunkFill a sub-range of this writable chunk with values from 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,
srcOffsetis an absolute offset from position 0, rather than a relative offset fromsrcBuffer.position().It is required that
srcBuffer.limit()is at leastsrcOffset + length.srcBuffer's position may be modified, but will always be restored to its initial value upon successful return.- Specified by:
copyFromBufferin interfaceWritableChunk<ATTR extends Any>- Parameters:
srcBuffer- The source buffer, which will be cast to the appropriate type for this chunksrcOffset- The offset intosrcBuffer(from position 0, notsrcBuffer.position()) to start copying fromdestOffset- The offset into this chunk to start copying tolength- The number of elements to copy
-
copyFromTypedBuffer
public final void copyFromTypedBuffer(@NotNull @NotNull ShortBuffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this WritableShortChunk with values from a
ShortBuffer.See
copyFromBuffer(Buffer, int, int, int)for general documentation.- Parameters:
srcBuffer- The sourceShortBuffersrcOffset- The absolute offset intosrcBufferto start copying fromdestOffset- The offset into this chunk to start copying tolength- The number of elements to copy
-
sort
public final void sort()Description copied from interface:WritableChunkSort this chunk in-place using Java's primitive defined ordering.Of note is that nulls or NaNs are not sorted according to Deephaven ordering rules.
- Specified by:
sortin interfaceWritableChunk<ATTR extends Any>
-
sort
public final void sort(int start, int length) Description copied from interface:WritableChunkSort this chunk in-place using Java's primitive defined ordering.Of note is that nulls or NaNs are not sorted according to Deephaven ordering rules.
- Specified by:
sortin interfaceWritableChunk<ATTR extends Any>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-
upcast
public static <ATTR extends Any,ATTR_DERIV extends ATTR> WritableShortChunk<ATTR> upcast(WritableShortChunk<ATTR_DERIV> self)
-