Java Code Examples for org.apache.flink.api.common.state.MapStateDescriptor#enableTimeToLive()

The following examples show how to use org.apache.flink.api.common.state.MapStateDescriptor#enableTimeToLive() . 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: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 6 votes vote down vote up
private InputSideHasUniqueKey(
		RuntimeContext ctx,
		String stateName,
		BaseRowTypeInfo recordType,
		BaseRowTypeInfo uniqueKeyType,
		KeySelector<BaseRow, BaseRow> uniqueKeySelector,
		StateTtlConfig ttlConfig) {
	checkNotNull(uniqueKeyType);
	checkNotNull(uniqueKeySelector);
	TupleTypeInfo<Tuple2<BaseRow, Integer>> valueTypeInfo = new TupleTypeInfo<>(recordType, Types.INT);
	MapStateDescriptor<BaseRow, Tuple2<BaseRow, Integer>> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		uniqueKeyType,
		valueTypeInfo);
	if (!ttlConfig.equals(StateTtlConfig.DISABLED)) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
	this.uniqueKeySelector = uniqueKeySelector;
}
 
Example 2
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 6 votes vote down vote up
private InputSideHasUniqueKey(
		RuntimeContext ctx,
		String stateName,
		BaseRowTypeInfo recordType,
		BaseRowTypeInfo uniqueKeyType,
		KeySelector<BaseRow, BaseRow> uniqueKeySelector,
		StateTtlConfig ttlConfig) {
	checkNotNull(uniqueKeyType);
	checkNotNull(uniqueKeySelector);
	MapStateDescriptor<BaseRow, BaseRow> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		uniqueKeyType,
		recordType);
	if (!ttlConfig.equals(StateTtlConfig.DISABLED)) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
	this.uniqueKeySelector = uniqueKeySelector;
}
 
Example 3
Source File: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 6 votes vote down vote up
private InputSideHasUniqueKey(
		RuntimeContext ctx,
		String stateName,
		RowDataTypeInfo recordType,
		RowDataTypeInfo uniqueKeyType,
		KeySelector<RowData, RowData> uniqueKeySelector,
		StateTtlConfig ttlConfig) {
	checkNotNull(uniqueKeyType);
	checkNotNull(uniqueKeySelector);
	TupleTypeInfo<Tuple2<RowData, Integer>> valueTypeInfo = new TupleTypeInfo<>(recordType, Types.INT);
	MapStateDescriptor<RowData, Tuple2<RowData, Integer>> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		uniqueKeyType,
		valueTypeInfo);
	if (ttlConfig.isEnabled()) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
	this.uniqueKeySelector = uniqueKeySelector;
}
 
Example 4
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 6 votes vote down vote up
private InputSideHasUniqueKey(
		RuntimeContext ctx,
		String stateName,
		RowDataTypeInfo recordType,
		RowDataTypeInfo uniqueKeyType,
		KeySelector<RowData, RowData> uniqueKeySelector,
		StateTtlConfig ttlConfig) {
	checkNotNull(uniqueKeyType);
	checkNotNull(uniqueKeySelector);
	MapStateDescriptor<RowData, RowData> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		uniqueKeyType,
		recordType);
	if (ttlConfig.isEnabled()) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
	this.uniqueKeySelector = uniqueKeySelector;
}
 
Example 5
Source File: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
private InputSideHasNoUniqueKey(
		RuntimeContext ctx,
		String stateName,
		BaseRowTypeInfo recordType,
		StateTtlConfig ttlConfig) {
	TupleTypeInfo<Tuple2<Integer, Integer>> tupleTypeInfo = new TupleTypeInfo<>(Types.INT, Types.INT);
	MapStateDescriptor<BaseRow, Tuple2<Integer, Integer>> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		recordType,
		tupleTypeInfo);
	if (!ttlConfig.equals(StateTtlConfig.DISABLED)) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
}
 
Example 6
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
private InputSideHasNoUniqueKey(
		RuntimeContext ctx,
		String stateName,
		BaseRowTypeInfo recordType,
		StateTtlConfig ttlConfig) {
	MapStateDescriptor<BaseRow, Integer> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		recordType,
		Types.INT);
	if (!ttlConfig.equals(StateTtlConfig.DISABLED)) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
}
 
Example 7
Source File: TtlStateTest.java    From bravo with Apache License 2.0 5 votes vote down vote up
@Override
public void open(Configuration parameters) throws Exception {
	MapStateDescriptor<String, Integer> mapDesc = new MapStateDescriptor<>("Map", String.class,
			Integer.class);
	mapDesc.enableTimeToLive(StateTtlConfig.newBuilder(Time.minutes(100)).build());
	mapState = getRuntimeContext().getMapState(mapDesc);

	ListStateDescriptor<Integer> listDesc = new ListStateDescriptor<>("List", Integer.class);
	listDesc.enableTimeToLive(StateTtlConfig.newBuilder(Time.minutes(100)).build());
	listState = getRuntimeContext().getListState(listDesc);

	ValueStateDescriptor<Integer> valueStateDesc = new ValueStateDescriptor<Integer>("Val", Integer.class);
	valueStateDesc.enableTimeToLive(StateTtlConfig.newBuilder(Time.minutes(100)).build());
	valueState = getRuntimeContext().getState(valueStateDesc);
}
 
Example 8
Source File: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
private InputSideHasNoUniqueKey(
		RuntimeContext ctx,
		String stateName,
		RowDataTypeInfo recordType,
		StateTtlConfig ttlConfig) {
	TupleTypeInfo<Tuple2<Integer, Integer>> tupleTypeInfo = new TupleTypeInfo<>(Types.INT, Types.INT);
	MapStateDescriptor<RowData, Tuple2<Integer, Integer>> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		recordType,
		tupleTypeInfo);
	if (ttlConfig.isEnabled()) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
}
 
Example 9
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
private InputSideHasNoUniqueKey(
		RuntimeContext ctx,
		String stateName,
		RowDataTypeInfo recordType,
		StateTtlConfig ttlConfig) {
	MapStateDescriptor<RowData, Integer> recordStateDesc = new MapStateDescriptor<>(
		stateName,
		recordType,
		Types.INT);
	if (ttlConfig.isEnabled()) {
		recordStateDesc.enableTimeToLive(ttlConfig);
	}
	this.recordState = ctx.getMapState(recordStateDesc);
}