Java Code Examples for org.apache.flink.api.java.ExecutionEnvironment#getConfig()
The following examples show how to use
org.apache.flink.api.java.ExecutionEnvironment#getConfig() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupReduceITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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()); }
Example 2
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@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()); }
Example 3
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@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()); }
Example 4
Source File: AvroTypeExtractionTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
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<>(in, User.class); DataSet<User> usersDS = env.createInput(users); DataSet<Object> res = usersDS .groupBy(fieldName) .reduceGroup((GroupReduceFunction<User, Object>) (values, out) -> { for (User u : values) { out.collect(u.get(fieldName)); } }) .returns(Object.class); 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)); switch (fieldName) { case "name": expected = "Alyssa\nCharlie"; break; case "type_enum": expected = "GREEN\nRED\n"; break; case "type_double_test": expected = "123.45\n1.337\n"; break; default: Assert.fail("Unknown field"); break; } after(); }
Example 5
Source File: AvroTypeExtractionTest.java From flink with Apache License 2.0 | 4 votes |
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<>(in, User.class); DataSet<User> usersDS = env.createInput(users); DataSet<Object> res = usersDS .groupBy(fieldName) .reduceGroup((GroupReduceFunction<User, Object>) (values, out) -> { for (User u : values) { out.collect(u.get(fieldName)); } }) .returns(Object.class); 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)); switch (fieldName) { case "name": expected = "Alyssa\nCharlie"; break; case "type_enum": expected = "GREEN\nRED\n"; break; case "type_double_test": expected = "123.45\n1.337\n"; break; default: Assert.fail("Unknown field"); break; } after(); }
Example 6
Source File: AvroTypeExtractionTest.java From flink with Apache License 2.0 | 4 votes |
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<>(in, User.class); DataSet<User> usersDS = env.createInput(users); DataSet<Object> res = usersDS .groupBy(fieldName) .reduceGroup((GroupReduceFunction<User, Object>) (values, out) -> { for (User u : values) { out.collect(u.get(fieldName)); } }) .returns(Object.class); 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)); switch (fieldName) { case "name": expected = "Alyssa\nCharlie"; break; case "type_enum": expected = "GREEN\nRED\n"; break; case "type_double_test": expected = "123.45\n1.337\n"; break; default: Assert.fail("Unknown field"); break; } after(); }