org.apache.flink.api.common.functions.RichCrossFunction Java Examples
The following examples show how to use
org.apache.flink.api.common.functions.RichCrossFunction.
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: TypeExtractorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPojo() { // use getCrossReturnTypes() RichCrossFunction<?, ?, ?> function = new RichCrossFunction<CustomType, Integer, CustomType>() { private static final long serialVersionUID = 1L; @Override public CustomType cross(CustomType first, Integer second) throws Exception { return null; } }; TypeInformation<?> ti = TypeExtractor.getCrossReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<CustomType>(){}), (TypeInformation) Types.INT); Assert.assertFalse(ti.isBasicType()); Assert.assertFalse(ti.isTupleType()); Assert.assertTrue(ti instanceof PojoTypeInfo); Assert.assertEquals(ti.getTypeClass(), CustomType.class); // use getForClass() Assert.assertTrue(TypeExtractor.getForClass(CustomType.class) instanceof PojoTypeInfo); Assert.assertEquals(TypeExtractor.getForClass(CustomType.class).getTypeClass(), ti.getTypeClass()); // use getForObject() CustomType t = new CustomType("World", 1); TypeInformation<?> ti2 = TypeExtractor.getForObject(t); Assert.assertFalse(ti2.isBasicType()); Assert.assertFalse(ti2.isTupleType()); Assert.assertTrue(ti2 instanceof PojoTypeInfo); Assert.assertEquals(ti2.getTypeClass(), CustomType.class); Assert.assertFalse(TypeExtractor.getForClass(PojoWithNonPublicDefaultCtor.class) instanceof PojoTypeInfo); }
Example #2
Source File: TypeExtractorTest.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPojo() { // use getCrossReturnTypes() RichCrossFunction<?, ?, ?> function = new RichCrossFunction<CustomType, Integer, CustomType>() { private static final long serialVersionUID = 1L; @Override public CustomType cross(CustomType first, Integer second) throws Exception { return null; } }; TypeInformation<?> ti = TypeExtractor.getCrossReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<CustomType>(){}), (TypeInformation) Types.INT); Assert.assertFalse(ti.isBasicType()); Assert.assertFalse(ti.isTupleType()); Assert.assertTrue(ti instanceof PojoTypeInfo); Assert.assertEquals(ti.getTypeClass(), CustomType.class); // use getForClass() Assert.assertTrue(TypeExtractor.getForClass(CustomType.class) instanceof PojoTypeInfo); Assert.assertEquals(TypeExtractor.getForClass(CustomType.class).getTypeClass(), ti.getTypeClass()); // use getForObject() CustomType t = new CustomType("World", 1); TypeInformation<?> ti2 = TypeExtractor.getForObject(t); Assert.assertFalse(ti2.isBasicType()); Assert.assertFalse(ti2.isTupleType()); Assert.assertTrue(ti2 instanceof PojoTypeInfo); Assert.assertEquals(ti2.getTypeClass(), CustomType.class); Assert.assertFalse(TypeExtractor.getForClass(PojoWithNonPublicDefaultCtor.class) instanceof PojoTypeInfo); }
Example #3
Source File: TypeExtractorTest.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPojo() { // use getCrossReturnTypes() RichCrossFunction<?, ?, ?> function = new RichCrossFunction<CustomType, Integer, CustomType>() { private static final long serialVersionUID = 1L; @Override public CustomType cross(CustomType first, Integer second) throws Exception { return null; } }; TypeInformation<?> ti = TypeExtractor.getCrossReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<CustomType>(){}), (TypeInformation) Types.INT); Assert.assertFalse(ti.isBasicType()); Assert.assertFalse(ti.isTupleType()); Assert.assertTrue(ti instanceof PojoTypeInfo); Assert.assertEquals(ti.getTypeClass(), CustomType.class); // use getForClass() Assert.assertTrue(TypeExtractor.getForClass(CustomType.class) instanceof PojoTypeInfo); Assert.assertEquals(TypeExtractor.getForClass(CustomType.class).getTypeClass(), ti.getTypeClass()); // use getForObject() CustomType t = new CustomType("World", 1); TypeInformation<?> ti2 = TypeExtractor.getForObject(t); Assert.assertFalse(ti2.isBasicType()); Assert.assertFalse(ti2.isTupleType()); Assert.assertTrue(ti2 instanceof PojoTypeInfo); Assert.assertEquals(ti2.getTypeClass(), CustomType.class); Assert.assertFalse(TypeExtractor.getForClass(PojoWithNonPublicDefaultCtor.class) instanceof PojoTypeInfo); }