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


Java DuplicateValue類代碼示例

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


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

示例1: testProgram

import org.apache.flink.examples.java.graph.ConnectedComponents.DuplicateValue; //導入依賴的package包/類
@Override
protected void testProgram() throws Exception {

	// set up execution environment
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	// read vertex and edge data
	DataSet<Long> vertices = env.fromElements(ConnectedComponentsData.getEnumeratingVertices(NUM_VERTICES).split("\n"))
			.map(new VertexParser());

	DataSet<Tuple2<Long, Long>> edges = env.fromElements(ConnectedComponentsData.getRandomOddEvenEdges(NUM_EDGES, NUM_VERTICES, SEED).split("\n"))
			.flatMap(new EdgeParser());

	// assign the initial components (equal to the vertex id)
	DataSet<Tuple2<Long, Long>> verticesWithInitialId = vertices.map(new DuplicateValue<Long>());

	// open a delta iteration
	DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration =
			verticesWithInitialId.iterateDelta(verticesWithInitialId, 100, 0);

	// apply the step logic: join with the edges, select the minimum neighbor, update if the component of the candidate is smaller
	DataSet<Tuple2<Long, Long>> changes = iteration
			.getWorkset().join(edges).where(0).equalTo(0).with(new NeighborWithComponentIDJoin())
			.coGroup(iteration.getSolutionSet()).where(0).equalTo(0)
			.with(new MinIdAndUpdate());

	// close the delta iteration (delta and new workset are identical)
	DataSet<Tuple2<Long, Long>> result = iteration.closeWith(changes, changes);

	// emit result
	List<Tuple2<Long, Long>> resutTuples = new ArrayList<>();
	result.output(new LocalCollectionOutputFormat<>(resutTuples));

	env.execute();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:36,代碼來源:CoGroupConnectedComponentsSecondITCase.java

示例2: testProgram

import org.apache.flink.examples.java.graph.ConnectedComponents.DuplicateValue; //導入依賴的package包/類
@Override
protected void testProgram() throws Exception {
		
	// set up execution environment
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	
	// read vertex and edge data
	DataSet<Long> vertices = env.fromElements(ConnectedComponentsData.getEnumeratingVertices(NUM_VERTICES).split("\n"))
			.map(new VertexParser());
	
	DataSet<Tuple2<Long, Long>> edges = env.fromElements(ConnectedComponentsData.getRandomOddEvenEdges(NUM_EDGES, NUM_VERTICES, SEED).split("\n"))
			.flatMap(new EdgeParser());
	
	// assign the initial components (equal to the vertex id)
	DataSet<Tuple2<Long, Long>> verticesWithInitialId = vertices.map(new DuplicateValue<Long>());
			
	// open a delta iteration
	DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration =
			verticesWithInitialId.iterateDelta(verticesWithInitialId, 100, 0);
	
	// apply the step logic: join with the edges, select the minimum neighbor, update if the component of the candidate is smaller
	DataSet<Tuple2<Long, Long>> changes = iteration
			.getWorkset().join(edges).where(0).equalTo(0).with(new NeighborWithComponentIDJoin())
			.coGroup(iteration.getSolutionSet()).where(0).equalTo(0)
			.with(new MinIdAndUpdate());

	// close the delta iteration (delta and new workset are identical)
	DataSet<Tuple2<Long, Long>> result = iteration.closeWith(changes, changes);
	
	
	// emit result
	List<Tuple2<Long,Long>> resutTuples = new ArrayList<Tuple2<Long,Long>>();
	result.output(new LocalCollectionOutputFormat<Tuple2<Long,Long>>(resutTuples));
	
	env.execute();
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:37,代碼來源:CoGroupConnectedComponentsSecondITCase.java


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