Search in sources :

Example 11 with Chunk

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);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 12 with Chunk

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);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 13 with Chunk

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);
    }
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 14 with Chunk

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);
}
Also used : Chunk(org.apache.flink.runtime.state.heap.space.Chunk) MemorySegment(org.apache.flink.core.memory.MemorySegment)

Example 15 with Chunk

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);
}
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