io.deephaven.chunk.LongChunkChunk 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 CharChunkChunk and run "./gradlew replicateSourcesAndChunks" to regenerate
//
// @formatter:off
package io.deephaven.chunk;
import io.deephaven.chunk.attributes.Any;
public class LongChunkChunk extends ChunkChunkBase implements ChunkChunk {
@SuppressWarnings({"unchecked", "rawtypes"})
private static final LongChunkChunk EMPTY = new LongChunkChunk<>(new LongChunk[0], 0, 0);
public static LongChunkChunk getEmptyChunk() {
// noinspection unchecked
return EMPTY;
}
public static LongChunk[] makeArray(int capacity) {
// noinspection unchecked
return new LongChunk[capacity];
}
public static LongChunkChunk chunkWrap(LongChunk[] data) {
return new LongChunkChunk<>(data, 0, data.length);
}
public static LongChunkChunk chunkWrap(LongChunk[] data, int offset, int capacity) {
return new LongChunkChunk<>(data, offset, capacity);
}
LongChunk[] data;
/**
* innerData[i] is a cached copy of data[i].data used for faster two-dimensional access.
*/
long[][] innerData;
/**
* innerOffsets[i] is a cached copy of data[i].offset used for faster two-dimensional access.
*/
int[] innerOffsets;
LongChunkChunk(LongChunk[] data, int offset, int capacity) {
super(data.length, offset, capacity);
this.data = data;
resetInnerCache(data, offset, 0, capacity);
}
/**
* Update cached "inner" data structures.
*/
final void resetInnerCache(LongChunk[] data, int offset, int oldCapacity, int newCapacity) {
if (innerData == null || innerData.length < newCapacity) {
innerData = new long[newCapacity][];
innerOffsets = new int[newCapacity];
}
for (int ii = 0; ii < newCapacity; ++ii) {
resetInnerCacheItem(ii, data[ii + offset]);
}
for (int ii = newCapacity; ii < oldCapacity; ++ii) {
// Be friendly to the garbage collector
innerData[ii] = null;
innerOffsets[ii] = 0; // to be nice
}
}
/**
* Update a specific cached "inner" data structures.
*/
final void resetInnerCacheItem(int index, LongChunk chunk) {
if (chunk == null) {
innerData[index] = null;
innerOffsets[index] = 0;
} else {
innerData[index] = chunk.data;
innerOffsets[index] = chunk.offset;
}
}
public final LongChunk get(int index) {
return data[offset + index];
}
public final LongChunk getChunk(int index) {
return get(index);
}
public final long get(int j, int i) {
return innerData[j][innerOffsets[j] + i];
}
@Override
public LongChunkChunk slice(int offset, int capacity) {
ChunkHelpers.checkSliceArgs(size, offset, capacity);
return new LongChunkChunk<>(data, this.offset + offset, capacity);
}
// region AsType
// endregion AsType
}