當前位置: 首頁>>代碼示例>>Java>>正文


Java ConnectedStreams類代碼示例

本文整理匯總了Java中org.apache.flink.streaming.api.datastream.ConnectedStreams的典型用法代碼示例。如果您正苦於以下問題:Java ConnectedStreams類的具體用法?Java ConnectedStreams怎麽用?Java ConnectedStreams使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConnectedStreams類屬於org.apache.flink.streaming.api.datastream包,在下文中一共展示了ConnectedStreams類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isKeyed

import org.apache.flink.streaming.api.datastream.ConnectedStreams; //導入依賴的package包/類
private static boolean isKeyed(ConnectedStreams<?, ?> dataStream) {
	return (dataStream.getFirstInput() instanceof KeyedStream && dataStream.getSecondInput() instanceof KeyedStream);
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:4,代碼來源:DataStreamTest.java

示例2: testOutputTypeConfigurationWithTwoInputTransformation

import org.apache.flink.streaming.api.datastream.ConnectedStreams; //導入依賴的package包/類
@Test
public void testOutputTypeConfigurationWithTwoInputTransformation() throws Exception {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<Integer> source1 = env.fromElements(1, 10);
	DataStream<Integer> source2 = env.fromElements(2, 11);

	ConnectedStreams<Integer, Integer> connectedSource = source1.connect(source2);

	OutputTypeConfigurableOperationWithTwoInputs outputTypeConfigurableOperation = new OutputTypeConfigurableOperationWithTwoInputs();

	DataStream<Integer> result = connectedSource.transform(
			"Two input and output type configurable operation",
			BasicTypeInfo.INT_TYPE_INFO,
			outputTypeConfigurableOperation);

	result.addSink(new DiscardingSink<Integer>());

	env.getStreamGraph();

	assertEquals(BasicTypeInfo.INT_TYPE_INFO, outputTypeConfigurableOperation.getTypeInformation());
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:23,代碼來源:StreamGraphGeneratorTest.java

示例3: main

import org.apache.flink.streaming.api.datastream.ConnectedStreams; //導入依賴的package包/類
public static void main(String[] args) throws Exception {		
	
	final AppConfiguration config = AppConfigurator.loadConfiguration(args);
	
	final StreamExecutionEnvironment env = EnvConfigurator.setupExecutionEnvironment(config);
	
	EnvConfigurator.initializeRedis(config.getRedisHostname(), config.getRedisPort());
	
	DataStream<EventCommentFriendshipLike> events = EventCommentFriendshipLikeStreamgen.getStreamOfEvents(env, config);
	
	SplitStream<EventCommentFriendshipLike> splitted = events.split(new FriendshipSplitter());
	
	DataStream<Friendship> friendships = splitted.select(FriendshipSplitter.FRIENDSHIP_ONLY).map(new FriendshipOperator()).setParallelism(1).broadcast();
	
	DataStream<EventCommentLike> eventsStream = splitted.select(FriendshipSplitter.EVENT_ALL).map(new EventCommentLikeExtractor()).keyBy(new EventCommentLikeKeyer());
			
	ConnectedStreams<EventCommentLike, Friendship> process = eventsStream.connect(friendships);
	
	DataStream<CommentScore> scores = process.flatMap(new CommentScoreUpdater(config.getD())).setParallelism(config.getParallelism());
	
	DataStream<CommentRank> bests = scores.keyBy(new CommentScoreKeyer()).flatMap(new CommentRankerSort(config.getK())).setParallelism(config.getParallelism());
	
	DataStream<CommentRank> tops = null;
	
	if (config.getParallelism() == 1) {
		tops = bests;
	} else {
		tops = bests.flatMap(new CommentRankMergerSort(config.getK())).setParallelism(1);
	}

	DataStream<CommentRank> newtops = tops.filter(new CommentRankUpdateFilter(config.getK())).setParallelism(1);

	newtops.addSink(new AsStringSink<CommentRank>(config.getSinkPath(JOB_NAME)));
	
	JobExecutionResult res = env.execute(JOB_NAME);
	
	PerformanceWriter.write(res, config.getPerformancePath(JOB_NAME));
}
 
開發者ID:3Cores,項目名稱:sostream,代碼行數:39,代碼來源:QueryTwo.java


注:本文中的org.apache.flink.streaming.api.datastream.ConnectedStreams類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。