本文整理了Java中org.apache.flink.api.common.typeinfo.Types.ROW_NAMED()
方法的一些代码示例,展示了Types.ROW_NAMED()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.ROW_NAMED()
方法的具体详情如下:
包路径:org.apache.flink.api.common.typeinfo.Types
类名称:Types
方法名:ROW_NAMED
[英]Returns type information for org.apache.flink.types.Row with fields of the given types and with given names. A row must not be null.
A row is a fixed-length, null-aware composite type for storing multiple values in a deterministic field order. Every field can be null independent of the field's type. The type of row fields cannot be automatically inferred; therefore, it is required to provide type information whenever a row is used.
The schema of rows can have up to Integer.MAX_VALUE
fields, however, all row instances must strictly adhere to the schema defined by the type info.
Example use: ROW_NAMED(new String[]{"name", "number"}, Types.STRING, Types.INT)}.
[中]返回组织的类型信息。阿帕奇。弗林克。类型。具有给定类型和给定名称的字段的行。行不能为空。
行是一种固定长度、支持空的复合类型,用于以确定性字段顺序存储多个值。每个字段都可以为空,与字段的类型无关。无法自动推断行字段的类型;因此,无论何时使用行,都需要提供类型信息。
行的模式最多可以有Integer.MAX_VALUE
个字段,但是,所有行实例必须严格遵守类型信息定义的模式。
示例用法:ROW_NAMED(新字符串[]{“name”,“number”},Types.String,Types.INT)}。
代码示例来源:origin: apache/flink
/**
* Converts a table schema into a (nested) type information describing a {@link Row}.
*/
public TypeInformation<Row> toRowType() {
return Types.ROW_NAMED(fieldNames, fieldTypes);
}
代码示例来源:origin: apache/flink
@Override
public TypeInformation<Row> getOutputType() {
return Types.ROW_NAMED(fieldNames, fieldTypes);
}
代码示例来源:origin: apache/flink
@Override
public TypeInformation<Row> getRecordType() {
return Types.ROW_NAMED(fieldNames, fieldTypes);
}
代码示例来源:origin: apache/flink
names[i] = field.name();
return Types.ROW_NAMED(names, types);
case ENUM:
return Types.STRING;
代码示例来源:origin: apache/flink
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
// validate properties
if (!node.has(PROPERTIES)) {
return Types.ROW();
}
if (!node.isObject()) {
throw new IllegalArgumentException(
"Invalid '" + PROPERTIES + "' property for object type in node: " + location);
}
final JsonNode props = node.get(PROPERTIES);
final String[] names = new String[props.size()];
final TypeInformation<?>[] types = new TypeInformation[props.size()];
final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
int i = 0;
while (fieldIter.hasNext()) {
final Map.Entry<String, JsonNode> subNode = fieldIter.next();
// set field name
names[i] = subNode.getKey();
// set type
types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
i++;
}
// validate that object does not contain additional properties
if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
throw new IllegalArgumentException(
"An object must not allow additional properties in node: " + location);
}
return Types.ROW_NAMED(names, types);
}
代码示例来源:origin: apache/flink
return Types.ROW_NAMED(
names.toArray(new String[0]),
types.toArray(new TypeInformation<?>[0]));
代码示例来源:origin: apache/flink
Types.ROW_NAMED(
new String[]{"hello", "world"},
Types.BIG_DEC, Types.BYTE));
Types.ROW_NAMED(
new String[] {"he \nllo", "world"},
Types.BIG_DEC, Types.BYTE),
Types.ROW_NAMED(
new String[] {"he`llo", "world"},
Types.BIG_DEC, Types.BYTE),
Types.ROW_NAMED(
new String[] {"he \nllo", "world"},
Types.BIG_DEC, Types.BYTE),
Types.ROW_NAMED(
new String[] {"singleton", "twoField"},
Types.ROW(Types.INT),
Types.ROW_NAMED(
new String[] {"Field 1", "Field`s 2"},
Types.ROW(Types.BIG_DEC), Types.STRING)));
代码示例来源:origin: apache/flink
private void validateUserSchema(TypeInformation<?> actual) {
final TypeInformation<Row> address = Types.ROW_NAMED(
new String[]{
"num",
Types.STRING);
final TypeInformation<Row> user = Types.ROW_NAMED(
new String[] {
"name",
代码示例来源:origin: apache/flink
/**
* Creates a result. Might start threads or opens sockets so every created result must be closed.
*/
public <T> DynamicResult<T> createResult(Environment env, TableSchema schema, ExecutionConfig config) {
final TypeInformation<Row> outputType = Types.ROW_NAMED(schema.getFieldNames(), schema.getFieldTypes());
if (env.getExecution().isStreamingExecution()) {
// determine gateway address (and port if possible)
final InetAddress gatewayAddress = getGatewayAddress(env.getDeployment());
final int gatewayPort = getGatewayPort(env.getDeployment());
if (env.getExecution().isChangelogMode()) {
return new ChangelogCollectStreamResult<>(outputType, config, gatewayAddress, gatewayPort);
} else {
return new MaterializedCollectStreamResult<>(
outputType,
config,
gatewayAddress,
gatewayPort,
env.getExecution().getMaxTableResultRows());
}
} else {
// Batch Execution
if (!env.getExecution().isTableMode()) {
throw new SqlExecutionException("Results of batch queries can only be served in table mode.");
}
return new MaterializedCollectBatchResult<>(outputType, config);
}
}
代码示例来源:origin: org.apache.flink/flink-table-common
/**
* Converts a table schema into a (nested) type information describing a {@link Row}.
*/
public TypeInformation<Row> toRowType() {
return Types.ROW_NAMED(fieldNames, fieldTypes);
}
代码示例来源:origin: org.apache.flink/flink-avro
names[i] = field.name();
return Types.ROW_NAMED(names, types);
case ENUM:
return Types.STRING;
代码示例来源:origin: com.alibaba.blink/flink-avro
names[i] = field.name();
return Types.ROW_NAMED(names, types);
case ENUM:
return Types.STRING;
代码示例来源:origin: com.alibaba.blink/flink-json
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
// validate properties
if (!node.has(PROPERTIES)) {
return Types.ROW();
}
if (!node.isObject()) {
throw new IllegalArgumentException(
"Invalid '" + PROPERTIES + "' property for object type in node: " + location);
}
final JsonNode props = node.get(PROPERTIES);
final String[] names = new String[props.size()];
final TypeInformation<?>[] types = new TypeInformation[props.size()];
final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
int i = 0;
while (fieldIter.hasNext()) {
final Map.Entry<String, JsonNode> subNode = fieldIter.next();
// set field name
names[i] = subNode.getKey();
// set type
types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
i++;
}
// validate that object does not contain additional properties
if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
throw new IllegalArgumentException(
"An object must not allow additional properties in node: " + location);
}
return Types.ROW_NAMED(names, types);
}
代码示例来源:origin: org.apache.flink/flink-json
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
// validate properties
if (!node.has(PROPERTIES)) {
return Types.ROW();
}
if (!node.isObject()) {
throw new IllegalArgumentException(
"Invalid '" + PROPERTIES + "' property for object type in node: " + location);
}
final JsonNode props = node.get(PROPERTIES);
final String[] names = new String[props.size()];
final TypeInformation<?>[] types = new TypeInformation[props.size()];
final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
int i = 0;
while (fieldIter.hasNext()) {
final Map.Entry<String, JsonNode> subNode = fieldIter.next();
// set field name
names[i] = subNode.getKey();
// set type
types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
i++;
}
// validate that object does not contain additional properties
if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
throw new IllegalArgumentException(
"An object must not allow additional properties in node: " + location);
}
return Types.ROW_NAMED(names, types);
}
代码示例来源:origin: com.alibaba.blink/flink-table-common
return Types.ROW_NAMED(
names.toArray(new String[0]),
types.toArray(new TypeInformation<?>[0]));
代码示例来源:origin: org.apache.flink/flink-table-common
return Types.ROW_NAMED(
names.toArray(new String[0]),
types.toArray(new TypeInformation<?>[0]));
内容来源于网络,如有侵权,请联系作者删除!