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


Java ExecutionEnvironment.getConfig方法代码示例

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


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

示例1: testField

import org.apache.flink.api.java.ExecutionEnvironment; //导入方法依赖的package包/类
private void testField(final String fieldName) throws Exception {
	before();

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Path in = new Path(inFile.getAbsoluteFile().toURI());

	AvroInputFormat<User> users = new AvroInputFormat<User>(in, User.class);
	DataSet<User> usersDS = env.createInput(users);

	DataSet<Object> res = usersDS.groupBy(fieldName).reduceGroup(new GroupReduceFunction<User, Object>() {
		@Override
		public void reduce(Iterable<User> values, Collector<Object> out) throws Exception {
			for (User u : values) {
				out.collect(u.get(fieldName));
			}
		}
	});
	res.writeAsText(resultPath);
	env.execute("Simple Avro read job");

	// test if automatic registration of the Types worked
	ExecutionConfig ec = env.getConfig();
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(org.apache.flink.api.io.avro.generated.Fixed16.class));

	if (fieldName.equals("name")) {
		expected = "Alyssa\nCharlie";
	} else if (fieldName.equals("type_enum")) {
		expected = "GREEN\nRED\n";
	} else if (fieldName.equals("type_double_test")) {
		expected = "123.45\n1.337\n";
	} else {
		Assert.fail("Unknown field");
	}

	after();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:AvroPojoTest.java

示例2: testField

import org.apache.flink.api.java.ExecutionEnvironment; //导入方法依赖的package包/类
private void testField(final String fieldName) throws Exception {
	before();

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Path in = new Path(inFile.getAbsoluteFile().toURI());

	AvroInputFormat<User> users = new AvroInputFormat<User>(in, User.class);
	DataSet<User> usersDS = env.createInput(users);

	DataSet<Object> res = usersDS.groupBy(fieldName).reduceGroup(new GroupReduceFunction<User, Object>() {
		@Override
		public void reduce(Iterable<User> values, Collector<Object> out) throws Exception {
			for (User u : values) {
				out.collect(u.get(fieldName));
			}
		}
	});
	res.writeAsText(resultPath);
	env.execute("Simple Avro read job");

	// test if automatic registration of the Types worked
	ExecutionConfig ec = env.getConfig();
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(Fixed16.class));

	if (fieldName.equals("name")) {
		expected = "Alyssa\nCharlie";
	} else if (fieldName.equals("type_enum")) {
		expected = "GREEN\nRED\n";
	} else if (fieldName.equals("type_double_test")) {
		expected = "123.45\n1.337\n";
	} else {
		Assert.fail("Unknown field");
	}

	after();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:AvroTypeExtractionTest.java

示例3: testGroupByGenericType

import org.apache.flink.api.java.ExecutionEnvironment; //导入方法依赖的package包/类
@Test
public void testGroupByGenericType() throws Exception {
	/*
	 * Group by generic type
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);

	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("bigInt")
			.reduceGroup(new GroupReducer8());
	List<String> result = reduceDs.collect();
	ExecutionConfig ec = env.getConfig();

	// check if automatic type registration with Kryo worked
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(BigInt.class));
	Assert.assertFalse(ec.getRegisteredKryoTypes().contains(java.sql.Date.class));

	String expected = null;

	String localExpected = "[call\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=2033-05-18, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=10, mixed=[{someKey=1}, /this/is/wrong, uhlala]}\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=1976-05-03, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=31104000, mixed=null}]";

	Assert.assertEquals(localExpected, result.toString());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:31,代码来源:GroupReduceITCase.java

示例4: testField

import org.apache.flink.api.java.ExecutionEnvironment; //导入方法依赖的package包/类
private void testField(final String fieldName) throws Exception {
	before();

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Path in = new Path(inFile.getAbsoluteFile().toURI());

	AvroInputFormat<User> users = new AvroInputFormat<User>(in, User.class);
	DataSet<User> usersDS = env.createInput(users);

	DataSet<Object> res = usersDS.groupBy(fieldName).reduceGroup(new GroupReduceFunction<User, Object>() {
		@Override
		public void reduce(Iterable<User> values, Collector<Object> out) throws Exception {
			for(User u : values) {
				out.collect(u.get(fieldName));
			}
		}
	});
	res.writeAsText(resultPath);
	env.execute("Simple Avro read job");

	// test if automatic registration of the Types worked
	ExecutionConfig ec = env.getConfig();
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(org.apache.flink.api.io.avro.generated.Fixed16.class));

	if(fieldName.equals("name")) {
		expected = "Alyssa\nCharlie";
	} else if(fieldName.equals("type_enum")) {
		expected = "GREEN\nRED\n";
	} else if(fieldName.equals("type_double_test")) {
		expected = "123.45\n1.337\n";
	} else {
		Assert.fail("Unknown field");
	}

	after();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:AvroPojoTest.java


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