io.deephaven.chunk.ResettableIntChunk Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-chunk Show documentation
Show all versions of deephaven-engine-chunk Show documentation
Engine Chunks: Array-like data structures for dense, efficient data movement
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit ResettableCharChunk and run "./gradlew replicateSourcesAndChunks" to regenerate
//
// @formatter:off
package io.deephaven.chunk;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.util.pools.MultiChunkPool;
import io.deephaven.util.type.ArrayTypeUtils;
import static io.deephaven.chunk.util.pools.ChunkPoolConstants.POOL_RESETTABLE_CHUNKS;
/**
* {@link ResettableReadOnlyChunk} implementation for int data.
*/
public class ResettableIntChunk
extends IntChunk
implements ResettableReadOnlyChunk {
public static ResettableIntChunk makeResettableChunk() {
if (POOL_RESETTABLE_CHUNKS) {
return MultiChunkPool.forThisThread().takeResettableIntChunk();
}
return new ResettableIntChunk<>();
}
public static ResettableIntChunk makeResettableChunkForPool() {
return new ResettableIntChunk<>() {
@Override
public void close() {
MultiChunkPool.forThisThread().giveResettableIntChunk(this);
}
};
}
private ResettableIntChunk(int[] data, int offset, int capacity) {
super(data, offset, capacity);
}
private ResettableIntChunk() {
this(ArrayTypeUtils.EMPTY_INT_ARRAY, 0, 0);
}
@Override
public ResettableIntChunk slice(int offset, int capacity) {
ChunkHelpers.checkSliceArgs(size, offset, capacity);
return new ResettableIntChunk<>(data, this.offset + offset, capacity);
}
@Override
public IntChunk resetFromChunk(Chunk extends ATTR> other, int offset,
int capacity) {
return resetFromTypedChunk(other.asIntChunk(), offset, capacity);
}
@Override
public IntChunk resetFromArray(Object array, int offset, int capacity) {
final int[] typedArray = (int[]) array;
return resetFromTypedArray(typedArray, offset, capacity);
}
@Override
public IntChunk resetFromArray(Object array) {
final int[] typedArray = (int[]) array;
return resetFromTypedArray(typedArray, 0, typedArray.length);
}
@Override
public IntChunk clear() {
return resetFromArray(ArrayTypeUtils.EMPTY_INT_ARRAY, 0, 0);
}
public IntChunk resetFromTypedChunk(IntChunk extends ATTR> other, int offset,
int capacity) {
ChunkHelpers.checkSliceArgs(other.size, offset, capacity);
return resetFromTypedArray(other.data, other.offset + offset, capacity);
}
public IntChunk resetFromTypedArray(int[] data, int offset, int capacity) {
ChunkHelpers.checkArrayArgs(data.length, offset, capacity);
this.data = data;
this.offset = offset;
this.capacity = capacity;
this.size = capacity;
return IntChunk.downcast(this);
}
@Override
public void close() {}
}