Search in sources :

Example 1 with SingleStateIterator

use of org.apache.flink.contrib.streaming.state.iterator.SingleStateIterator in project flink by apache.

the class RocksDBFullSnapshotResources method createKVStateIterator.

@Override
public KeyValueStateIterator createKVStateIterator() throws IOException {
    CloseableRegistry closeableRegistry = new CloseableRegistry();
    try {
        ReadOptions readOptions = new ReadOptions();
        closeableRegistry.registerCloseable(readOptions::close);
        readOptions.setSnapshot(snapshot);
        List<Tuple2<RocksIteratorWrapper, Integer>> kvStateIterators = createKVStateIterators(closeableRegistry, readOptions);
        List<SingleStateIterator> heapPriorityQueueIterators = createHeapPriorityQueueIterators();
        // RocksStatesPerKeyGroupMergeIterator
        return new RocksStatesPerKeyGroupMergeIterator(closeableRegistry, kvStateIterators, heapPriorityQueueIterators, keyGroupPrefixBytes);
    } catch (Throwable t) {
        // If anything goes wrong, clean up our stuff. If things went smoothly the
        // merging iterator is now responsible for closing the resources
        IOUtils.closeQuietly(closeableRegistry);
        throw new IOException("Error creating merge iterator", t);
    }
}
Also used : ReadOptions(org.rocksdb.ReadOptions) RocksStatesPerKeyGroupMergeIterator(org.apache.flink.contrib.streaming.state.iterator.RocksStatesPerKeyGroupMergeIterator) Tuple2(org.apache.flink.api.java.tuple.Tuple2) SingleStateIterator(org.apache.flink.contrib.streaming.state.iterator.SingleStateIterator) IOException(java.io.IOException) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry)

Example 2 with SingleStateIterator

use of org.apache.flink.contrib.streaming.state.iterator.SingleStateIterator in project flink by apache.

the class RocksDBFullSnapshotResources method createHeapPriorityQueueIterators.

private List<SingleStateIterator> createHeapPriorityQueueIterators() {
    int kvStateId = metaData.size();
    List<SingleStateIterator> queuesIterators = new ArrayList<>(heapPriorityQueuesSnapshots.size());
    for (HeapPriorityQueueStateSnapshot<?> queuesSnapshot : heapPriorityQueuesSnapshots) {
        queuesIterators.add(new RocksQueueIterator(queuesSnapshot, keyGroupRange, keyGroupPrefixBytes, kvStateId++));
    }
    return queuesIterators;
}
Also used : SingleStateIterator(org.apache.flink.contrib.streaming.state.iterator.SingleStateIterator) ArrayList(java.util.ArrayList) RocksQueueIterator(org.apache.flink.contrib.streaming.state.iterator.RocksQueueIterator)

Aggregations

SingleStateIterator (org.apache.flink.contrib.streaming.state.iterator.SingleStateIterator)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 RocksQueueIterator (org.apache.flink.contrib.streaming.state.iterator.RocksQueueIterator)1 RocksStatesPerKeyGroupMergeIterator (org.apache.flink.contrib.streaming.state.iterator.RocksStatesPerKeyGroupMergeIterator)1 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)1 ReadOptions (org.rocksdb.ReadOptions)1