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


Java LogicalTypes.timestampMillis方法代码示例

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


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

示例1: convertOriginalType

import org.apache.avro.LogicalTypes; //导入方法依赖的package包/类
private LogicalType convertOriginalType(OriginalType annotation, DecimalMetadata meta) {
  if (annotation == null) {
    return null;
  }
  switch (annotation) {
    case DECIMAL:
      return LogicalTypes.decimal(meta.getPrecision(), meta.getScale());
    case DATE:
      return LogicalTypes.date();
    case TIME_MILLIS:
      return LogicalTypes.timeMillis();
    case TIME_MICROS:
      return LogicalTypes.timeMicros();
    case TIMESTAMP_MILLIS:
      return LogicalTypes.timestampMillis();
    case TIMESTAMP_MICROS:
      return LogicalTypes.timestampMicros();
  }
  return null;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:21,代码来源:AvroSchemaConverter.java

示例2: write

import org.apache.avro.LogicalTypes; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void write(Object datum) throws IOException {
    if (null == datum) {
        return;
    }
    if (null == factory) {
        factory = (IndexedRecordConverter<Object, ? extends IndexedRecord>) SnowflakeAvroRegistry.get()
                .createIndexedRecordConverter(datum.getClass());
    }
    IndexedRecord input = factory.convertToAvro(datum);
    List<Schema.Field> remoteTableFields = mainSchema.getFields();

    /*
     * This piece will be executed only once per instance. Will not cause performance issue. Perform input and mainSchema
     * synchronization. Such situation is useful in case of Dynamic fields.
     */
    if (isFirst) {
        collectedFields = DynamicSchemaUtils.getCommonFieldsForDynamicSchema(mainSchema, input.getSchema());
        isFirst = false;
    }

    for (int i = 0; i < row.length; i++) {
        Field f = collectedFields.get(i);
        Field remoteTableField = remoteTableFields.get(i);
        if (f == null) {
            row[i] = remoteTableField.defaultVal();
            continue;
        }
        Object inputValue = input.get(f.pos());
        Schema s = AvroUtils.unwrapIfNullable(remoteTableField.schema());
        if (null == inputValue || inputValue instanceof String) {
            row[i] = inputValue;
        } else if (AvroUtils.isSameType(s, AvroUtils._date())) {
            Date date = (Date) inputValue;
            row[i] = date.getTime();
        } else if (LogicalTypes.fromSchemaIgnoreInvalid(s) == LogicalTypes.timeMillis()) {
            row[i] = formatter.formatTimeMillis(inputValue);
        } else if (LogicalTypes.fromSchemaIgnoreInvalid(s) == LogicalTypes.date()) {
            row[i] = formatter.formatDate(inputValue);
        } else if (LogicalTypes.fromSchemaIgnoreInvalid(s) == LogicalTypes.timestampMillis()) {
            row[i] = formatter.formatTimestampMillis(inputValue);
        } else {
            row[i] = inputValue;
        }
    }

    loader.submitRow(row);
}
 
开发者ID:Talend,项目名称:components,代码行数:50,代码来源:SnowflakeWriter.java


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