use of org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl in project flink by apache.
the class WindowJoinOperator method open.
@Override
public void open() throws Exception {
super.open();
this.collector = new TimestampedCollector<>(output);
collector.eraseTimestamp();
final LongSerializer windowSerializer = LongSerializer.INSTANCE;
InternalTimerService<Long> internalTimerService = getInternalTimerService("window-timers", windowSerializer, this);
this.windowTimerService = new WindowTimerServiceImpl(internalTimerService, shiftTimeZone);
// init join condition
JoinCondition condition = generatedJoinCondition.newInstance(getRuntimeContext().getUserCodeClassLoader());
this.joinCondition = new JoinConditionWithNullFilters(condition, filterNullKeys, this);
this.joinCondition.setRuntimeContext(getRuntimeContext());
this.joinCondition.open(new Configuration());
// init state
ListStateDescriptor<RowData> leftRecordStateDesc = new ListStateDescriptor<>(LEFT_RECORDS_STATE_NAME, leftSerializer);
ListState<RowData> leftListState = getOrCreateKeyedState(windowSerializer, leftRecordStateDesc);
this.leftWindowState = new WindowListState<>((InternalListState<RowData, Long, RowData>) leftListState);
ListStateDescriptor<RowData> rightRecordStateDesc = new ListStateDescriptor<>(RIGHT_RECORDS_STATE_NAME, rightSerializer);
ListState<RowData> rightListState = getOrCreateKeyedState(windowSerializer, rightRecordStateDesc);
this.rightWindowState = new WindowListState<>((InternalListState<RowData, Long, RowData>) rightListState);
// metrics
this.leftNumLateRecordsDropped = metrics.counter(LEFT_LATE_ELEMENTS_DROPPED_METRIC_NAME);
this.leftLateRecordsDroppedRate = metrics.meter(LEFT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(leftNumLateRecordsDropped));
this.rightNumLateRecordsDropped = metrics.counter(RIGHT_LATE_ELEMENTS_DROPPED_METRIC_NAME);
this.rightLateRecordsDroppedRate = metrics.meter(RIGHT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(rightNumLateRecordsDropped));
this.watermarkLatency = metrics.gauge(WATERMARK_LATENCY_METRIC_NAME, () -> {
long watermark = windowTimerService.currentWatermark();
if (watermark < 0) {
return 0L;
} else {
return windowTimerService.currentProcessingTime() - watermark;
}
});
}
use of org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl in project flink by apache.
the class AbstractWindowAggProcessor method open.
@Override
public void open(Context<Long> context) throws Exception {
this.ctx = context;
final LongSerializer namespaceSerializer = LongSerializer.INSTANCE;
ValueState<RowData> state = ctx.getKeyedStateBackend().getOrCreateKeyedState(namespaceSerializer, new ValueStateDescriptor<>("window-aggs", accSerializer));
this.windowState = new WindowValueState<>((InternalValueState<RowData, Long, RowData>) state);
this.clockService = ClockService.of(ctx.getTimerService());
this.windowTimerService = new WindowTimerServiceImpl(ctx.getTimerService(), shiftTimeZone);
this.aggregator = genAggsHandler.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
this.aggregator.open(new PerWindowStateDataViewStore(ctx.getKeyedStateBackend(), namespaceSerializer, ctx.getRuntimeContext()));
this.windowBuffer = windowBufferFactory.create(ctx.getOperatorOwner(), ctx.getMemoryManager(), ctx.getMemorySize(), ctx.getRuntimeContext(), windowTimerService, ctx.getKeyedStateBackend(), windowState, isEventTime, shiftTimeZone);
this.reuseOutput = new JoinedRowData();
this.currentProgress = Long.MIN_VALUE;
this.nextTriggerProgress = Long.MIN_VALUE;
}
use of org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl in project flink by apache.
the class WindowRankProcessor method open.
@Override
public void open(Context<Long> context) throws Exception {
this.ctx = context;
// compile comparator
sortKeyComparator = generatedSortKeyComparator.newInstance(ctx.getRuntimeContext().getUserCodeClassLoader());
final LongSerializer namespaceSerializer = LongSerializer.INSTANCE;
ListSerializer<RowData> listSerializer = new ListSerializer<>(inputSerializer);
MapStateDescriptor<RowData, List<RowData>> mapStateDescriptor = new MapStateDescriptor<>("window_rank", sortKeySerializer, listSerializer);
MapState<RowData, List<RowData>> state = ctx.getKeyedStateBackend().getOrCreateKeyedState(namespaceSerializer, mapStateDescriptor);
this.windowTimerService = new WindowTimerServiceImpl(ctx.getTimerService(), shiftTimeZone);
this.windowState = new WindowMapState<>((InternalMapState<RowData, Long, RowData, List<RowData>>) state);
this.windowBuffer = bufferFactory.create(ctx.getOperatorOwner(), ctx.getMemoryManager(), ctx.getMemorySize(), ctx.getRuntimeContext(), windowTimerService, ctx.getKeyedStateBackend(), windowState, true, shiftTimeZone);
this.reuseOutput = new JoinedRowData();
this.reuseRankRow = new GenericRowData(1);
this.currentProgress = Long.MIN_VALUE;
}
use of org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl in project flink by apache.
the class RowTimeWindowDeduplicateProcessor method open.
@Override
public void open(Context<Long> context) throws Exception {
this.ctx = context;
final LongSerializer namespaceSerializer = LongSerializer.INSTANCE;
ValueStateDescriptor<RowData> valueStateDescriptor = new ValueStateDescriptor<>("window_deduplicate", inputSerializer);
ValueState<RowData> state = ctx.getKeyedStateBackend().getOrCreateKeyedState(namespaceSerializer, valueStateDescriptor);
this.windowTimerService = new WindowTimerServiceImpl(ctx.getTimerService(), shiftTimeZone);
this.windowState = new WindowValueState<>((InternalValueState<RowData, Long, RowData>) state);
this.windowBuffer = bufferFactory.create(ctx.getOperatorOwner(), ctx.getMemoryManager(), ctx.getMemorySize(), ctx.getRuntimeContext(), windowTimerService, ctx.getKeyedStateBackend(), windowState, true, shiftTimeZone);
this.currentProgress = Long.MIN_VALUE;
}
Aggregations