use of org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore in project flink by apache.
the class MiniBatchLocalGroupAggFunction method open.
@Override
public void open(ExecutionContext ctx) throws Exception {
super.open(ctx);
// instantiate function
function = genAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
function.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext()));
resultRow = new JoinedRowData();
}
use of org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore in project flink by apache.
the class MiniBatchIncrementalGroupAggFunction method open.
@Override
public void open(ExecutionContext ctx) throws Exception {
super.open(ctx);
ClassLoader classLoader = ctx.getRuntimeContext().getUserCodeClassLoader();
StateTtlConfig ttlConfig = createTtlConfig(stateRetentionTime);
partialAgg = genPartialAggsHandler.newInstance(classLoader);
partialAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext()));
finalAgg = genFinalAggsHandler.newInstance(classLoader);
finalAgg.open(new PerKeyStateDataViewStore(ctx.getRuntimeContext(), ttlConfig));
resultRow = new JoinedRowData();
}
use of org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore in project flink by apache.
the class GroupTableAggFunction method open.
@Override
public void open(Configuration parameters) throws Exception {
super.open(parameters);
// instantiate function
StateTtlConfig ttlConfig = createTtlConfig(stateRetentionTime);
function = genAggsHandler.newInstance(getRuntimeContext().getUserCodeClassLoader());
function.open(new PerKeyStateDataViewStore(getRuntimeContext(), ttlConfig));
InternalTypeInfo<RowData> accTypeInfo = InternalTypeInfo.ofFields(accTypes);
ValueStateDescriptor<RowData> accDesc = new ValueStateDescriptor<>("accState", accTypeInfo);
if (ttlConfig.isEnabled()) {
accDesc.enableTimeToLive(ttlConfig);
}
accState = getRuntimeContext().getState(accDesc);
}
use of org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore in project flink by apache.
the class ProcTimeRowsBoundedPrecedingFunction 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 keyed
// by the ingestion time in the operator.
// we also keep counter of processed elements
// and timestamp of oldest element
ListTypeInfo<RowData> rowListTypeInfo = new ListTypeInfo<RowData>(inputType);
MapStateDescriptor<Long, List<RowData>> mapStateDescriptor = new MapStateDescriptor<Long, List<RowData>>("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> processedCountDescriptor = new ValueStateDescriptor<Long>("processedCountState", Types.LONG);
counterState = getRuntimeContext().getState(processedCountDescriptor);
ValueStateDescriptor<Long> smallestTimestampDescriptor = new ValueStateDescriptor<Long>("smallestTSState", Types.LONG);
smallestTsState = getRuntimeContext().getState(smallestTimestampDescriptor);
initCleanupTimeState("ProcTimeBoundedRowsOverCleanupTime");
}
use of org.apache.flink.table.runtime.dataview.PerKeyStateDataViewStore 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);
}
Aggregations