org.apache.gobblin.util.AvroUtils.getFieldSchemaHelper()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(73)

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

AvroUtils.getFieldSchemaHelper介绍

[英]Helper method that does the actual work for #getFieldSchema(Schema,String)
[中]为#getFieldSchema(Schema,String)执行实际工作的Helper方法

代码示例

代码示例来源:origin: apache/incubator-gobblin

/**
 * Given a GenericRecord, this method will return the schema of the field specified by the path parameter. The
 * fieldLocation parameter is an ordered string specifying the location of the nested field to retrieve. For example,
 * field1.nestedField1 takes the the schema of the field "field1", and retrieves the schema "nestedField1" from it.
 * @param schema is the record to retrieve the schema from
 * @param fieldLocation is the location of the field
 * @return the schema of the field
 */
public static Optional<Schema> getFieldSchema(Schema schema, String fieldLocation) {
 Preconditions.checkNotNull(schema);
 Preconditions.checkArgument(!Strings.isNullOrEmpty(fieldLocation));
 Splitter splitter = Splitter.on(FIELD_LOCATION_DELIMITER).omitEmptyStrings().trimResults();
 List<String> pathList = Lists.newArrayList(splitter.split(fieldLocation));
 if (pathList.size() == 0) {
  return Optional.absent();
 }
 return AvroUtils.getFieldSchemaHelper(schema, pathList, 0);
}

代码示例来源:origin: apache/incubator-gobblin

case UNION:
 if (AvroSerdeUtils.isNullableType(schema)) {
  return AvroUtils.getFieldSchemaHelper(AvroSerdeUtils.getOtherTypeFromNullableType(schema), pathList, field);
  return Optional.fromNullable(schema.getValueType());
 return AvroUtils.getFieldSchemaHelper(schema.getValueType(), pathList, ++field);
case RECORD:
 if ((field + 1) == pathList.size()) {
  return Optional.fromNullable(schema.getField(pathList.get(field)).schema());
 return AvroUtils.getFieldSchemaHelper(schema.getField(pathList.get(field)).schema(), pathList, ++field);
default:
 throw new AvroRuntimeException("Invalid type in schema : " + schema);

代码示例来源:origin: org.apache.gobblin/gobblin-utility

/**
 * Given a GenericRecord, this method will return the schema of the field specified by the path parameter. The
 * fieldLocation parameter is an ordered string specifying the location of the nested field to retrieve. For example,
 * field1.nestedField1 takes the the schema of the field "field1", and retrieves the schema "nestedField1" from it.
 * @param schema is the record to retrieve the schema from
 * @param fieldLocation is the location of the field
 * @return the schema of the field
 */
public static Optional<Schema> getFieldSchema(Schema schema, String fieldLocation) {
 Preconditions.checkNotNull(schema);
 Preconditions.checkArgument(!Strings.isNullOrEmpty(fieldLocation));
 Splitter splitter = Splitter.on(FIELD_LOCATION_DELIMITER).omitEmptyStrings().trimResults();
 List<String> pathList = Lists.newArrayList(splitter.split(fieldLocation));
 if (pathList.size() == 0) {
  return Optional.absent();
 }
 return AvroUtils.getFieldSchemaHelper(schema, pathList, 0);
}

代码示例来源:origin: org.apache.gobblin/gobblin-utility

case UNION:
 if (AvroSerdeUtils.isNullableType(schema)) {
  return AvroUtils.getFieldSchemaHelper(AvroSerdeUtils.getOtherTypeFromNullableType(schema), pathList, field);
  return Optional.fromNullable(schema.getValueType());
 return AvroUtils.getFieldSchemaHelper(schema.getValueType(), pathList, ++field);
case RECORD:
 if ((field + 1) == pathList.size()) {
  return Optional.fromNullable(schema.getField(pathList.get(field)).schema());
 return AvroUtils.getFieldSchemaHelper(schema.getField(pathList.get(field)).schema(), pathList, ++field);
default:
 throw new AvroRuntimeException("Invalid type in schema : " + schema);

相关文章