org.apache.nifi.serialization.record.DataType.getFormat()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(148)

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

DataType.getFormat介绍

暂无

代码示例

代码示例来源:origin: apache/nifi

@Override
public int hashCode() {
  return 31 + 41 * getFieldType().hashCode() + 41 * (getFormat() == null ? 0 : getFormat().hashCode());
}

代码示例来源:origin: apache/nifi

@Override
public boolean equals(final Object obj) {
  if (obj == this) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (!(obj instanceof DataType)) {
    return false;
  }
  final DataType other = (DataType) obj;
  return getFieldType().equals(other.getFieldType()) && Objects.equals(getFormat(), other.getFormat());
}

代码示例来源:origin: apache/nifi

@Override
  public String toString() {
    if (getFormat() == null) {
      return getFieldType().toString();
    } else {
      return getFieldType().toString() + ":" + getFormat();
    }
  }
}

代码示例来源:origin: apache/nifi

private String getFormat(final RecordField field) {
  final DataType dataType = field.getDataType();
  switch (dataType.getFieldType()) {
    case DATE:
      return dateFormat;
    case TIME:
      return timeFormat;
    case TIMESTAMP:
      return timestampFormat;
  }
  return dataType.getFormat();
}

代码示例来源:origin: apache/nifi

private static Long getLongFromTimestamp(final Object rawValue, final Schema fieldSchema, final String fieldName) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  Timestamp t = DataTypeUtils.toTimestamp(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  return t.getTime();
}

代码示例来源:origin: apache/nifi

@Override
public String getAsString(final String fieldName) {
  final Optional<DataType> dataTypeOption = schema.getDataType(fieldName);
  if (dataTypeOption.isPresent()) {
    return convertToString(getValue(fieldName), dataTypeOption.get().getFormat());
  }
  return DataTypeUtils.toString(getValue(fieldName), (Supplier<DateFormat>) null);
}

代码示例来源:origin: apache/nifi

final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  final Date date = DataTypeUtils.toDate(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  final Duration duration = Duration.between(new Date(0L).toInstant(), new Date(date.getTime()).toInstant());
  return (int) days;
} else if (LOGICAL_TYPE_TIME_MILLIS.equals(logicalType.getName())) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  final Time time = DataTypeUtils.toTime(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  final Date date = new Date(time.getTime());
  return duration.toMillis() * 1000L;
} else if (LOGICAL_TYPE_TIMESTAMP_MILLIS.equals(logicalType.getName())) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  Timestamp t = DataTypeUtils.toTimestamp(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  return getLongFromTimestamp(rawValue, fieldSchema, fieldName);

代码示例来源:origin: apache/nifi

break;
case DATE:
  Date d = record.getAsDate(fieldName, field.getDataType().getFormat());
  if(d != null) {
    org.apache.hadoop.hive.common.type.Date hiveDate = new org.apache.hadoop.hive.common.type.Date();
  Timestamp ts = DataTypeUtils.toTimestamp(record.getValue(fieldName), () -> DataTypeUtils.getDateFormat(field.getDataType().getFormat()), fieldName);
  if(ts != null) {

代码示例来源:origin: apache/nifi

return isCharacterTypeCompatible(value);
case DATE:
  return isDateTypeCompatible(value, dataType.getFormat());
case DOUBLE:
  return isDoubleTypeCompatible(value);
  return isShortTypeCompatible(value);
case TIME:
  return isTimeTypeCompatible(value, dataType.getFormat());
case TIMESTAMP:
  return isTimestampTypeCompatible(value, dataType.getFormat());
case STRING:
  return isStringTypeCompatible(value);

代码示例来源:origin: org.apache.nifi/nifi-record

@Override
public int hashCode() {
  return 31 + 41 * getFieldType().hashCode() + 41 * (getFormat() == null ? 0 : getFormat().hashCode());
}

代码示例来源:origin: org.apache.nifi/nifi-record

@Override
public boolean equals(final Object obj) {
  if (obj == this) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (!(obj instanceof DataType)) {
    return false;
  }
  final DataType other = (DataType) obj;
  return getFieldType().equals(other.getFieldType()) && Objects.equals(getFormat(), other.getFormat());
}

代码示例来源:origin: org.apache.nifi/nifi-record

@Override
  public String toString() {
    if (getFormat() == null) {
      return getFieldType().toString();
    } else {
      return getFieldType().toString() + ":" + getFormat();
    }
  }
}

代码示例来源:origin: org.apache.nifi/nifi-avro-record-utils

private static Long getLongFromTimestamp(final Object rawValue, final Schema fieldSchema, final String fieldName) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  Timestamp t = DataTypeUtils.toTimestamp(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  return t.getTime();
}

代码示例来源:origin: org.apache.nifi/nifi-record

@Override
public String getAsString(final String fieldName) {
  final Optional<DataType> dataTypeOption = schema.getDataType(fieldName);
  if (dataTypeOption.isPresent()) {
    return convertToString(getValue(fieldName), dataTypeOption.get().getFormat());
  }
  return DataTypeUtils.toString(getValue(fieldName), (Supplier<DateFormat>) null);
}

代码示例来源:origin: org.apache.nifi/nifi-avro-record-utils

final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  final Date date = DataTypeUtils.toDate(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  final Duration duration = Duration.between(new Date(0L).toInstant(), new Date(date.getTime()).toInstant());
  return (int) days;
} else if (LOGICAL_TYPE_TIME_MILLIS.equals(logicalType.getName())) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  final Time time = DataTypeUtils.toTime(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  final Date date = new Date(time.getTime());
  return duration.toMillis() * 1000L;
} else if (LOGICAL_TYPE_TIMESTAMP_MILLIS.equals(logicalType.getName())) {
  final String format = AvroTypeUtil.determineDataType(fieldSchema).getFormat();
  Timestamp t = DataTypeUtils.toTimestamp(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName);
  return getLongFromTimestamp(rawValue, fieldSchema, fieldName);

代码示例来源:origin: org.apache.nifi/nifi-record

return isCharacterTypeCompatible(value);
case DATE:
  return isDateTypeCompatible(value, dataType.getFormat());
case DOUBLE:
  return isDoubleTypeCompatible(value);
  return isShortTypeCompatible(value);
case TIME:
  return isTimeTypeCompatible(value, dataType.getFormat());
case TIMESTAMP:
  return isTimestampTypeCompatible(value, dataType.getFormat());
case STRING:
  return isStringTypeCompatible(value);

相关文章