本文整理了Java中org.apache.flink.api.java.typeutils.GenericTypeInfo.
方法的一些代码示例,展示了GenericTypeInfo.
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GenericTypeInfo.
方法的具体详情如下:
包路径:org.apache.flink.api.java.typeutils.GenericTypeInfo
类名称:GenericTypeInfo
方法名:
暂无
代码示例来源:origin: apache/flink
Generic types are black-boxes for Flink, but allow any object and null values in fields. By default, serialization of this type is not very efficient. Please read the documentation/**
* Returns generic type information for any Java object. The serialization logic will
* use the general purpose serializer Kryo.
*
*
*
*
* about how to improve efficiency (namely by pre-registering classes).
*
* @param genericClass any Java class
*/
public static
return new GenericTypeInfo<>(genericClass);
}
代码示例来源:origin: apache/flink
@Override
protected GenericTypeInfo>[] getTestData() {
return new GenericTypeInfo>[] {
new GenericTypeInfo<>(TestClass.class),
new GenericTypeInfo<>(AlternativeClass.class)
};
}
代码示例来源:origin: apache/flink
private TypeInformation getFieldType(HCatFieldSchema fieldSchema) {
switch(fieldSchema.getType()) {
case INT:
return BasicTypeInfo.INT_TYPE_INFO;
case TINYINT:
return BasicTypeInfo.BYTE_TYPE_INFO;
case SMALLINT:
return BasicTypeInfo.SHORT_TYPE_INFO;
case BIGINT:
return BasicTypeInfo.LONG_TYPE_INFO;
case BOOLEAN:
return BasicTypeInfo.BOOLEAN_TYPE_INFO;
case FLOAT:
return BasicTypeInfo.FLOAT_TYPE_INFO;
case DOUBLE:
return BasicTypeInfo.DOUBLE_TYPE_INFO;
case STRING:
return BasicTypeInfo.STRING_TYPE_INFO;
case BINARY:
return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
case ARRAY:
return new GenericTypeInfo(List.class);
case MAP:
return new GenericTypeInfo(Map.class);
case STRUCT:
return new GenericTypeInfo(List.class);
default:
throw new IllegalArgumentException("Unknown data type \"" + fieldSchema.getType() + "\" encountered.");
}
}
代码示例来源:origin: apache/flink
"and must be processed as GenericType. Please read the Flink documentation " +
"on \"Data Types & Serialization\" for details of the effect on performance.");
return new GenericTypeInfo
"and must be processed as GenericType. Please read the Flink documentation " +
"on \"Data Types & Serialization\" for details of the effect on performance.");
return new GenericTypeInfo
genericClass = typeToClass(fieldType);
pojoFields.add(new PojoField(field, new GenericTypeInfo
代码示例来源:origin: apache/flink
@SuppressWarnings("unchecked")
@Internal
private static
PojoTypeExtractor pte = new PojoTypeExtractor();
ArrayList
typeHierarchy.add(typeClass);
TypeInformation ti = pte.analyzePojo(typeClass, typeHierarchy, null, null, null);
if (!(ti instanceof PojoTypeInfo)) {
throw new IllegalStateException("Expecting type to be a PojoTypeInfo");
}
PojoTypeInfo pti = (PojoTypeInfo) ti;
List
for (int i = 0; i
TypeInformation newType = f.getTypeInformation();
// check if type is a CharSequence
if (newType instanceof GenericTypeInfo) {
if ((newType).getTypeClass().equals(CharSequence.class)) {
// replace the type by a org.apache.avro.util.Utf8
newType = new GenericTypeInfo(org.apache.avro.util.Utf8.class);
}
}
PojoField newField = new PojoField(f.getField(), newType);
newFields.add(newField);
}
return newFields;
}
代码示例来源:origin: apache/flink
@Test(expected = InvalidProgramException.class)
public void testGenericNonKeyType() {
// Fail: GenericType cannot be used as key
TypeInformation
new ExpressionKeys<>("*", genericType);
}
代码示例来源:origin: apache/flink
@Override
protected ObjectArrayTypeInfo, ?>[] getTestData() {
return new ObjectArrayTypeInfo, ?>[] {
ObjectArrayTypeInfo.getInfoFor(TestClass[].class, new GenericTypeInfo<>(TestClass.class)),
ObjectArrayTypeInfo.getInfoFor(TestClass[].class, new PojoTypeInfo<>(TestClass.class, new ArrayList
};
}
代码示例来源:origin: apache/flink
@Test
public void testForwardWithGenericTypePublicAttrAccess() {
compareAnalyzerResultWithAnnotationsSingleInput(MapFunction.class, Map4.class,
new GenericTypeInfo<>(MyPojo.class), Types.STRING);
}
代码示例来源:origin: apache/flink
return new GenericTypeInfo<>(clazz);
return new GenericTypeInfo
return new GenericTypeInfo<>(clazz);
return new GenericTypeInfo
return new GenericTypeInfo
代码示例来源:origin: apache/flink
@Override
protected
ExecutionConfig cOnf= new ExecutionConfig();
conf.registerTypeWithKryoSerializer(LocalDate.class, LocalDateSerializer.class);
TypeInformation
return typeInfo.createSerializer(conf);
}
代码示例来源:origin: apache/flink
@Test
public void testOfGenericClassForGenericType() {
assertEquals(new GenericTypeInfo<>(List.class), TypeInformation.of(List.class));
}
代码示例来源:origin: apache/flink
new GenericTypeInfo<>(FileCopyTask.class), "fileCopyTasks");
代码示例来源:origin: apache/flink
@Test
public void testObjectArrayKeyRejection() {
KeySelector
new KeySelector
@Override
public Object[] getKey(Tuple2
Object[] ks = new Object[value.f0.length];
for (int i = 0; i
}
return ks;
}
};
ObjectArrayTypeInfo keyTypeInfo = ObjectArrayTypeInfo.getInfoFor(
Object[].class, new GenericTypeInfo<>(Object.class));
testKeyRejection(keySelector, keyTypeInfo);
}
代码示例来源:origin: apache/flink
@Test
public void testKeyGenericType() {
TypeInformation
ExpressionKeys
Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
}
代码示例来源:origin: apache/flink
/**
* Test if the TypeExtractor is accepting untyped generics,
* making them GenericTypes
*/
@Test
public void testPojoWithGenericsSomeFieldsGeneric() {
TypeInformation> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenerics.class);
Assert.assertTrue(typeForClass instanceof PojoTypeInfo>);
PojoTypeInfo> pojoTypeForClass = (PojoTypeInfo>) typeForClass;
for(int i = 0; i
String name = field.getField().getName();
if(name.equals("field1")) {
Assert.assertEquals(new GenericTypeInfo(Object.class), field.getTypeInformation());
} else if (name.equals("field2")) {
Assert.assertEquals(new GenericTypeInfo(Object.class), field.getTypeInformation());
} else if (name.equals("key")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
} else {
Assert.fail("Unexpected field "+field);
}
}
}
代码示例来源:origin: apache/flink
@Test
public void testDisableGenericTypes() {
ExecutionConfig cOnf= new ExecutionConfig();
TypeInformation typeInfo = new GenericTypeInfo(Object.class);
// by default, generic types are supported
TypeSerializer serializer = typeInfo.createSerializer(conf);
assertTrue(serializer instanceof KryoSerializer);
// expect an exception when generic types are disabled
conf.disableGenericTypes();
try {
typeInfo.createSerializer(conf);
fail("should have failed with an exception");
}
catch (UnsupportedOperationException e) {
// expected
}
}
代码示例来源:origin: apache/flink
@Test
public void testRow() {
Row row = new Row(2);
row.setField(0, "string");
row.setField(1, 15);
TypeInformation
Assert.assertEquals(rowInfo.getClass(), RowTypeInfo.class);
Assert.assertEquals(2, rowInfo.getArity());
Assert.assertEquals(
new RowTypeInfo(
BasicTypeInfo.STRING_TYPE_INFO,
BasicTypeInfo.INT_TYPE_INFO),
rowInfo);
Row nullRow = new Row(2);
TypeInformation
Assert.assertEquals(genericRowInfo, new GenericTypeInfo<>(Row.class));
}
代码示例来源:origin: apache/flink
@Test
public void testJoinWithAtomicType1() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet
DataSet
DataSet
.fullOuterJoin(ds2)
.where(0)
.equalTo("*")
.with(new ProjectBothFunction
.returns(new GenericTypeInfo(Tuple2.class));
List
String expected = "(1,1,Hi),1\n" +
"(2,2,Hello),2\n" +
"(3,2,Hello world),null\n";
compareResultAsTuples(result, expected);
}
代码示例来源:origin: apache/flink
@Test
public void testJoinWithAtomicType2() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet
DataSet
DataSet
.fullOuterJoin(ds2)
.where("*")
.equalTo(0)
.with(new ProjectBothFunction
.returns(new GenericTypeInfo(Tuple2.class));
List
String expected = "1,(1,1,Hi)\n" +
"2,(2,2,Hello)\n" +
"null,(3,2,Hello world)\n";
compareResultAsTuples(result, expected);
}
代码示例来源:origin: apache/flink
@Test
public void testTypeRegistrationFromTypeInfo() {
ExecutionConfig cOnf= new ExecutionConfig();
Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet
KryoSerializer
assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
// check if the generic type from one field is also registered (its very likely that
// generic types are also used as fields somewhere.
assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
}
}