use of org.apache.flink.api.common.state.MapStateDescriptor in project flink by apache.
the class ProcTimeRangeBoundedPrecedingFunction method open.
@Override
public void open(Configuration parameters) throws Exception {
function = genAggsHandler.newInstance(getRuntimeContext().getUserCodeClassLoader());
function.open(new PerKeyStateDataViewStore(getRuntimeContext()));
output = new JoinedRowData();
// input element are all binary row as they are came from network
InternalTypeInfo<RowData> inputType = InternalTypeInfo.ofFields(inputFieldTypes);
// we keep the elements received in a map state indexed based on their ingestion time
ListTypeInfo<RowData> rowListTypeInfo = new ListTypeInfo<>(inputType);
MapStateDescriptor<Long, List<RowData>> mapStateDescriptor = new MapStateDescriptor<>("inputState", BasicTypeInfo.LONG_TYPE_INFO, rowListTypeInfo);
inputState = getRuntimeContext().getMapState(mapStateDescriptor);
InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
ValueStateDescriptor<RowData> stateDescriptor = new ValueStateDescriptor<RowData>("accState", accTypeInfo);
accState = getRuntimeContext().getState(stateDescriptor);
ValueStateDescriptor<Long> cleanupTsStateDescriptor = new ValueStateDescriptor<>("cleanupTsState", Types.LONG);
this.cleanupTsState = getRuntimeContext().getState(cleanupTsStateDescriptor);
}
use of org.apache.flink.api.common.state.MapStateDescriptor in project flink by apache.
the class TimeIntervalJoin method open.
@Override
public void open(Configuration parameters) throws Exception {
joinFunction.setRuntimeContext(getRuntimeContext());
joinFunction.open(parameters);
joinCollector = new EmitAwareCollector();
// Initialize the data caches.
ListTypeInfo<Tuple2<RowData, Boolean>> leftRowListTypeInfo = new ListTypeInfo<>(new TupleTypeInfo<>(leftType, BasicTypeInfo.BOOLEAN_TYPE_INFO));
MapStateDescriptor<Long, List<Tuple2<RowData, Boolean>>> leftMapStateDescriptor = new MapStateDescriptor<>("IntervalJoinLeftCache", BasicTypeInfo.LONG_TYPE_INFO, leftRowListTypeInfo);
leftCache = getRuntimeContext().getMapState(leftMapStateDescriptor);
ListTypeInfo<Tuple2<RowData, Boolean>> rightRowListTypeInfo = new ListTypeInfo<>(new TupleTypeInfo<>(rightType, BasicTypeInfo.BOOLEAN_TYPE_INFO));
MapStateDescriptor<Long, List<Tuple2<RowData, Boolean>>> rightMapStateDescriptor = new MapStateDescriptor<>("IntervalJoinRightCache", BasicTypeInfo.LONG_TYPE_INFO, rightRowListTypeInfo);
rightCache = getRuntimeContext().getMapState(rightMapStateDescriptor);
// Initialize the timer states.
ValueStateDescriptor<Long> leftValueStateDescriptor = new ValueStateDescriptor<>("IntervalJoinLeftTimerState", Long.class);
leftTimerState = getRuntimeContext().getState(leftValueStateDescriptor);
ValueStateDescriptor<Long> rightValueStateDescriptor = new ValueStateDescriptor<>("IntervalJoinRightTimerState", Long.class);
rightTimerState = getRuntimeContext().getState(rightValueStateDescriptor);
paddingUtil = new OuterJoinPaddingUtil(leftType.toRowSize(), rightType.toRowSize());
}
Aggregations