io.deephaven.engine.page.CharChunkPage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.page;
import io.deephaven.base.verify.Require;
import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.engine.rowset.RowSequence;
import org.jetbrains.annotations.NotNull;
public class CharChunkPage extends CharChunk implements ChunkPage {
private final long mask;
private final long firstRow;
public static CharChunkPage pageWrap(
final long firstRow,
@NotNull final char[] data,
final int offset,
final int capacity,
final long mask) {
return new CharChunkPage<>(firstRow, data, offset, capacity, mask);
}
public static CharChunkPage pageWrap(
final long firstRow,
@NotNull final char[] data,
final long mask) {
return new CharChunkPage<>(firstRow, data, 0, data.length, mask);
}
private CharChunkPage(
final long firstRow,
@NotNull final char[] data,
final int offset,
final int capacity,
final long mask) {
super(data, offset, capacity);
this.mask = mask;
this.firstRow = Require.inRange(firstRow, "firstRow", mask, "mask");
}
@Override
public final void fillChunkAppend(
@NotNull final FillContext context,
@NotNull final WritableChunk super ATTR> destination,
@NotNull final RowSequence rowSequence) {
WritableCharChunk super ATTR> to = destination.asWritableCharChunk();
if (rowSequence.getAverageRunLengthEstimate() >= Chunk.SYSTEM_ARRAYCOPY_THRESHOLD) {
rowSequence.forAllRowKeyRanges((final long rangeStartKey, final long rangeEndKey) -> to.appendTypedChunk(
this, getChunkOffset(rangeStartKey), (int) (rangeEndKey - rangeStartKey + 1)));
} else {
rowSequence.forAllRowKeys((final long key) -> to.add(get(getChunkOffset(key))));
}
}
@Override
public final long firstRowOffset() {
return firstRow;
}
@Override
public final long mask() {
return mask;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy