當前位置: 首頁>>代碼示例>>Java>>正文


Java Schema.parameters方法代碼示例

本文整理匯總了Java中org.apache.kafka.connect.data.Schema.parameters方法的典型用法代碼示例。如果您正苦於以下問題:Java Schema.parameters方法的具體用法?Java Schema.parameters怎麽用?Java Schema.parameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.kafka.connect.data.Schema的用法示例。


在下文中一共展示了Schema.parameters方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import org.apache.kafka.connect.data.Schema; //導入方法依賴的package包/類
@Override
public R apply(R record) {
    final Schema schema = operatingSchema(record);
    requireSchema(schema, "updating schema metadata");
    final boolean isArray = schema.type() == Schema.Type.ARRAY;
    final boolean isMap = schema.type() == Schema.Type.MAP;
    final Schema updatedSchema = new ConnectSchema(
            schema.type(),
            schema.isOptional(),
            schema.defaultValue(),
            schemaName != null ? schemaName : schema.name(),
            schemaVersion != null ? schemaVersion : schema.version(),
            schema.doc(),
            schema.parameters(),
            schema.fields(),
            isMap ? schema.keySchema() : null,
            isMap || isArray ? schema.valueSchema() : null
    );
    return newRecord(record, updatedSchema);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:21,代碼來源:SetSchemaMetadata.java

示例2: copySchemaBasics

import org.apache.kafka.connect.data.Schema; //導入方法依賴的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

示例3: asJsonSchema

import org.apache.kafka.connect.data.Schema; //導入方法依賴的package包/類
public ObjectNode asJsonSchema(Schema schema) {
    if (schema == null)
        return null;

    ObjectNode cached = fromConnectSchemaCache.get(schema);
    if (cached != null)
        return cached;

    final ObjectNode jsonSchema;
    switch (schema.type()) {
        case BOOLEAN:
            jsonSchema = JsonSchema.BOOLEAN_SCHEMA.deepCopy();
            break;
        case BYTES:
            jsonSchema = JsonSchema.BYTES_SCHEMA.deepCopy();
            break;
        case FLOAT64:
            jsonSchema = JsonSchema.DOUBLE_SCHEMA.deepCopy();
            break;
        case FLOAT32:
            jsonSchema = JsonSchema.FLOAT_SCHEMA.deepCopy();
            break;
        case INT8:
            jsonSchema = JsonSchema.INT8_SCHEMA.deepCopy();
            break;
        case INT16:
            jsonSchema = JsonSchema.INT16_SCHEMA.deepCopy();
            break;
        case INT32:
            jsonSchema = JsonSchema.INT32_SCHEMA.deepCopy();
            break;
        case INT64:
            jsonSchema = JsonSchema.INT64_SCHEMA.deepCopy();
            break;
        case STRING:
            jsonSchema = JsonSchema.STRING_SCHEMA.deepCopy();
            break;
        case ARRAY:
            jsonSchema = JsonNodeFactory.instance.objectNode().put(JsonSchema.SCHEMA_TYPE_FIELD_NAME, JsonSchema.ARRAY_TYPE_NAME);
            jsonSchema.set(JsonSchema.ARRAY_ITEMS_FIELD_NAME, asJsonSchema(schema.valueSchema()));
            break;
        case MAP:
            jsonSchema = JsonNodeFactory.instance.objectNode().put(JsonSchema.SCHEMA_TYPE_FIELD_NAME, JsonSchema.MAP_TYPE_NAME);
            jsonSchema.set(JsonSchema.MAP_KEY_FIELD_NAME, asJsonSchema(schema.keySchema()));
            jsonSchema.set(JsonSchema.MAP_VALUE_FIELD_NAME, asJsonSchema(schema.valueSchema()));
            break;
        case STRUCT:
            jsonSchema = JsonNodeFactory.instance.objectNode().put(JsonSchema.SCHEMA_TYPE_FIELD_NAME, JsonSchema.STRUCT_TYPE_NAME);
            ArrayNode fields = JsonNodeFactory.instance.arrayNode();
            for (Field field : schema.fields()) {
                ObjectNode fieldJsonSchema = asJsonSchema(field.schema()).deepCopy();
                fieldJsonSchema.put(JsonSchema.STRUCT_FIELD_NAME_FIELD_NAME, field.name());
                fields.add(fieldJsonSchema);
            }
            jsonSchema.set(JsonSchema.STRUCT_FIELDS_FIELD_NAME, fields);
            break;
        default:
            throw new DataException("Couldn't translate unsupported schema type " + schema + ".");
    }

    jsonSchema.put(JsonSchema.SCHEMA_OPTIONAL_FIELD_NAME, schema.isOptional());
    if (schema.name() != null)
        jsonSchema.put(JsonSchema.SCHEMA_NAME_FIELD_NAME, schema.name());
    if (schema.version() != null)
        jsonSchema.put(JsonSchema.SCHEMA_VERSION_FIELD_NAME, schema.version());
    if (schema.doc() != null)
        jsonSchema.put(JsonSchema.SCHEMA_DOC_FIELD_NAME, schema.doc());
    if (schema.parameters() != null) {
        ObjectNode jsonSchemaParams = JsonNodeFactory.instance.objectNode();
        for (Map.Entry<String, String> prop : schema.parameters().entrySet())
            jsonSchemaParams.put(prop.getKey(), prop.getValue());
        jsonSchema.set(JsonSchema.SCHEMA_PARAMETERS_FIELD_NAME, jsonSchemaParams);
    }
    if (schema.defaultValue() != null)
        jsonSchema.set(JsonSchema.SCHEMA_DEFAULT_FIELD_NAME, convertToJson(schema, schema.defaultValue()));

    fromConnectSchemaCache.put(schema, jsonSchema);
    return jsonSchema;
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:80,代碼來源:JsonConverter.java


注:本文中的org.apache.kafka.connect.data.Schema.parameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。