Search in sources :

Example 6 with Chunk

use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.

the class SkipListUtils method helpSetNextValuePointer.

/**
 * Sets the next value pointer of the value.
 *
 * @param valuePointer the value pointer.
 * @param nextValuePointer the next value pointer to set.
 * @param spaceAllocator the space allocator.
 */
static void helpSetNextValuePointer(long valuePointer, long nextValuePointer, Allocator spaceAllocator) {
    Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(valuePointer));
    int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(valuePointer);
    MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
    int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
    putNextValuePointer(segment, offsetInByteBuffer, nextValuePointer);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 7 with Chunk

use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.

the class SkipListUtils method findPredecessor.

/**
 * Find the predecessor node for the given node at the given level.
 *
 * @param node the node.
 * @param level the level.
 * @param levelIndexHeader the head level index.
 * @param spaceAllocator the space allocator.
 * @return node id before the key at the given level.
 */
static long findPredecessor(long node, int level, LevelIndexHeader levelIndexHeader, @Nonnull Allocator spaceAllocator) {
    Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
    int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(node);
    MemorySegment keySegment = chunk.getMemorySegment(offsetInChunk);
    int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
    int keyLevel = getLevel(keySegment, offsetInByteBuffer);
    int keyOffset = offsetInByteBuffer + getKeyDataOffset(keyLevel);
    return findPredecessor(keySegment, keyOffset, level, levelIndexHeader, spaceAllocator);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 8 with Chunk

use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.

the class SkipListUtils method isNodeRemoved.

/**
 * Whether the node has been logically removed.
 *
 * @param node the node to check against
 * @param spaceAllocator the space allocator
 * @return true if the node has been logically removed.
 */
static boolean isNodeRemoved(long node, Allocator spaceAllocator) {
    if (node == NIL_NODE) {
        return false;
    }
    Chunk chunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
    int offsetInChunk = SpaceUtils.getChunkOffsetByAddress(node);
    MemorySegment segment = chunk.getMemorySegment(offsetInChunk);
    int offsetInByteBuffer = chunk.getOffsetInSegment(offsetInChunk);
    return getNodeStatus(segment, offsetInByteBuffer) == NodeStatus.REMOVE;
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 9 with Chunk

use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.

the class SkipListUtils method helpGetValueLen.

/**
 * Returns the length of the value.
 *
 * @param valuePointer the pointer to the value.
 * @param spaceAllocator the space allocator.
 */
static int helpGetValueLen(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 getValueLen(segment, offsetInByteBuffer);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 10 with Chunk

use of org.apache.flink.runtime.state.heap.space.Chunk in project flink by apache.

the class CopyOnWriteSkipListStateMap method getNodeSegmentAndOffset.

private Node getNodeSegmentAndOffset(long node) {
    Chunk nodeChunk = spaceAllocator.getChunkById(SpaceUtils.getChunkIdByAddress(node));
    int offsetInNodeChunk = SpaceUtils.getChunkOffsetByAddress(node);
    MemorySegment nodeSegment = nodeChunk.getMemorySegment(offsetInNodeChunk);
    int offsetInNodeSegment = nodeChunk.getOffsetInSegment(offsetInNodeChunk);
    return new Node(nodeSegment, offsetInNodeSegment);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Aggregations

MemorySegment (org.apache.flink.core.memory.MemorySegment)15 Chunk (org.apache.flink.runtime.state.heap.space.Chunk)15