Java Code Examples for org.apache.flink.api.common.state.FoldingStateDescriptor#getFoldFunction()

The following examples show how to use org.apache.flink.api.common.state.FoldingStateDescriptor#getFoldFunction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TtlStateFactory.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"deprecation", "unchecked"})
private <T> IS createFoldingState() throws Exception {
	FoldingStateDescriptor<T, SV> foldingStateDescriptor = (FoldingStateDescriptor<T, SV>) stateDesc;
	SV initAcc = stateDesc.getDefaultValue();
	TtlValue<SV> ttlInitAcc = initAcc == null ? null : new TtlValue<>(initAcc, Long.MAX_VALUE);
	FoldingStateDescriptor<T, TtlValue<SV>> ttlDescriptor = new FoldingStateDescriptor<>(
		stateDesc.getName(),
		ttlInitAcc,
		new TtlFoldFunction<>(foldingStateDescriptor.getFoldFunction(), ttlConfig, timeProvider, initAcc),
		new TtlSerializer<>(LongSerializer.INSTANCE, stateDesc.getSerializer()));
	return (IS) new TtlFoldingState<>(createTtlStateContext(ttlDescriptor));
}
 
Example 2
Source File: MockInternalFoldingState.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "unused"})
static <T, N, ACC, S extends State, IS extends S> IS createState(
	TypeSerializer<N> namespaceSerializer,
	StateDescriptor<S, ACC> stateDesc) {
	FoldingStateDescriptor<T, ACC> foldingStateDesc = (FoldingStateDescriptor<T, ACC>) stateDesc;
	return (IS) new MockInternalFoldingState<>(foldingStateDesc.getFoldFunction());
}
 
Example 3
Source File: TtlStateFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"deprecation", "unchecked"})
private <T> IS createFoldingState() throws Exception {
	FoldingStateDescriptor<T, SV> foldingStateDescriptor = (FoldingStateDescriptor<T, SV>) stateDesc;
	SV initAcc = stateDesc.getDefaultValue();
	TtlValue<SV> ttlInitAcc = initAcc == null ? null : new TtlValue<>(initAcc, Long.MAX_VALUE);
	FoldingStateDescriptor<T, TtlValue<SV>> ttlDescriptor = new FoldingStateDescriptor<>(
		stateDesc.getName(),
		ttlInitAcc,
		new TtlFoldFunction<>(foldingStateDescriptor.getFoldFunction(), ttlConfig, timeProvider, initAcc),
		new TtlSerializer<>(LongSerializer.INSTANCE, stateDesc.getSerializer()));
	return (IS) new TtlFoldingState<>(createTtlStateContext(ttlDescriptor));
}
 
Example 4
Source File: MockInternalFoldingState.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "unused"})
static <T, N, ACC, S extends State, IS extends S> IS createState(
	TypeSerializer<N> namespaceSerializer,
	StateDescriptor<S, ACC> stateDesc) {
	FoldingStateDescriptor<T, ACC> foldingStateDesc = (FoldingStateDescriptor<T, ACC>) stateDesc;
	return (IS) new MockInternalFoldingState<>(foldingStateDesc.getFoldFunction());
}
 
Example 5
Source File: TtlStateFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"deprecation", "unchecked"})
private <T> IS createFoldingState() throws Exception {
	FoldingStateDescriptor<T, SV> foldingStateDescriptor = (FoldingStateDescriptor<T, SV>) stateDesc;
	SV initAcc = stateDesc.getDefaultValue();
	TtlValue<SV> ttlInitAcc = initAcc == null ? null : new TtlValue<>(initAcc, Long.MAX_VALUE);
	FoldingStateDescriptor<T, TtlValue<SV>> ttlDescriptor = new FoldingStateDescriptor<>(
		stateDesc.getName(),
		ttlInitAcc,
		new TtlFoldFunction<>(foldingStateDescriptor.getFoldFunction(), ttlConfig, timeProvider, initAcc),
		new TtlSerializer<>(LongSerializer.INSTANCE, stateDesc.getSerializer()));
	return (IS) new TtlFoldingState<>(createTtlStateContext(ttlDescriptor));
}
 
Example 6
Source File: MockInternalFoldingState.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "unused"})
static <T, N, ACC, S extends State, IS extends S> IS createState(
	TypeSerializer<N> namespaceSerializer,
	StateDescriptor<S, ACC> stateDesc) {
	FoldingStateDescriptor<T, ACC> foldingStateDesc = (FoldingStateDescriptor<T, ACC>) stateDesc;
	return (IS) new MockInternalFoldingState<>(foldingStateDesc.getFoldFunction());
}