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