热门标签 | 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);
}
}

推荐阅读
  • 本文探讨了如何在 Spring MVC 框架下,通过自定义注解和拦截器机制来实现细粒度的权限管理功能。 ... [详细]
  • Maven + Spring + MyBatis + MySQL 环境搭建与实例解析
    本文详细介绍如何使用MySQL数据库进行环境搭建,包括创建数据库表并插入示例数据。随后,逐步指导如何配置Maven项目,整合Spring框架与MyBatis,实现高效的数据访问。 ... [详细]
  • 长期从事ABAP开发工作的专业人士,在面对行业新趋势时,往往需要重新审视自己的发展方向。本文探讨了几位资深专家对ABAP未来走向的看法,以及开发者应如何调整技能以适应新的技术环境。 ... [详细]
  • 本文详细介绍了 `org.apache.tinkerpop.gremlin.structure.VertexProperty` 类中的 `key()` 方法,并提供了多个实际应用的代码示例。通过这些示例,读者可以更好地理解该方法在图数据库操作中的具体用途。 ... [详细]
  • 本文详细介绍了如何使用C#实现不同类型的系统服务账户(如Windows服务、计划任务和IIS应用池)的密码重置方法。 ... [详细]
  • Spring Security基础配置详解
    本文详细介绍了Spring Security的基础配置方法,包括如何搭建Maven多模块工程以及具体的安全配置步骤,帮助开发者更好地理解和应用这一强大的安全框架。 ... [详细]
  • Asynchronous JavaScript and XML (AJAX) 的流行很大程度上得益于 Google 在其产品如 Google Suggest 和 Google Maps 中的应用。本文将深入探讨 AJAX 在 .NET 环境下的工作原理及其实现方法。 ... [详细]
  • 探讨了在HTML表单中使用元素代替进行表单提交的方法。 ... [详细]
  • 本文详细介绍了如何在 Ubuntu 14.04 系统上搭建仅使用 CPU 的 Caffe 深度学习框架,包括环境准备、依赖安装及编译过程。 ... [详细]
  • Hibernate全自动全映射ORM框架,旨在消除sql,是一个持久层的ORM框架1)、基础概念DAO(DataAccessorOb ... [详细]
  • ASP.NET 进度条实现详解
    本文介绍了如何在ASP.NET中使用HTML和JavaScript创建一个动态更新的进度条,并通过Default.aspx页面进行展示。 ... [详细]
  • 利用Node.js实现PSD文件的高效切图
    本文介绍了如何通过Node.js及其psd2json模块,快速实现PSD文件的自动化切图过程,以适应项目中频繁的界面更新需求。此方法不仅提高了工作效率,还简化了从设计稿到实际应用的转换流程。 ... [详细]
  • 本文探讨了如何利用RxJS库在AngularJS应用中实现对用户单击和拖动操作的精确区分,特别是在调整区域大小的场景下。 ... [详细]
  • 本文详细介绍了在 CentOS 系统中如何创建和管理 SWAP 分区,包括临时创建交换文件、永久性增加交换空间的方法,以及如何手动释放内存缓存。 ... [详细]
  • 本文介绍了如何通过C#语言调用动态链接库(DLL)中的函数来实现IC卡的基本操作,包括初始化设备、设置密码模式、获取设备状态等,并详细展示了将TextBox中的数据写入IC卡的具体实现方法。 ... [详细]
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社区 版权所有