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


Java Field.name方法代码示例

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


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

示例1: before

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@BeforeClass
public static void before() throws Exception {
  final String filePath = TestUtils.getFileFromResourceUrl(BlocksTest.class.getClassLoader().getResource(AVRO_DATA));
  if (INDEX_DIR.exists()) {
    FileUtils.deleteQuietly(INDEX_DIR);
  }

  System.out.println(INDEX_DIR.getAbsolutePath());
  final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);

  final SegmentGeneratorConfig config =
      SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(new File(filePath), INDEX_DIR, "daysSinceEpoch",
          TimeUnit.DAYS, "test");
  config.setTimeColumnName("daysSinceEpoch");
  driver.init(config);
  driver.build();

  final DataFileStream<GenericRecord> avroReader = AvroUtils.getAvroReader(new File(filePath));
  final org.apache.avro.Schema avroSchema = avroReader.getSchema();
  final String[] columns = new String[avroSchema.getFields().size()];
  int i = 0;
  for (final Field f : avroSchema.getFields()) {
    columns[i] = f.name();
    i++;
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:27,代码来源:BlocksTest.java

示例2: initializeFieldNameMap

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
private void initializeFieldNameMap(Schema schema) {
  Class<?> recordClass = data.getClass(schema);
  if (recordClass == null) {
    LOG.warn("Unable to load class " + SpecificData.getClassName(schema) + "; skipping java annotation processing");
    fieldNameMap = Collections.emptyMap();
  } else {
    List<Field> fields = schema.getFields();
    fieldNameMap = new HashMap<>(fields.size());
    for (Field field : fields) {
      String schemaFieldName = field.name();
      String dbFieldName = RecordConverter.getFieldName(field);
      if (!schemaFieldName.equals(dbFieldName)) {
        fieldNameMap.put(schemaFieldName, dbFieldName);
      }
    }
  }
}
 
开发者ID:tfeng,项目名称:toolbox,代码行数:18,代码来源:DocumentDecoder.java

示例3: setSchema

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@Override
public void setSchema(Schema schema) {
    this.schema = schema;
    Boolean useNameMappings = (nameMappings != null);
    String[] names;
    names = new String[getSchema().getFields().size()];
    fieldConverter = new AvroConverter[names.length];
    for (int j = 0; j < names.length; j++) {
        Field f = getSchema().getFields().get(j);
        String mappedName = f.name();
        if (useNameMappings && nameMappings.containsKey(f.name())) {
            mappedName = nameMappings.get(f.name());
            // LOGGER.warn("AdaptorFactory: {} <---> {}.", f.name(), mappedName);
        }
        names[j] = f.name();
        DTEConverter converter = AzureStorageAvroRegistry.get().getConverter(f, mappedName);
        fieldConverter[j] = converter;
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:20,代码来源:AzureStorageTableAdaptorFactory.java

示例4: getMarketoColumns

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
public List<String> getMarketoColumns(Schema schema) {
    List<String> result = new ArrayList<>();
    Map<String, String> mappings = getInputedNameMappingsForMarketo();
    String marketoCol = null;
    String schemaCol = null;
    for (Field f : schema.getFields()) {
        marketoCol = mappings.get(f.name());
        if (StringUtils.isEmpty(marketoCol)) {
            schemaCol = f.getProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME);
            if (!StringUtils.isEmpty(schemaCol)) {
                marketoCol = schemaCol;
            } else {
                marketoCol = f.name();
            }
        }
        result.add(marketoCol);
    }
    return result;
}
 
开发者ID:Talend,项目名称:components,代码行数:20,代码来源:MarketoColumnMappingsTable.java

示例5: generateAppropriateValue

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
public static String generateAppropriateValue(Field field) {
  switch (field.schema().getType()) {
    case RECORD:
      return field.schema().getName()+".newBuilder().build()";
    case MAP:
      return "new org.apache.gora.persistency.impl.DirtyMapWrapper(new java.util.HashMap())";
    case ARRAY:
      return "new org.apache.gora.persistency.impl.DirtyListWrapper(new java.util.ArrayList())";
    default:
      return "this."+field.name();
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:13,代码来源:GoraCompiler.java

示例6: getRecordSchemaWithDirtySupport

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
private static Schema getRecordSchemaWithDirtySupport(Schema originalSchema, Map<Schema,Schema> queue) throws IOException {
  if (originalSchema.getType() != Type.RECORD) {
    throw new IOException("Gora only supports record schemas.");
  }
  List<Field> originalFields = originalSchema.getFields();
  /* make sure the schema doesn't contain the field __g__dirty */
  for (Field field : originalFields) {
    if (GORA_RESERVED_NAMES.contains(field.name())) {
      throw new IOException(
        "Gora schemas cannot contain the field name " + field.name());
    }
  }
  Schema newSchema = Schema.createRecord(originalSchema.getName(),
  originalSchema.getDoc(), originalSchema.getNamespace(),
  originalSchema.isError());
  
  queue.put(originalSchema, newSchema);
  
  List<Field> newFields = new ArrayList<>();
  byte[] defaultDirtyBytesValue = new byte[getNumberOfBytesNeededForDirtyBits(originalSchema)];
  Arrays.fill(defaultDirtyBytesValue, (byte) 0);
  JsonNode defaultDirtyJsonValue = JsonNodeFactory.instance
    .binaryNode(defaultDirtyBytesValue);
  Field dirtyBits = new Field(DIRTY_BYTES_FIELD_NAME,
    Schema.create(Type.BYTES),
    "Bytes used to represent weather or not a field is dirty.",
    defaultDirtyJsonValue);
  newFields.add(dirtyBits);
  for (Field originalField : originalFields) {
    // recursively add dirty support
    Field newField = new Field(originalField.name(),
      getSchemaWithDirtySupport(originalField.schema(),queue),
      originalField.doc(), originalField.defaultValue(),
      originalField.order());
    newFields.add(newField);
  }
  newSchema.setFields(newFields);
  return newSchema;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:40,代码来源:GoraCompiler.java

示例7: fromMongoRecord

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object fromMongoRecord(final Schema fieldSchema, final String docf,
    final DBObject rec) {
  Object result;
  BSONDecorator innerBson = new BSONDecorator(rec);
  Class<?> clazz = null;
  try {
    clazz = ClassLoadingUtils.loadClass(fieldSchema.getFullName());
  } catch (ClassNotFoundException e) {
  }
  Persistent record = new BeanFactoryImpl(keyClass, clazz).newPersistent();
  for (Field recField : fieldSchema.getFields()) {
    Schema innerSchema = recField.schema();
    DocumentFieldType innerStoreType = mapping
        .getDocumentFieldType(innerSchema.getName());
    String innerDocField = mapping.getDocumentField(recField.name()) != null ? mapping
        .getDocumentField(recField.name()) : recField.name();
    String fieldPath = docf + "." + innerDocField;
    LOG.debug(
        "Load from DBObject (RECORD), field:{}, schemaType:{}, docField:{}, storeType:{}",
        new Object[] { recField.name(), innerSchema.getType(), fieldPath,
            innerStoreType });
    record.put(
        recField.pos(),
        fromDBObject(innerSchema, innerStoreType, recField, innerDocField,
            innerBson));
  }
  result = record;
  return result;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:31,代码来源:MongoStore.java

示例8: getPinotSchemaFromAvroSchema

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
/**
 * Given an avro schema object along with column field types and time unit, return the equivalent
 * pinot schema object.
 *
 * @param avroSchema Avro schema for which to get the Pinot schema.
 * @param fieldTypes Map containing fieldTypes for each column.
 * @param timeUnit Time unit to be used for the time column.
 * @return Return the equivalent pinot schema for the given avro schema.
 */
private static Schema getPinotSchemaFromAvroSchema(org.apache.avro.Schema avroSchema,
                                                   Map<String, FieldSpec.FieldType> fieldTypes,
                                                   TimeUnit timeUnit) {
  Schema pinotSchema = new Schema();

  for (final Field field : avroSchema.getFields()) {
    FieldSpec spec;
    FieldSpec.DataType columnType;

    try {
      columnType = AvroRecordReader.getColumnType(field);
    } catch (UnsupportedOperationException e) {
      LOGGER.warn("Unsupported field type for field {}, using String instead.", field.name());
      columnType = FieldSpec.DataType.STRING;
    }

    FieldSpec.FieldType fieldType = fieldTypes.get(field.name());
    if (fieldType == FieldSpec.FieldType.METRIC) {
      spec = new MetricFieldSpec();
      spec.setDataType(columnType);
    } else if (fieldType == FieldSpec.FieldType.TIME) {
      spec = new TimeFieldSpec(field.name(), columnType, timeUnit);
    } else {
      spec = new DimensionFieldSpec();
      spec.setDataType(columnType);
    }

    spec.setName(field.name());
    spec.setSingleValueField(AvroRecordReader.isSingleValueField(field));

    pinotSchema.addSchema(spec.getName(), spec);
  }
  return pinotSchema;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:44,代码来源:AvroUtils.java

示例9: before

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@BeforeClass
public static void before() throws Exception {
  final String filePath =
      TestUtils.getFileFromResourceUrl(DictionariesTest.class.getClassLoader().getResource(AVRO_DATA));
  if (INDEX_DIR.exists()) {
    FileUtils.deleteQuietly(INDEX_DIR);
  }

  System.out.println(INDEX_DIR.getAbsolutePath());
  final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);

  final SegmentGeneratorConfig config =
      SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(new File(filePath), INDEX_DIR, "weeksSinceEpochSunday",
          TimeUnit.DAYS, "test");
  config.setTimeColumnName("weeksSinceEpochSunday");
  driver.init(config);
  driver.build();

  final DataFileStream<GenericRecord> avroReader = AvroUtils.getAvroReader(new File(filePath));
  final org.apache.avro.Schema avroSchema = avroReader.getSchema();
  final String[] columns = new String[avroSchema.getFields().size()];
  int i = 0;
  for (final Field f : avroSchema.getFields()) {
    columns[i] = f.name();
    i++;
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:28,代码来源:IntArraysTest.java

示例10: extractSchemaFromAvroWithoutTime

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
public static Schema extractSchemaFromAvroWithoutTime(File avroFile) throws FileNotFoundException, IOException {
  DataFileStream<GenericRecord> dataStream =
      new DataFileStream<GenericRecord>(new FileInputStream(avroFile), new GenericDatumReader<GenericRecord>());
  Schema schema = new Schema();

  for (final Field field : dataStream.getSchema().getFields()) {
    final String columnName = field.name();
    final String pinotType = field.getProp("pinotType");

    final FieldSpec fieldSpec;
    if (pinotType != null && "METRIC".equals(pinotType)) {
      fieldSpec = new MetricFieldSpec();
      fieldSpec.setFieldType(FieldType.METRIC);
    } else {
      fieldSpec = new DimensionFieldSpec();
      fieldSpec.setFieldType(FieldType.DIMENSION); // default
    }

    fieldSpec.setName(columnName);
    fieldSpec.setDataType(getColumnType(dataStream.getSchema().getField(columnName)));
    fieldSpec.setSingleValueField(isSingleValueField(dataStream.getSchema().getField(columnName)));
    fieldSpec.setDelimiter(",");
    schema.addSchema(columnName, fieldSpec);
  }

  dataStream.close();
  return schema;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:29,代码来源:SegmentTestUtils.java

示例11: getFieldName

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
protected static String getFieldName(Field field) {
  String mongoName = field.getProp(MONGO_NAME_PROPERTY);
  if (mongoName != null) {
    return mongoName;
  } else {
    return field.name();
  }
}
 
开发者ID:tfeng,项目名称:toolbox,代码行数:9,代码来源:RecordConverter.java

示例12: setSchema

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@Override
public void setSchema(Schema schema) {
    this.schema = schema;
    names = new String[getSchema().getFields().size()];
    fieldConverter = new AvroConverter[names.length];
    for (int j = 0; j < names.length; j++) {
        Field f = getSchema().getFields().get(j);
        names[j] = f.name();
        JDBCAvroRegistry.JDBCConverter jdbcConverter = getRegistry().getConverter(f);
        if (influencer != null) {
            jdbcConverter.setInfluencer(influencer);
        }
        fieldConverter[j] = jdbcConverter;
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:16,代码来源:JDBCResultSetIndexedRecordConverter.java

示例13: init

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
private void init() {
    if (names == null) {
        List<Schema.Field> fields = getSchema().getFields();
        names = new String[fields.size()];
        fieldConverter = new AvroConverter[names.length];
        name2converter = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (int j = 0; j < names.length; j++) {
            Field f = getSchema().getFields().get(j);
            names[j] = f.name();
            fieldConverter[j] = SalesforceAvroRegistry.get().getConverterFromString(f);
            name2converter.put(f.name(), fieldConverter[j]);
            name2converter.put(rootType + schema.getProp(SalesforceSchemaConstants.COLUMNNAME_DELIMTER) + f.name(), fieldConverter[j]);
        }
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:16,代码来源:SObjectAdapterFactory.java

示例14: get

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object get(int i) {
    // Lazy initialization of the cached converter objects.
    if (names == null) {
        names = new String[getSchema().getFields().size()];
        fieldConverter = new AvroConverter[names.length];
        for (int j = 0; j < names.length; j++) {
            Field f = getSchema().getFields().get(j);
            names[j] = f.name();
            fieldConverter[j] = SalesforceAvroRegistryString.get().getConverterFromString(f);
        }
    }
    return fieldConverter[i].convertToAvro(value.getValue(names[i]));
}
 
开发者ID:Talend,项目名称:components,代码行数:16,代码来源:BulkResultIndexedRecordConverter.java

示例15: get

import org.apache.avro.Schema.Field; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object get(int i) {
    // Lazy initialization of the cached converter objects.
    if (names == null) {
        names = new String[getSchema().getFields().size()];
        fieldConverter = new AvroConverter[names.length];
        for (int j = 0; j < names.length; j++) {
            Field f = getSchema().getFields().get(j);
            names[j] = f.name();
            fieldConverter[j] = SalesforceAvroRegistry.get().getConverterFromString(f);
        }
    }
    return fieldConverter[i].convertToAvro(value.getValue(names[i]));
}
 
开发者ID:Talend,项目名称:components,代码行数:16,代码来源:BulkResultAdapterFactory.java


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