Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenlax committed Oct 12, 2024
1 parent 29019bf commit 66cea97
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.beam.sdk.util.common.ReflectHelpers.ObjectsClassComparator;
import org.apache.beam.sdk.values.Row;
import org.apache.beam.sdk.values.TypeDescriptor;
import org.apache.beam.sdk.values.TypeDescriptors;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.Lists;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.Maps;
Expand Down Expand Up @@ -78,9 +77,6 @@ void registerProvider(TypeDescriptor typeDescriptor, SchemaProvider schemaProvid
}

private <T> @Nullable SchemaProvider schemaProviderFor(TypeDescriptor<T> typeDescriptor) {
if (typeDescriptor.equals(TypeDescriptors.rows())) {
throw new IllegalArgumentException("Schema providers cannot be registered for Rows.");
}
TypeDescriptor<?> type = typeDescriptor;
do {
SchemaProvider schemaProvider = providers.get(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ public ByteCodeAppender appender(final Target implementationTarget) {
Parameter parameter = parameters.get(i);
ForLoadedType convertedType =
new ForLoadedType(
(Class) convertType.convert(TypeDescriptor.of(parameter.getType())));
(Class) convertType.convert(TypeDescriptor.of(parameter.getParameterizedType())));

// The instruction to read the parameter. Use the fieldMapping to reorder parameters as
// necessary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static <T> SchemaUserTypeCreator createStaticCreator(
field.getDeclaringClass(),
typeConversionsFactory
.createTypeConversion(false)
.convert(TypeDescriptor.of(field.getType())));
.convert(TypeDescriptor.of(field.getGenericType())));
builder =
implementGetterMethods(builder, field, typeInformation.getName(), typeConversionsFactory);
try {
Expand Down Expand Up @@ -386,7 +386,7 @@ private static <ObjectT, ValueT> FieldValueSetter<ObjectT, ValueT> createSetter(
field.getDeclaringClass(),
typeConversionsFactory
.createTypeConversion(false)
.convert(TypeDescriptor.of(field.getType())));
.convert(TypeDescriptor.of(field.getGenericType())));
builder = implementSetterMethods(builder, field, typeConversionsFactory);
try {
return builder
Expand Down Expand Up @@ -494,7 +494,7 @@ public ByteCodeAppender appender(final Target implementationTarget) {
// Do any conversions necessary.
typeConversionsFactory
.createSetterConversions(readField)
.convert(TypeDescriptor.of(field.getType())),
.convert(TypeDescriptor.of(field.getGenericType())),
// Now update the field and return void.
FieldAccess.forField(new ForLoadedField(field)).write(),
MethodReturn.VOID);
Expand Down Expand Up @@ -549,7 +549,8 @@ public ByteCodeAppender appender(final Target implementationTarget) {
Field field = fields.get(i);

ForLoadedType convertedType =
new ForLoadedType((Class) convertType.convert(TypeDescriptor.of(field.getType())));
new ForLoadedType(
(Class) convertType.convert(TypeDescriptor.of(field.getGenericType())));

// The instruction to read the parameter.
StackManipulation readParameter =
Expand All @@ -566,7 +567,7 @@ public ByteCodeAppender appender(final Target implementationTarget) {
// Do any conversions necessary.
typeConversionsFactory
.createSetterConversions(readParameter)
.convert(TypeDescriptor.of(field.getType())),
.convert(TypeDescriptor.of(field.getGenericType())),
// Now update the field.
FieldAccess.forField(new ForLoadedField(field)).write());
stackManipulation = new StackManipulation.Compound(stackManipulation, updateField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,14 +783,6 @@ public void testCircularNestedPOJOThrows() throws NoSuchSchemaException {
containsString("TestPOJOs$FirstCircularNestedPOJO"));
}

@Test
public void testRegisterPojo() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
registry.registerPOJO(SimplePOJO.class);
Schema schema = registry.getSchema(SimplePOJO.class);
assertTrue(SIMPLE_POJO_SCHEMA.equivalent(schema));
}

@Test
public void testRegisterPojoWithTypeParameter() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ public void testDefaultSchemaProvider() throws NoSuchSchemaException {
assertEquals(EMPTY_SCHEMA, registry.getSchema(TestDefaultSchemaClass.class));
}

@Test
public void testRegisterPojo() throws NoSuchSchemaException {
SchemaRegistry registry = SchemaRegistry.createDefault();
registry.registerPOJO(SimplePOJO.class);
Schema schema = registry.getSchema(SimplePOJO.class);
assertTrue(SIMPLE_POJO_SCHEMA.equivalent(schema));
}

@Test
public void testSchemaTypeParameterInsideCoder() throws CannotProvideCoderException {
SchemaRegistry schemaRegistry = SchemaRegistry.createDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PojoWithNestedArray)) {
if (!(o instanceof PojoWithIterable)) {
return false;
}
PojoWithIterable that = (PojoWithIterable) o;
Expand Down

0 comments on commit 66cea97

Please sign in to comment.