热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.flink.api.java.typeutils.GenericTypeInfo.()方法的使用及代码示例

本文整理了Java中org.apache.flink.api.java.typeutils.GenericTypeInfo.<init>()方法的一些代码示

本文整理了Java中org.apache.flink.api.java.typeutils.GenericTypeInfo.()方法的一些代码示例,展示了GenericTypeInfo.()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GenericTypeInfo.()方法的具体详情如下:
包路径:org.apache.flink.api.java.typeutils.GenericTypeInfo
类名称:GenericTypeInfo
方法名:

GenericTypeInfo.介绍

暂无

代码示例

代码示例来源:origin: apache/flink

/**
* Returns generic type information for any Java object. The serialization logic will
* use the general purpose serializer Kryo.
*
*

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
* about how to improve efficiency (namely by pre-registering classes).
*
* @param genericClass any Java class
*/
public static TypeInformation GENERIC(Class genericClass) {
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(clazz);
"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(clazz);
genericClass = typeToClass(fieldType);
pojoFields.add(new PojoField(field, new GenericTypeInfo((Class) genericClass)));

代码示例来源:origin: apache/flink

@SuppressWarnings("unchecked")
@Internal
private static List generateFieldsFromAvroSchema(Class typeClass) {
PojoTypeExtractor pte = new PojoTypeExtractor();
ArrayList typeHierarchy = new 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 newFields = new ArrayList<>(pti.getTotalFields());
for (int i = 0; i PojoField f = pti.getPojoFieldAt(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 genericType = new GenericTypeInfo<>(GenericNonKeyType.class);
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(clazz);
return new GenericTypeInfo<>(clazz);
return new GenericTypeInfo(clazz);
return new GenericTypeInfo(clazz);

代码示例来源:origin: apache/flink

@Override
protected TypeSerializer createSerializer(Class type) {
ExecutionConfig cOnf= new ExecutionConfig();
conf.registerTypeWithKryoSerializer(LocalDate.class, LocalDateSerializer.class);
TypeInformation typeInfo = new GenericTypeInfo(type);
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, Object[]> keySelector =
new KeySelector, Object[]>() {
@Override
public Object[] getKey(Tuple2 value) throws Exception {
Object[] ks = new Object[value.f0.length];
for (int i = 0; i ks[i] = new Object();
}
return ks;
}
};
ObjectArrayTypeInfo keyTypeInfo = ObjectArrayTypeInfo.getInfoFor(
Object[].class, new GenericTypeInfo<>(Object.class));
testKeyRejection(keySelector, keyTypeInfo);
}

代码示例来源:origin: apache/flink

@Test
public void testKeyGenericType() {
TypeInformation genericType = new GenericTypeInfo<>(GenericKeyType.class);
ExpressionKeys ek = new ExpressionKeys<>("*", genericType);
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 PojoField field = pojoTypeForClass.getPojoFieldAt(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 rowInfo = TypeExtractor.getForObject(row);
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 genericRowInfo = TypeExtractor.getForObject(nullRow);
Assert.assertEquals(genericRowInfo, new GenericTypeInfo<>(Row.class));
}

代码示例来源:origin: apache/flink

@Test
public void testJoinWithAtomicType1() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet> ds1 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet ds2 = env.fromElements(1, 2);
DataSet, Integer>> joinDs = ds1
.fullOuterJoin(ds2)
.where(0)
.equalTo("*")
.with(new ProjectBothFunction, Integer>())
.returns(new GenericTypeInfo(Tuple2.class));
List, Integer>> result = joinDs.collect();
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 ds1 = env.fromElements(1, 2);
DataSet> ds2 = CollectionDataSets.getSmall3TupleDataSet(env);
DataSet>> joinDs = ds1
.fullOuterJoin(ds2)
.where("*")
.equalTo(0)
.with(new ProjectBothFunction>())
.returns(new GenericTypeInfo(Tuple2.class));
List>> result = joinDs.collect();
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 kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
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);
}
}

推荐阅读
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Flink(三)IDEA开发Flink环境搭建与测试
    一.IDEA开发环境1.pom文件设置1.8 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 如何用JNI技术调用Java接口以及提高Java性能的详解
    本文介绍了如何使用JNI技术调用Java接口,并详细解析了如何通过JNI技术提高Java的性能。同时还讨论了JNI调用Java的private方法、Java开发中使用JNI技术的情况以及使用Java的JNI技术调用C++时的运行效率问题。文章还介绍了JNIEnv类型的使用方法,包括创建Java对象、调用Java对象的方法、获取Java对象的属性等操作。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 怀疑是每次都在新建文件,具体代码如下 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • Google Play推出全新的应用内评价API,帮助开发者获取更多优质用户反馈。用户每天在Google Play上发表数百万条评论,这有助于开发者了解用户喜好和改进需求。开发者可以选择在适当的时间请求用户撰写评论,以获得全面而有用的反馈。全新应用内评价功能让用户无需返回应用详情页面即可发表评论,提升用户体验。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 本文概述了JNI的原理以及常用方法。JNI提供了一种Java字节码调用C/C++的解决方案,但引用类型不能直接在Native层使用,需要进行类型转化。多维数组(包括二维数组)都是引用类型,需要使用jobjectArray类型来存取其值。此外,由于Java支持函数重载,根据函数名无法找到对应的JNI函数,因此介绍了JNI函数签名信息的解决方案。 ... [详细]
  • 本文介绍了解决java开源项目apache commons email简单使用报错的方法,包括使用正确的JAR包和正确的代码配置,以及相关参数的设置。详细介绍了如何使用apache commons email发送邮件。 ... [详细]
  • PeopleSoft安装镜像版本及导入语言包的方法
    本文介绍了PeopleSoft安装镜像的两个版本,分别是VirtualBox虚拟机版本和NativeOS版本,并详细说明了导入语言包的方法。对于Windows版本,可以通过psdmt.exe登录进入,并使用datamover脚本导入语言包。对于Linux版本,同样可以使用命令行方式执行datamover脚本导入语言包。导入语言包后,可以实现多种语言的登录。参考文献提供了相关链接以供深入了解。 ... [详细]
  • flink 本地_Flink本地安装和创建Flink应用
    本篇介绍一下Flink本地环境搭建和创建Flink应用。本地安装Flink可以在Linux、MacOSX和Windows上运行,要求安装Java8.x。java-ve ... [详细]
author-avatar
mobiledu2502908793
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有