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


Java DataSet.cross方法代码示例

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


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

示例1: testAdvanced

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testAdvanced() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.getConfig().disableObjectReuse();

	DataSet<Integer> data = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
	DataSet<Integer> data2 = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	DataSet<Tuple2<Integer, Integer>> data3 = data.cross(data2);

	// count
	long numEntries = data3.count();
	assertEquals(100, numEntries);

	// collect
	ArrayList<Tuple2<Integer, Integer>> list = (ArrayList<Tuple2<Integer, Integer>>) data3.collect();

	// set expected entries in a hash map to true
	HashMap<Tuple2<Integer, Integer>, Boolean> expected = new HashMap<Tuple2<Integer, Integer>, Boolean>();
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			expected.put(new Tuple2<Integer, Integer>(i, j), true);
		}
	}

	// check if all entries are contained in the hash map
	for (int i = 0; i < 100; i++) {
		Tuple2<Integer, Integer> element = list.get(i);
		assertEquals(expected.get(element), true);
		expected.remove(element);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:CountCollectITCase.java

示例2: testCorrectnessOfDefaultCross

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
@Test
public void testCorrectnessOfDefaultCross() throws Exception {
	/*
	 * check correctness of default cross
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple3<Integer, Long, String>> ds = CollectionDataSets.getSmall3TupleDataSet(env);
	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = CollectionDataSets.getSmall5TupleDataSet(env);
	DataSet<Tuple2<Tuple3<Integer, Long, String>, Tuple5<Integer, Long, Integer, String, Long>>> crossDs = ds.cross(ds2);

	List<Tuple2<Tuple3<Integer, Long, String>, Tuple5<Integer, Long, Integer, String, Long>>> result = crossDs.collect();

	String expected = "(1,1,Hi),(2,2,1,Hallo Welt,2)\n"
			+
			"(1,1,Hi),(1,1,0,Hallo,1)\n" +
			"(1,1,Hi),(2,3,2,Hallo Welt wie,1)\n" +
			"(2,2,Hello),(2,2,1,Hallo Welt,2)\n" +
			"(2,2,Hello),(1,1,0,Hallo,1)\n" +
			"(2,2,Hello),(2,3,2,Hallo Welt wie,1)\n" +
			"(3,2,Hello world),(2,2,1,Hallo Welt,2)\n" +
			"(3,2,Hello world),(1,1,0,Hallo,1)\n" +
			"(3,2,Hello world),(2,3,2,Hallo Welt wie,1)\n";

	compareResultAsTuples(result, expected);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:CrossITCase.java

示例3: createCrossOperation

import org.apache.flink.api.java.DataSet; //导入方法依赖的package包/类
private <IN1, IN2, OUT> void createCrossOperation(DatasizeHint mode, PythonOperationInfo info, TypeInformation<OUT> type) {
	DataSet<IN1> op1 = sets.getDataSet(info.parentID);
	DataSet<IN2> op2 = sets.getDataSet(info.otherID);

	DefaultCross<IN1, IN2> defaultResult;
	switch (mode) {
		case NONE:
			defaultResult = op1.cross(op2);
			break;
		case HUGE:
			defaultResult = op1.crossWithHuge(op2);
			break;
		case TINY:
			defaultResult = op1.crossWithTiny(op2);
			break;
		default:
			throw new IllegalArgumentException("Invalid Cross mode specified: " + mode);
	}

	defaultResult.setParallelism(info.parallelism);
	if (info.usesUDF) {
		sets.add(info.setID, defaultResult
			.mapPartition(new PythonMapPartition<Tuple2<IN1, IN2>, OUT>(operatorConfig, info.envID, info.setID, type))
			.setParallelism(info.parallelism).name(info.name));
	} else {
		sets.add(info.setID, defaultResult.name("DefaultCross"));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:29,代码来源:PythonPlanBinder.java


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