use of org.apache.flink.state.api.input.operator.KeyedStateReaderOperator in project flink by apache.
the class KeyedStateInputFormatTest method readInputSplit.
@Nonnull
private List<Integer> readInputSplit(KeyGroupRangeInputSplit split, KeyedStateReaderFunction<Integer, Integer> userFunction) throws IOException {
KeyedStateInputFormat<Integer, VoidNamespace, Integer> format = new KeyedStateInputFormat<>(new OperatorState(OperatorIDGenerator.fromUid("uid"), 1, 4), new MemoryStateBackend(), new Configuration(), new KeyedStateReaderOperator<>(userFunction, Types.INT));
List<Integer> data = new ArrayList<>();
format.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
format.openInputFormat();
format.open(split);
while (!format.reachedEnd()) {
data.add(format.nextRecord(0));
}
format.close();
format.closeInputFormat();
data.sort(Comparator.comparingInt(id -> id));
return data;
}
Aggregations