org.apache.flink.api.common.typeinfo.Types.POJO()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(328)

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

Types.POJO介绍

[英]Returns type information for a POJO (Plain Old Java Object).

A POJO class is public and standalone (no non-static inner class). It has a public no-argument constructor. All non-static, non-transient fields in the class (and all superclasses) are either public (and non-final) or have a public getter and a setter method that follows the Java beans naming conventions for getters and setters.

A POJO is a fixed-length and null-aware composite type. Every field can be null independent of the field's type.

The generic types for all fields of the POJO can be defined in a hierarchy of subclasses.

If Flink's type analyzer is unable to extract a valid POJO type information with type information for all fields, an org.apache.flink.api.common.functions.InvalidTypesExceptionis thrown. Alternatively, you can use Types#POJO(Class,Map) to specify all fields manually.
[中]返回POJO(普通旧Java对象)的类型信息。
POJO类是公共的和独立的(没有非静态的内部类)。它有一个公共的无参数构造函数。类(和所有超类)中的所有非静态、非瞬态字段要么是公共的(和非最终的),要么有一个公共的getter和setter方法,该方法遵循JavaBeans对getter和setter的命名约定。
POJO是一种固定长度且支持空的复合类型。每个字段都可以为空,与字段的类型无关。
POJO的所有字段的泛型类型都可以在子类的层次结构中定义。
如果Flink的类型分析器无法从所有字段的类型信息中提取有效的POJO类型信息,则会生成一个组织。阿帕奇。弗林克。应用程序编程接口。常见的功能。InvalidTypesCeptionis被抛出。或者,可以使用类型#POJO(Class,Map)手动指定所有字段。

代码示例

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

private TypeInformation<?> convertPojo() {
  nextToken(TokenType.BEGIN);
  nextToken(TokenType.LITERAL);
  final String className = token().literal;
  nextToken(TokenType.END);
  final Class<?> clazz = EncodingUtils.loadClass(className);
  return Types.POJO(clazz);
}

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

@Test
public void testAvroToAvro() throws Exception {
  ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
  BatchTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env, config());
  Table t = tEnv.fromDataSet(testData(env));
  Table result = t.select("*");
  List<User> results = tEnv.toDataSet(result, Types.POJO(User.class)).collect();
  List<User> expected = Arrays.asList(USER_1, USER_2, USER_3);
  assertEquals(expected, results);
}

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

@Test
public void testAvroObjectAccess() throws Exception {
  ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
  BatchTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env, config());
  Table t = tEnv.fromDataSet(testData(env));
  Table result = t
      .filter("type_nested.isNotNull")
      .select("type_nested.flatten()").as("city, num, state, street, zip");
  List<Address> results = tEnv.toDataSet(result, Types.POJO(Address.class)).collect();
  String expected = USER_1.getTypeNested().toString();
  TestBaseUtils.compareResultAsText(results, expected);
}

代码示例来源:origin: org.apache.flink/flink-table-common

private TypeInformation<?> convertPojo() {
  nextToken(TokenType.BEGIN);
  nextToken(TokenType.LITERAL);
  final String className = token().literal;
  nextToken(TokenType.END);
  final Class<?> clazz = EncodingUtils.loadClass(className);
  return Types.POJO(clazz);
}

代码示例来源:origin: com.alibaba.blink/flink-table-common

private TypeInformation<?> convertPojo() {
  nextToken(TokenType.BEGIN);
  nextToken(TokenType.LITERAL);
  final String className = token().literal;
  nextToken(TokenType.END);
  final Class<?> clazz = EncodingUtils.loadClass(className);
  return Types.POJO(clazz);
}

相关文章