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


Java SchemaBuilder.doc方法代码示例

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


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

示例1: copySchemaBasics

import org.apache.kafka.connect.data.SchemaBuilder; //导入方法依赖的package包/类
public static SchemaBuilder copySchemaBasics(Schema source, SchemaBuilder builder) {
    builder.name(source.name());
    builder.version(source.version());
    builder.doc(source.doc());

    final Map<String, String> params = source.parameters();
    if (params != null) {
        builder.parameters(params);
    }

    return builder;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:13,代码来源:SchemaUtil.java

示例2: generateSchema

import org.apache.kafka.connect.data.SchemaBuilder; //导入方法依赖的package包/类
Schema generateSchema(ResultSet resultSet, final String columnName) throws SQLException {
  SchemaBuilder builder = null;

  String dataType = resultSet.getString(2);
  int scale = resultSet.getInt(3);
  boolean nullable = "Y".equalsIgnoreCase(resultSet.getString(4));
  String comments = resultSet.getString(5);

  if (TYPE_LOOKUP.containsKey(dataType)) {
    Schema.Type type = TYPE_LOOKUP.get(dataType);
    builder = SchemaBuilder.type(type);
  } else if ("NUMBER".equals(dataType)) {
    builder = Decimal.builder(scale);
  } else if (matches(TIMESTAMP_PATTERN, dataType)) {
    builder = Timestamp.builder();
  } else if (matches(TIMESTAMP_WITH_LOCAL_TIMEZONE, dataType)) {
    builder = Timestamp.builder();
  } else if (matches(TIMESTAMP_WITH_TIMEZONE, dataType)) {
    builder = Timestamp.builder();
  } else if ("DATE".equals(dataType)) {
    builder = Timestamp.builder();
  } else {
    String message = String.format("Could not determine schema type for column %s. dataType = %s", columnName, dataType);
    throw new DataException(message);
  }


  if (nullable) {
    builder.optional();
  }

  if (!Strings.isNullOrEmpty(comments)) {
    builder.doc(comments);
  }

  builder.parameters(
      ImmutableMap.of(Change.ColumnValue.COLUMN_NAME, columnName)
  );

  return builder.build();
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-cdc-oracle,代码行数:42,代码来源:Oracle12cTableMetadataProvider.java

示例3: build

import org.apache.kafka.connect.data.SchemaBuilder; //导入方法依赖的package包/类
public Schema build() {
  log.trace(this.toString());
  SchemaBuilder builder;

  switch (this.type) {
    case MAP:
      Preconditions.checkNotNull(this.keySchema, "keySchema cannot be null.");
      Preconditions.checkNotNull(this.valueSchema, "valueSchema cannot be null.");
      builder = SchemaBuilder.map(this.keySchema, this.valueSchema);
      break;
    case ARRAY:
      Preconditions.checkNotNull(this.valueSchema, "valueSchema cannot be null.");
      builder = SchemaBuilder.array(this.valueSchema);
      break;
    default:
      builder = SchemaBuilder.type(this.type);
      break;
  }

  if (Schema.Type.STRUCT == this.type) {
    for (Map.Entry<String, Schema> kvp : this.fieldSchemas.entrySet()) {
      builder.field(kvp.getKey(), kvp.getValue());
    }
  }

  if (!Strings.isNullOrEmpty(this.name)) {
    builder.name(this.name);
  }

  if (!Strings.isNullOrEmpty(this.doc)) {
    builder.doc(this.doc);
  }

  if (null != this.defaultValue) {
    Object value;
    switch (this.type) {
      case INT8:
        value = ((Number) this.defaultValue).byteValue();
        break;
      case INT16:
        value = ((Number) this.defaultValue).shortValue();
        break;
      case INT32:
        value = ((Number) this.defaultValue).intValue();
        break;
      case INT64:
        value = ((Number) this.defaultValue).longValue();
        break;
      case FLOAT32:
        value = ((Number) this.defaultValue).floatValue();
        break;
      case FLOAT64:
        value = ((Number) this.defaultValue).doubleValue();
        break;
      default:
        value = this.defaultValue;
        break;
    }
    builder.defaultValue(value);
  }

  if (null != this.parameters) {
    builder.parameters(this.parameters);
  }

  if (this.isOptional) {
    builder.optional();
  }

  if (null != this.version) {
    builder.version(this.version);
  }

  return builder.build();
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:76,代码来源:SchemaSerializationModule.java


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