Search in sources :

Example 1 with ListStateInputFormat

use of org.apache.flink.state.api.input.ListStateInputFormat in project flink by apache.

the class ExistingSavepoint method readListState.

/**
 * Read operator {@code ListState} from a {@code Savepoint}.
 *
 * @param uid The uid of the operator.
 * @param name The (unique) name for the state.
 * @param typeInfo The type of the elements in the state.
 * @param <T> The type of the values that are in the list state.
 * @return A {@code DataSet} representing the elements in state.
 * @throws IOException If the savepoint path is invalid or the uid does not exist.
 */
public <T> DataSource<T> readListState(String uid, String name, TypeInformation<T> typeInfo) throws IOException {
    OperatorState operatorState = metadata.getOperatorState(uid);
    ListStateDescriptor<T> descriptor = new ListStateDescriptor<>(name, typeInfo);
    ListStateInputFormat<T> inputFormat = new ListStateInputFormat<>(operatorState, env.getConfiguration(), stateBackend, descriptor);
    return env.createInput(inputFormat, typeInfo);
}
Also used : ListStateInputFormat(org.apache.flink.state.api.input.ListStateInputFormat) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState)

Example 2 with ListStateInputFormat

use of org.apache.flink.state.api.input.ListStateInputFormat in project flink by apache.

the class ExistingSavepoint method readListState.

/**
 * Read operator {@code ListState} from a {@code Savepoint} when a custom serializer was used;
 * e.g., a different serializer than the one returned by {@code
 * TypeInformation#createSerializer}.
 *
 * @param uid The uid of the operator.
 * @param name The (unique) name for the state.
 * @param typeInfo The type of the elements in the state.
 * @param serializer The serializer used to write the elements into state.
 * @param <T> The type of the values that are in the list state.
 * @return A {@code DataSet} representing the elements in state.
 * @throws IOException If the savepoint path is invalid or the uid does not exist.
 */
public <T> DataSource<T> readListState(String uid, String name, TypeInformation<T> typeInfo, TypeSerializer<T> serializer) throws IOException {
    OperatorState operatorState = metadata.getOperatorState(uid);
    ListStateDescriptor<T> descriptor = new ListStateDescriptor<>(name, serializer);
    ListStateInputFormat<T> inputFormat = new ListStateInputFormat<>(operatorState, env.getConfiguration(), stateBackend, descriptor);
    return env.createInput(inputFormat, typeInfo);
}
Also used : ListStateInputFormat(org.apache.flink.state.api.input.ListStateInputFormat) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState)

Example 3 with ListStateInputFormat

use of org.apache.flink.state.api.input.ListStateInputFormat in project flink by apache.

the class SavepointReader method readListState.

/**
 * Read operator {@code ListState} from a {@code Savepoint} when a custom serializer was used;
 * e.g., a different serializer than the one returned by {@code
 * TypeInformation#createSerializer}.
 *
 * @param uid The uid of the operator.
 * @param name The (unique) name for the state.
 * @param typeInfo The type of the elements in the state.
 * @param serializer The serializer used to write the elements into state.
 * @param <T> The type of the values that are in the list state.
 * @return A {@code DataStream} representing the elements in state.
 * @throws IOException If the savepoint path is invalid or the uid does not exist.
 */
public <T> DataStream<T> readListState(String uid, String name, TypeInformation<T> typeInfo, TypeSerializer<T> serializer) throws IOException {
    OperatorState operatorState = metadata.getOperatorState(uid);
    ListStateDescriptor<T> descriptor = new ListStateDescriptor<>(name, serializer);
    ListStateInputFormat<T> inputFormat = new ListStateInputFormat<>(operatorState, MutableConfig.of(env.getConfiguration()), stateBackend, descriptor);
    return SourceBuilder.fromFormat(env, inputFormat, typeInfo);
}
Also used : ListStateInputFormat(org.apache.flink.state.api.input.ListStateInputFormat) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState)

Example 4 with ListStateInputFormat

use of org.apache.flink.state.api.input.ListStateInputFormat in project flink by apache.

the class SavepointReader method readListState.

/**
 * Read operator {@code ListState} from a {@code Savepoint}.
 *
 * @param uid The uid of the operator.
 * @param name The (unique) name for the state.
 * @param typeInfo The type of the elements in the state.
 * @param <T> The type of the values that are in the list state.
 * @return A {@code DataStream} representing the elements in state.
 * @throws IOException If the savepoint path is invalid or the uid does not exist.
 */
public <T> DataStream<T> readListState(String uid, String name, TypeInformation<T> typeInfo) throws IOException {
    OperatorState operatorState = metadata.getOperatorState(uid);
    ListStateDescriptor<T> descriptor = new ListStateDescriptor<>(name, typeInfo);
    ListStateInputFormat<T> inputFormat = new ListStateInputFormat<>(operatorState, MutableConfig.of(env.getConfiguration()), stateBackend, descriptor);
    return SourceBuilder.fromFormat(env, inputFormat, typeInfo);
}
Also used : ListStateInputFormat(org.apache.flink.state.api.input.ListStateInputFormat) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState)

Aggregations

ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)4 OperatorState (org.apache.flink.runtime.checkpoint.OperatorState)4 ListStateInputFormat (org.apache.flink.state.api.input.ListStateInputFormat)4