io.deephaven.engine.page.ChunkPage 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.chunk.Chunk;
import io.deephaven.chunk.ChunkType;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.engine.table.impl.DefaultChunkSource;
import io.deephaven.util.annotations.FinalDefault;
import org.jetbrains.annotations.NotNull;
public interface ChunkPage extends Page.WithDefaults, Chunk,
DefaultChunkSource.SupportsContiguousGet {
@Override
ChunkType getChunkType();
/**
* @param row Any row contained on this page.
* @return the last row of this page, located in the same way as row.
*/
default long lastRow(final long row) {
return (row & ~mask()) | (firstRowOffset() + size() - 1);
}
@Override
@FinalDefault
default long maxRow(final long rowKey) {
return lastRow(rowKey);
}
/**
* @return The offset into the chunk for this row.
* @apiNote This function is for convenience over {@link #getRowOffset(long)}, so the caller doesn't have to cast to
* an int.
* @implNote This page is known to be a chunk, so {@link #size()} is an int, and so is the offset.
*/
@FinalDefault
default int getChunkOffset(final long row) {
return (int) getRowOffset(row);
}
@FinalDefault
@Override
default Chunk extends ATTR> getChunk(@NotNull final GetContext context, final long firstKey, final long lastKey) {
return slice(getChunkOffset(firstKey), Math.toIntExact(lastKey - firstKey + 1));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy