@Test public void testToConnectRecursiveSchema() { ProtobufSchema protobufSchema = new ProtobufSchema( RecursiveKeyValue.RecursiveKeyValueMessage.getDescriptor()); ProtobufData protobufData = new ProtobufData(); Schema expected = getRecursiveSchema(); Schema actual = protobufData.toConnectSchema(protobufSchema); assertEquals(expected.field("key"), actual.field("key")); assertEquals(expected.field("value"), actual.field("value")); Schema expectedNested = expected.field("key_value").schema(); Schema actualNested = actual.field("key_value").schema(); assertEquals(expectedNested.name(), actualNested.name()); assertEquals(expectedNested.type(), actualNested.type()); assertEquals(expectedNested.parameters(), actualNested.parameters()); }
public Schema toConnectSchema(ProtobufSchema schema) { if (schema == null) { return null; } Pair<String, ProtobufSchema> cacheKey = new Pair<>(schema.name(), schema); Schema cachedSchema = toConnectSchemaCache.get(cacheKey); if (cachedSchema != null) { return cachedSchema; } SchemaBuilder builder = SchemaBuilder.struct(); Descriptor descriptor = schema.toDescriptor(); ToConnectContext ctx = new ToConnectContext(); ctx.put(descriptor.getFullName(), builder); Schema resultSchema = toConnectSchema(ctx, builder, descriptor, schema.version()).build(); toConnectSchemaCache.put(cacheKey, resultSchema); return resultSchema; }
ProtobufData { public Schema toConnectSchema(ProtobufSchema schema) { if (schema == null) { return null; } Pair<String, ProtobufSchema> cacheKey = new Pair<>(schema.name(), schema); Schema cachedSchema = toConnectSchemaCache.get(cacheKey); if (cachedSchema != null) { return cachedSchema; } SchemaBuilder builder = SchemaBuilder.struct(); Descriptor descriptor = schema.toDescriptor(); ToConnectContext ctx = new ToConnectContext(); ctx.put(descriptor.getFullName(), builder); Schema resultSchema = toConnectSchema(ctx, builder, descriptor, schema.version()).build(); toConnectSchemaCache.put(cacheKey, resultSchema); return resultSchema; } }
ProtobufData { public Schema toConnectSchema(ProtobufSchema schema) { if (schema == null) { return null; } Pair<String, ProtobufSchema> cacheKey = new Pair<>(schema.name(), schema); Schema cachedSchema = toConnectSchemaCache.get(cacheKey); if (cachedSchema != null) { return cachedSchema; } SchemaBuilder builder = SchemaBuilder.struct(); Descriptor descriptor = schema.toDescriptor(); ToConnectContext ctx = new ToConnectContext(); ctx.put(descriptor.getFullName(), builder); Schema resultSchema = toConnectSchema(ctx, builder, descriptor, schema.version()).build(); toConnectSchemaCache.put(cacheKey, resultSchema); return resultSchema; } ProtobufData();  ProtobufData(int cacheSize);  ProtobufData(ProtobufDataConfig protobufDataConfig); }
ProtobufData { public Schema toConnectSchema(ProtobufSchema schema) { if (schema == null) { return null; } Pair<String, ProtobufSchema> cacheKey = new Pair<>(schema.name(), schema); Schema cachedSchema = toConnectSchemaCache.get(cacheKey); if (cachedSchema != null) { return cachedSchema; } SchemaBuilder builder = SchemaBuilder.struct(); Descriptor descriptor = schema.toDescriptor(); ToConnectContext ctx = new ToConnectContext(); ctx.put(descriptor.getFullName(), builder); Schema resultSchema = toConnectSchema(ctx, builder, descriptor, schema.version()).build(); toConnectSchemaCache.put(cacheKey, resultSchema); return resultSchema; } ProtobufData();  ProtobufData(int cacheSize);  ProtobufData(ProtobufDataConfig protobufDataConfig); ProtobufSchemaAndValue fromConnectData(Schema schema, Object value); ProtobufSchema fromConnectSchema(Schema schema); SchemaAndValue toConnectData(ProtobufSchema protobufSchema, Message message); Schema toConnectSchema(ProtobufSchema schema); }
ProtobufData { public Schema toConnectSchema(ProtobufSchema schema) { if (schema == null) { return null; } Pair<String, ProtobufSchema> cacheKey = new Pair<>(schema.name(), schema); Schema cachedSchema = toConnectSchemaCache.get(cacheKey); if (cachedSchema != null) { return cachedSchema; } SchemaBuilder builder = SchemaBuilder.struct(); Descriptor descriptor = schema.toDescriptor(); ToConnectContext ctx = new ToConnectContext(); ctx.put(descriptor.getFullName(), builder); Schema resultSchema = toConnectSchema(ctx, builder, descriptor, schema.version()).build(); toConnectSchemaCache.put(cacheKey, resultSchema); return resultSchema; } ProtobufData();  ProtobufData(int cacheSize);  ProtobufData(ProtobufDataConfig protobufDataConfig); ProtobufSchemaAndValue fromConnectData(Schema schema, Object value); ProtobufSchema fromConnectSchema(Schema schema); SchemaAndValue toConnectData(ProtobufSchema protobufSchema, Message message); Schema toConnectSchema(ProtobufSchema schema); static final String NAMESPACE; static final String DEFAULT_SCHEMA_NAME; static final String MAP_ENTRY_SUFFIX; static final String KEY_FIELD; static final String VALUE_FIELD; static final String PROTOBUF_TYPE_ENUM; static final String PROTOBUF_TYPE_ENUM_PREFIX; static final String PROTOBUF_TYPE_UNION; static final String PROTOBUF_TYPE_UNION_PREFIX; static final String PROTOBUF_TYPE_TAG; static final String GOOGLE_PROTOBUF_PACKAGE; static final String GOOGLE_PROTOBUF_TIMESTAMP_NAME; static final String GOOGLE_PROTOBUF_TIMESTAMP_FULL_NAME; static final String GOOGLE_PROTOBUF_TIMESTAMP_LOCATION; }