当前位置: 首页>>代码示例>>Java>>正文


Java SchemaBuilder.record方法代码示例

本文整理汇总了Java中org.apache.avro.SchemaBuilder.record方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaBuilder.record方法的具体用法?Java SchemaBuilder.record怎么用?Java SchemaBuilder.record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.avro.SchemaBuilder的用法示例。


在下文中一共展示了SchemaBuilder.record方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: schemaFor

import org.apache.avro.SchemaBuilder; //导入方法依赖的package包/类
private static Schema schemaFor(StructType structType, String record, String namespace, int recordCount) {

    // Increment after using the recordCount
    record = (null == record) ? "record" + recordCount++ : record;

    LOG.debug("Converting {} to Avro Record schema [{}:{}]", structType, record, namespace);
    SchemaBuilder.RecordBuilder<Schema> schema = SchemaBuilder.record(record);

    if (null != namespace) {
      schema.namespace(namespace);
    }

    schema.doc("Auto-generated from Spark DataFrame");

    SchemaBuilder.FieldAssembler<Schema> assembler = schema.fields();
    StructField[] structFields = structType.fields();

    for (StructField f : structFields) {
      assembler.name(f.name()).type(typeFor(f.dataType(), f.nullable(), recordCount)).noDefault();
    }

    return assembler.endRecord();
  }
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:24,代码来源:AvroUtils.java

示例2: createSchemaFor

import org.apache.avro.SchemaBuilder; //导入方法依赖的package包/类
/**
 * Generate a schema with given schema name and has one field of STRING type
 * for each dimension and one field of LONG type for each metric
 * @param schemaName
 * @param dimensions
 * @param metrics
 * @return
 */
public static Schema createSchemaFor(String schemaName, String[] dimensions,
    String[] metrics) {
  FieldAssembler<Schema> fields;
  RecordBuilder<Schema> record = SchemaBuilder.record(schemaName);
  fields = record.namespace("com.linkedin.thirdeye.join").fields();
  for (String dimension : dimensions) {
    fields = fields.name(dimension).type().nullable().stringType()
        .noDefault();
  }
  for (String metric : metrics) {
    fields = fields.name(metric).type().nullable().longType().longDefault(0);
  }
  Schema schema = fields.endRecord();
  return schema;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:24,代码来源:AvroTestUtil.java

示例3: record

import org.apache.avro.SchemaBuilder; //导入方法依赖的package包/类
@Override
public RecordContext record(String name) {
	RecordBuilder<?> recordBuilder = SchemaBuilder.record(name);
	return new RecordContextImpl(recordBuilder);
}
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:6,代码来源:RootContextImpl.java

示例4: getSchemaForTriplesMap

import org.apache.avro.SchemaBuilder; //导入方法依赖的package包/类
protected Schema getSchemaForTriplesMap(TriplesMapGraph graph, String triplesMapId)
{
	TriplesMap map = graph.getTriplesMap(triplesMapId);
	RecordBuilder<Schema> rb = SchemaBuilder.record("subjr"+(id++));
	
	Set<String> currentPredicates = new HashSet<String>(); 
	FieldAssembler<Schema> fieldAssembler = rb.fields();
	for(PredicateObjectMap pom : map.getPredicateObjectMaps())
	{
	
	
			boolean isMap = false;
			Schema targetSchema = null;
			String predicateShortHand = null;
			if(pom.getPredicate().getTemplate().getAllColumnNameTermElements().isEmpty())
			{
				String predicate = pom.getPredicate().getTemplate().getR2rmlTemplateString(rep);
				predicateShortHand = shortHandURIGenerator.getShortHand(predicate).toString().replaceAll("[^\\w]", "_");
			}
			else
			{
				isMap = true;
			}
			
			if(pom.getObject() != null && pom.getObject().hasRefObjectMap())
			{
				RefObjectMap refObjectMap = pom.getObject().getRefObjectMap();
				
				if(!refObjectMap.getParentTriplesMap().getId().equalsIgnoreCase(triplesMapId))
				{
						targetSchema = triplesMapIdToSchema.get(refObjectMap.getParentTriplesMap().getId());
				
				}
				
			}
			
			if(currentPredicates.add(predicateShortHand))
			{
				fieldAssembler = addField(fieldAssembler, pom, isMap,
					targetSchema, predicateShortHand);
			}
			else
			{
				//TODO handle conflicting types
				LOG.warn("Duplicate predicate detected in schema");
			}
	}
	
	fieldAssembler = fieldAssembler.name("id").type().unionOf().array().items().stringType().and().stringType().and().nullType().endUnion().noDefault();
	fieldAssembler = fieldAssembler.name("rdf_type").type().unionOf().array().items().stringType().and().stringType().and().nullType().endUnion().noDefault();

	
	return fieldAssembler.endRecord();
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:55,代码来源:AvroKR2RMLRDFWriter.java


注:本文中的org.apache.avro.SchemaBuilder.record方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。