Class WritableIntChunk<ATTR extends Attributes.Any>
- All Implemented Interfaces:
Chunk<ATTR>
,PoolableChunk
,WritableChunk<ATTR>
,SafeCloseable
,AutoCloseable
- Direct Known Subclasses:
ResettableWritableIntChunk
WritableChunk
implementation for int data.-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.sources.chunk.Chunk
MAXIMUM_SIZE, SYSTEM_ARRAYCOPY_THRESHOLD, SYSTEM_ARRAYFILL_THRESHOLD
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(int value) Add the specified value to the chunk.final void
appendTypedChunk
(IntChunk<? extends ATTR> src, int srcOffset, int length) void
close()
final void
copyFromArray
(Object srcArray, int srcOffset, int destOffset, int length) final void
copyFromBuffer
(Buffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this writable chunk with values from aBuffer
.final void
copyFromChunk
(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length) final void
copyFromTypedArray
(int[] src, int srcOffset, int destOffset, int length) final void
copyFromTypedBuffer
(IntBuffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this WritableIntChunk with values from aIntBuffer
.final void
copyFromTypedChunk
(IntChunk<? extends ATTR> src, int srcOffset, int destOffset, int length) static <ATTR extends Attributes.Any,
ATTR_DERIV extends ATTR>
WritableIntChunk<ATTR_DERIV>downcast
(WritableIntChunk<ATTR> self) final void
fillWithBoxedValue
(int offset, int size, Object value) Fill a sub-range of this writable chunk with the given value, unboxing it as appropriate.final void
fillWithNullValue
(int offset, int length) Fill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.final void
fillWithValue
(int offset, int length, int value) final ChunkFiller
Our ChunkFiller "plugin".static <ATTR extends Attributes.Any>
WritableIntChunk<ATTR>makeWritableChunk
(int size) Retrieve aWritableIntChunk
of the specified size.static <ATTR extends Attributes.Any>
WritableIntChunk<ATTR>makeWritableChunkForPool
(int size) Create aWritableIntChunk
of the specified size.final void
set
(int index, int 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 void
sort()
Sort this chunk in-place using Java's primitive defined ordering.final void
sort
(int start, int length) Sort this chunk in-place using Java's primitive defined ordering.static <ATTR extends Attributes.Any,
ATTR_DERIV extends ATTR>
WritableIntChunk<ATTR>upcast
(WritableIntChunk<ATTR_DERIV> self) static <ATTR extends Attributes.Any>
WritableIntChunk<ATTR>writableChunkWrap
(int[] data) Wrap the specified array in aWritableIntChunk
.static <ATTR extends Attributes.Any>
WritableIntChunk<ATTR>writableChunkWrap
(int[] data, int offset, int size) Wrap the specified array in aWritableIntChunk
.Methods inherited from class com.illumon.iris.db.v2.sources.chunk.IntChunk
chunkWrap, chunkWrap, copyToArray, copyToBuffer, copyToChunk, copyToTypedArray, copyToTypedBuffer, get, getChunkType, getEmptyChunk, isAlias, isAlias, makeArray
Methods inherited from class com.illumon.iris.db.v2.sources.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 com.illumon.iris.db.v2.sources.chunk.Chunk
asBooleanChunk, asByteChunk, asCharChunk, asDoubleChunk, asFloatChunk, asIntChunk, asLongChunk, asObjectChunk, asShortChunk, copyToArray, copyToBuffer, copyToChunk, getChunkType, isAlias, isAlias, size
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.WritableChunk
asWritableBooleanChunk, asWritableByteChunk, asWritableCharChunk, asWritableDoubleChunk, asWritableFloatChunk, asWritableIntChunk, asWritableLongChunk, asWritableObjectChunk, asWritableShortChunk, capacity, internalCapacity, internalSetSize, setSize
-
Method Details
-
makeWritableChunk
Retrieve aWritableIntChunk
of the specified size.Note that the returned chunk may have a larger capacity than requested, and its size will be set to
size
.Users must take care to
close()
the chunk when finished.- Parameters:
size
- the desired size of the chunk.- Returns:
- A
WritableIntChunk
of the requested size.
-
makeWritableChunkForPool
public static <ATTR extends Attributes.Any> WritableIntChunk<ATTR> makeWritableChunkForPool(int size) Create aWritableIntChunk
of the specified size. The returned chunk will have exactly the requested capacity, and its size will be set tosize
.- Parameters:
size
- the desired size of the chunk.- Returns:
- A
WritableIntChunk
of the requested size.
-
writableChunkWrap
public static <ATTR extends Attributes.Any> WritableIntChunk<ATTR> writableChunkWrap(@NotNull int[] data) Wrap the specified array in aWritableIntChunk
. TheChunkBase.size()
will be initialized to thedata
length.- Parameters:
data
- the array to wrap- Returns:
- A new
WritableIntChunk
backed by the specified array.
-
writableChunkWrap
public static <ATTR extends Attributes.Any> WritableIntChunk<ATTR> writableChunkWrap(@NotNull int[] data, int offset, int size) Wrap the specified array in aWritableIntChunk
.- Parameters:
data
- the array to wrap- Returns:
- A new
WritableIntChunk
backed by the specified array.
-
set
public final void set(int index, int value) -
add
public final void add(int value) Add the specified value to the chunk. The value will be added at the positionChunkBase.size()
, and theChunkBase.size()
will be incremented.- Parameters:
value
- the value to add
-
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).- Specified by:
slice
in interfaceChunk<ATTR extends Attributes.Any>
- Specified by:
slice
in interfaceWritableChunk<ATTR extends Attributes.Any>
- Overrides:
slice
in classIntChunk<ATTR extends Attributes.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.
-
fillWithNullValue
public final void fillWithNullValue(int offset, int length) Description copied from interface:WritableChunk
Fill a sub-range of this writable chunk with the appropriate Deephaven null value for the type.- Specified by:
fillWithNullValue
in interfaceWritableChunk<ATTR extends Attributes.Any>
- Parameters:
offset
- Starting offsetlength
- Number of values to fill
-
fillWithBoxedValue
Description copied from interface:WritableChunk
Fill a sub-range of this writable chunk with the given value, unboxing it as appropriate.- Specified by:
fillWithBoxedValue
in interfaceWritableChunk<ATTR extends Attributes.Any>
- Parameters:
offset
- Starting offsetsize
- Number of values to fill
-
fillWithValue
public final void fillWithValue(int offset, int length, int value) -
appendTypedChunk
-
copyFromChunk
public final void copyFromChunk(Chunk<? extends ATTR> src, int srcOffset, int destOffset, int length) - Specified by:
copyFromChunk
in interfaceWritableChunk<ATTR extends Attributes.Any>
-
copyFromTypedChunk
-
copyFromArray
- Specified by:
copyFromArray
in interfaceWritableChunk<ATTR extends Attributes.Any>
-
copyFromTypedArray
public final void copyFromTypedArray(int[] src, int srcOffset, int destOffset, int length) -
copyFromBuffer
public final void copyFromBuffer(@NotNull Buffer srcBuffer, int srcOffset, int destOffset, int length) Description copied from interface:WritableChunk
Fill 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,
srcOffset
is 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:
copyFromBuffer
in interfaceWritableChunk<ATTR extends Attributes.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 IntBuffer srcBuffer, int srcOffset, int destOffset, int length) Fill a sub-range of this WritableIntChunk with values from a
IntBuffer
.See
copyFromBuffer(Buffer, int, int, int)
for general documentation.- Parameters:
srcBuffer
- The sourceIntBuffer
srcOffset
- The absolute offset intosrcBuffer
to start copying fromdestOffset
- The offset into this chunk to start copying tolength
- The number of elements to copy
-
getChunkFiller
Description copied from interface:WritableChunk
Our ChunkFiller "plugin".- Specified by:
getChunkFiller
in interfaceWritableChunk<ATTR extends Attributes.Any>
-
sort
public final void sort()Description copied from interface:WritableChunk
Sort 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:
sort
in interfaceWritableChunk<ATTR extends Attributes.Any>
-
sort
public final void sort(int start, int length) Description copied from interface:WritableChunk
Sort 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:
sort
in interfaceWritableChunk<ATTR extends Attributes.Any>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSafeCloseable
-
upcast
public static <ATTR extends Attributes.Any,ATTR_DERIV extends ATTR> WritableIntChunk<ATTR> upcast(WritableIntChunk<ATTR_DERIV> self) -
downcast
public static <ATTR extends Attributes.Any,ATTR_DERIV extends ATTR> WritableIntChunk<ATTR_DERIV> downcast(WritableIntChunk<ATTR> self)
-