use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.
the class SkipListUtils method helpSetPrevNode.
/**
* Set the previous node of the given node at the given level. The level must be positive.
*
* @param node the node.
* @param prevNode the previous node to set.
* @param level the level to find the next node.
* @param spaceAllocator the space allocator.
*/
static void helpSetPrevNode(long node, long prevNode, int level, Allocator spaceAllocator) {
Preconditions.checkArgument(level > 0, "only index level have previous node");
if (node == HEAD_NODE || node == NIL_NODE) {
return;
}
Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(node);
MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
int topLevel = getLevel(segment, offsetInByteBuffer);
putPrevIndexNode(segment, offsetInByteBuffer, topLevel, level, prevNode);
}
use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.
the class SkipListUtils method helpGetValuePointer.
/**
* Returns the value pointer of the node.
*
* @param node the node.
* @param spaceAllocator the space allocator.
*/
static long helpGetValuePointer(long node, Allocator spaceAllocator) {
Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(node);
MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
return getValuePointer(segment, offsetInByteBuffer);
}
use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.
the class SkipListUtils method helpSetNextNode.
/**
* Set the next node of the given node at the given level.
*
* @param node the node.
* @param nextNode the next node to set.
* @param level the level to find the next node.
* @param levelIndexHeader the header of the level index.
* @param spaceAllocator the space allocator.
*/
static void helpSetNextNode(long node, long nextNode, int level, LevelIndexHeader levelIndexHeader, Allocator spaceAllocator) {
if (node == HEAD_NODE) {
levelIndexHeader.updateNextNode(level, nextNode);
return;
}
Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(node);
MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
if (level == 0) {
putNextKeyPointer(segment, offsetInByteBuffer, nextNode);
} else {
putNextIndexNode(segment, offsetInByteBuffer, level, nextNode);
}
}
use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.
the class SkipListUtils method helpGetNextValuePointer.
/**
* Returns the next value pointer of the value.
*
* @param valuePointer the value pointer of current value.
* @param spaceAllocator the space allocator.
*/
static long helpGetNextValuePointer(long valuePointer, Allocator spaceAllocator) {
Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(valuePointer));
int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(valuePointer);
MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
return getNextValuePointer(segment, offsetInByteBuffer);
}
use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.
the class SkipListUtils method helpGetValueVersion.
/**
* Returns the version of the value.
*
* @param valuePointer the pointer to the value.
* @param spaceAllocator the space allocator.
*/
static int helpGetValueVersion(long valuePointer, Allocator spaceAllocator) {
Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(valuePointer));
int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(valuePointer);
MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
return getValueVersion(segment, offsetInByteBuffer);
}
Aggregations