Search in sources :

Example 6 with ListTypeInfo

use of org.apache.flink.api.java.typeutils.ListTypeInfo in project flink by apache.

the class RowTimeRangeBoundedPrecedingFunction method open.

@Override
public void open(Configuration parameters) throws Exception {
    function = genAggsHandler.newInstance(getRuntimeContext().getUserCodeClassLoader());
    function.open(new PerKeyStateDataViewStore(getRuntimeContext()));
    output = new JoinedRowData();
    ValueStateDescriptor<Long> lastTriggeringTsDescriptor = new ValueStateDescriptor<Long>("lastTriggeringTsState", Types.LONG);
    lastTriggeringTsState = getRuntimeContext().getState(lastTriggeringTsDescriptor);
    InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
    ValueStateDescriptor<RowData> accStateDesc = new ValueStateDescriptor<RowData>("accState", accTypeInfo);
    accState = getRuntimeContext().getState(accStateDesc);
    // input element are all binary row as they are came from network
    InternalTypeInfo<RowData> inputType = InternalTypeInfo.ofFields(inputFieldTypes);
    ListTypeInfo<RowData> rowListTypeInfo = new ListTypeInfo<RowData>(inputType);
    MapStateDescriptor<Long, List<RowData>> inputStateDesc = new MapStateDescriptor<Long, List<RowData>>("inputState", Types.LONG, rowListTypeInfo);
    inputState = getRuntimeContext().getMapState(inputStateDesc);
    ValueStateDescriptor<Long> cleanupTsStateDescriptor = new ValueStateDescriptor<>("cleanupTsState", Types.LONG);
    this.cleanupTsState = getRuntimeContext().getState(cleanupTsStateDescriptor);
    // metrics
    this.numLateRecordsDropped = getRuntimeContext().getMetricGroup().counter(LATE_ELEMENTS_DROPPED_METRIC_NAME);
}
Also used : MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) ListTypeInfo(org.apache.flink.api.java.typeutils.ListTypeInfo) ArrayList(java.util.ArrayList) List(java.util.List) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 7 with ListTypeInfo

use of org.apache.flink.api.java.typeutils.ListTypeInfo 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);
}
Also used : MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) ListTypeInfo(org.apache.flink.api.java.typeutils.ListTypeInfo) ArrayList(java.util.ArrayList) List(java.util.List) PerKeyStateDataViewStore(org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)

Example 8 with ListTypeInfo

use of org.apache.flink.api.java.typeutils.ListTypeInfo 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());
}
Also used : MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) OuterJoinPaddingUtil(org.apache.flink.table.runtime.operators.join.OuterJoinPaddingUtil) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) RowData(org.apache.flink.table.data.RowData) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ListTypeInfo(org.apache.flink.api.java.typeutils.ListTypeInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

List (java.util.List)8 ListTypeInfo (org.apache.flink.api.java.typeutils.ListTypeInfo)8 ArrayList (java.util.ArrayList)7 MapStateDescriptor (org.apache.flink.api.common.state.MapStateDescriptor)7 ValueStateDescriptor (org.apache.flink.api.common.state.ValueStateDescriptor)7 RowData (org.apache.flink.table.data.RowData)7 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)5 PerKeyStateDataViewStore (org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore)5 LinkedList (java.util.LinkedList)2 Date (java.sql.Date)1 Time (java.sql.Time)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 Map (java.util.Map)1 Pickler (net.razorvine.pickle.Pickler)1 BasicArrayTypeInfo (org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo)1 BasicTypeInfo (org.apache.flink.api.common.typeinfo.BasicTypeInfo)1 PrimitiveArrayTypeInfo (org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo)1 SqlTimeTypeInfo (org.apache.flink.api.common.typeinfo.SqlTimeTypeInfo)1