当前位置: 首页>>代码示例>>Java>>正文


Java InternalTimer.getKey方法代码示例

本文整理汇总了Java中org.apache.flink.streaming.api.operators.InternalTimer.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java InternalTimer.getKey方法的具体用法?Java InternalTimer.getKey怎么用?Java InternalTimer.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.streaming.api.operators.InternalTimer的用法示例。


在下文中一共展示了InternalTimer.getKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEventTime

import org.apache.flink.streaming.api.operators.InternalTimer; //导入方法依赖的package包/类
@Override
public void onEventTime(InternalTimer<K, W> timer) throws Exception {

	triggerContext.key = timer.getKey();
	triggerContext.window = timer.getNamespace();
	evictorContext.key = timer.getKey();
	evictorContext.window = timer.getNamespace();

	MergingWindowSet<W> mergingWindows = null;

	if (windowAssigner instanceof MergingWindowAssigner) {
		mergingWindows = getMergingWindowSet();
		W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
		if (stateWindow == null) {
			// Timer firing for non-existent window, this can only happen if a
			// trigger did not clean up timers. We have already cleared the merging
			// window and therefore the Trigger state, however, so nothing to do.
			return;
		} else {
			evictingWindowState.setCurrentNamespace(stateWindow);
		}
	} else {
		evictingWindowState.setCurrentNamespace(triggerContext.window);
	}

	Iterable<StreamRecord<IN>> contents = evictingWindowState.get();

	if (contents != null) {
		TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp());
		if (triggerResult.isFire()) {
			emitWindowContents(triggerContext.window, contents, evictingWindowState);
		}
		if (triggerResult.isPurge()) {
			evictingWindowState.clear();
		}
	}

	if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) {
		clearAllState(triggerContext.window, evictingWindowState, mergingWindows);
	}

	if (mergingWindows != null) {
		// need to make sure to update the merging state in state
		mergingWindows.persist();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:EvictingWindowOperator.java

示例2: onProcessingTime

import org.apache.flink.streaming.api.operators.InternalTimer; //导入方法依赖的package包/类
@Override
public void onProcessingTime(InternalTimer<K, W> timer) throws Exception {
	triggerContext.key = timer.getKey();
	triggerContext.window = timer.getNamespace();
	evictorContext.key = timer.getKey();
	evictorContext.window = timer.getNamespace();

	MergingWindowSet<W> mergingWindows = null;

	if (windowAssigner instanceof MergingWindowAssigner) {
		mergingWindows = getMergingWindowSet();
		W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
		if (stateWindow == null) {
			// Timer firing for non-existent window, this can only happen if a
			// trigger did not clean up timers. We have already cleared the merging
			// window and therefore the Trigger state, however, so nothing to do.
			return;
		} else {
			evictingWindowState.setCurrentNamespace(stateWindow);
		}
	} else {
		evictingWindowState.setCurrentNamespace(triggerContext.window);
	}

	Iterable<StreamRecord<IN>> contents = evictingWindowState.get();

	if (contents != null) {
		TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp());
		if (triggerResult.isFire()) {
			emitWindowContents(triggerContext.window, contents, evictingWindowState);
		}
		if (triggerResult.isPurge()) {
			evictingWindowState.clear();
		}
	}

	if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) {
		clearAllState(triggerContext.window, evictingWindowState, mergingWindows);
	}

	if (mergingWindows != null) {
		// need to make sure to update the merging state in state
		mergingWindows.persist();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:46,代码来源:EvictingWindowOperator.java

示例3: onEventTime

import org.apache.flink.streaming.api.operators.InternalTimer; //导入方法依赖的package包/类
@Override
public void onEventTime(InternalTimer<K, W> timer) throws Exception {
	triggerContext.key = timer.getKey();
	triggerContext.window = timer.getNamespace();

	MergingWindowSet<W> mergingWindows;

	if (windowAssigner instanceof MergingWindowAssigner) {
		mergingWindows = getMergingWindowSet();
		W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
		if (stateWindow == null) {
			// Timer firing for non-existent window, this can only happen if a
			// trigger did not clean up timers. We have already cleared the merging
			// window and therefore the Trigger state, however, so nothing to do.
			return;
		} else {
			windowState.setCurrentNamespace(stateWindow);
		}
	} else {
		windowState.setCurrentNamespace(triggerContext.window);
		mergingWindows = null;
	}

	ACC contents = null;
	if (windowState != null) {
		contents = windowState.get();
	}

	if (contents != null) {
		TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp());
		if (triggerResult.isFire()) {
			emitWindowContents(triggerContext.window, contents);
		}
		if (triggerResult.isPurge()) {
			windowState.clear();
		}
	}

	if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) {
		clearAllState(triggerContext.window, windowState, mergingWindows);
	}

	if (mergingWindows != null) {
		// need to make sure to update the merging state in state
		mergingWindows.persist();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:48,代码来源:WindowOperator.java

示例4: onProcessingTime

import org.apache.flink.streaming.api.operators.InternalTimer; //导入方法依赖的package包/类
@Override
public void onProcessingTime(InternalTimer<K, W> timer) throws Exception {
	triggerContext.key = timer.getKey();
	triggerContext.window = timer.getNamespace();

	MergingWindowSet<W> mergingWindows;

	if (windowAssigner instanceof MergingWindowAssigner) {
		mergingWindows = getMergingWindowSet();
		W stateWindow = mergingWindows.getStateWindow(triggerContext.window);
		if (stateWindow == null) {
			// Timer firing for non-existent window, this can only happen if a
			// trigger did not clean up timers. We have already cleared the merging
			// window and therefore the Trigger state, however, so nothing to do.
			return;
		} else {
			windowState.setCurrentNamespace(stateWindow);
		}
	} else {
		windowState.setCurrentNamespace(triggerContext.window);
		mergingWindows = null;
	}

	ACC contents = null;
	if (windowState != null) {
		contents = windowState.get();
	}

	if (contents != null) {
		TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp());
		if (triggerResult.isFire()) {
			emitWindowContents(triggerContext.window, contents);
		}
		if (triggerResult.isPurge()) {
			windowState.clear();
		}
	}

	if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) {
		clearAllState(triggerContext.window, windowState, mergingWindows);
	}

	if (mergingWindows != null) {
		// need to make sure to update the merging state in state
		mergingWindows.persist();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:48,代码来源:WindowOperator.java


注:本文中的org.apache.flink.streaming.api.operators.InternalTimer.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。