You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beam.apache.org by Binh Nguyen Van <bi...@gmail.com> on 2022/08/04 21:06:18 UTC

Using a non-AutoValue member with AutoValueSchema

Hi,

I have an AutoValue class and it looks like this

@AutoValue
@DefaultSchema( AutoValueSchema.class )
public abstract class MyClass {
    public abstract String getField1();
    public abstract MyThriftClass getField2();
    public static Builder Builder() {
        return new AutoValue_MyClass.Builder();
    }

    @AutoValue.Builder
    public static abstract class Builder() {
        public abstract Builder setField1(String field1);
        public abstract Builder setField2(MyThriftClass field2);
        public abstract MyClass build();
    }
}

MyThriftClass is not an AutoValue class and it inherits from
org.apache.thrift.TBase class.

When I run a pipeline with a PCollection of elements that are instances of
this class, I got this error java.lang.IllegalStateException: AutoValue
generated class not found: com.foo.bar.AutoValue_MyThriftClass.

My question is, is it possible to use a non-AutoValue member in an
AutoValue class like what I am doing now? If yes then how can I do it? If
no then what would be the alternatives?

Thank you

-Binh

Re: Using a non-AutoValue member with AutoValueSchema

Posted by Binh Nguyen Van <bi...@gmail.com>.
Thank you for helping.

My thrift class conforms to Java beans, I will convert the outer class to
Java bean and try it.

-Binh


On Thu, Aug 4, 2022 at 2:55 PM Reuven Lax via user <us...@beam.apache.org>
wrote:

> That would be a nice feature, though maybe some work to implement.
>
> On Thu, Aug 4, 2022 at 2:49 PM Brian Hulette <bh...@google.com> wrote:
>
>> In some places (e.g. in AutoValueSchema) we assume that nested
>> schema-inferred types are of the same "class". I filed [1] to track this a
>> while back - I think we should support mixing and matching SchemaProviders
>> for nested types.
>>
>> [1] https://github.com/apache/beam/issues/20359
>>
>> On Thu, Aug 4, 2022 at 2:45 PM Reuven Lax via user <us...@beam.apache.org>
>> wrote:
>>
>>> We do have JavaBeanSchema which might work, depending on whether your
>>> thrift class conforms to java beans.
>>>
>>> On Thu, Aug 4, 2022 at 2:06 PM Binh Nguyen Van <bi...@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have an AutoValue class and it looks like this
>>>>
>>>> @AutoValue
>>>> @DefaultSchema( AutoValueSchema.class )
>>>> public abstract class MyClass {
>>>>     public abstract String getField1();
>>>>     public abstract MyThriftClass getField2();
>>>>     public static Builder Builder() {
>>>>         return new AutoValue_MyClass.Builder();
>>>>     }
>>>>
>>>>     @AutoValue.Builder
>>>>     public static abstract class Builder() {
>>>>         public abstract Builder setField1(String field1);
>>>>         public abstract Builder setField2(MyThriftClass field2);
>>>>         public abstract MyClass build();
>>>>     }
>>>> }
>>>>
>>>> MyThriftClass is not an AutoValue class and it inherits from
>>>> org.apache.thrift.TBase class.
>>>>
>>>> When I run a pipeline with a PCollection of elements that are instances
>>>> of this class, I got this error java.lang.IllegalStateException:
>>>> AutoValue generated class not found: com.foo.bar.AutoValue_MyThriftClass
>>>> .
>>>>
>>>> My question is, is it possible to use a non-AutoValue member in an
>>>> AutoValue class like what I am doing now? If yes then how can I do it? If
>>>> no then what would be the alternatives?
>>>>
>>>> Thank you
>>>>
>>>> -Binh
>>>>
>>>>
>>>>

Re: Using a non-AutoValue member with AutoValueSchema

Posted by Reuven Lax via user <us...@beam.apache.org>.
That would be a nice feature, though maybe some work to implement.

On Thu, Aug 4, 2022 at 2:49 PM Brian Hulette <bh...@google.com> wrote:

> In some places (e.g. in AutoValueSchema) we assume that nested
> schema-inferred types are of the same "class". I filed [1] to track this a
> while back - I think we should support mixing and matching SchemaProviders
> for nested types.
>
> [1] https://github.com/apache/beam/issues/20359
>
> On Thu, Aug 4, 2022 at 2:45 PM Reuven Lax via user <us...@beam.apache.org>
> wrote:
>
>> We do have JavaBeanSchema which might work, depending on whether your
>> thrift class conforms to java beans.
>>
>> On Thu, Aug 4, 2022 at 2:06 PM Binh Nguyen Van <bi...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I have an AutoValue class and it looks like this
>>>
>>> @AutoValue
>>> @DefaultSchema( AutoValueSchema.class )
>>> public abstract class MyClass {
>>>     public abstract String getField1();
>>>     public abstract MyThriftClass getField2();
>>>     public static Builder Builder() {
>>>         return new AutoValue_MyClass.Builder();
>>>     }
>>>
>>>     @AutoValue.Builder
>>>     public static abstract class Builder() {
>>>         public abstract Builder setField1(String field1);
>>>         public abstract Builder setField2(MyThriftClass field2);
>>>         public abstract MyClass build();
>>>     }
>>> }
>>>
>>> MyThriftClass is not an AutoValue class and it inherits from
>>> org.apache.thrift.TBase class.
>>>
>>> When I run a pipeline with a PCollection of elements that are instances
>>> of this class, I got this error java.lang.IllegalStateException:
>>> AutoValue generated class not found: com.foo.bar.AutoValue_MyThriftClass
>>> .
>>>
>>> My question is, is it possible to use a non-AutoValue member in an
>>> AutoValue class like what I am doing now? If yes then how can I do it? If
>>> no then what would be the alternatives?
>>>
>>> Thank you
>>>
>>> -Binh
>>>
>>>
>>>

Re: Using a non-AutoValue member with AutoValueSchema

Posted by Brian Hulette via user <us...@beam.apache.org>.
In some places (e.g. in AutoValueSchema) we assume that nested
schema-inferred types are of the same "class". I filed [1] to track this a
while back - I think we should support mixing and matching SchemaProviders
for nested types.

[1] https://github.com/apache/beam/issues/20359

On Thu, Aug 4, 2022 at 2:45 PM Reuven Lax via user <us...@beam.apache.org>
wrote:

> We do have JavaBeanSchema which might work, depending on whether your
> thrift class conforms to java beans.
>
> On Thu, Aug 4, 2022 at 2:06 PM Binh Nguyen Van <bi...@gmail.com> wrote:
>
>> Hi,
>>
>> I have an AutoValue class and it looks like this
>>
>> @AutoValue
>> @DefaultSchema( AutoValueSchema.class )
>> public abstract class MyClass {
>>     public abstract String getField1();
>>     public abstract MyThriftClass getField2();
>>     public static Builder Builder() {
>>         return new AutoValue_MyClass.Builder();
>>     }
>>
>>     @AutoValue.Builder
>>     public static abstract class Builder() {
>>         public abstract Builder setField1(String field1);
>>         public abstract Builder setField2(MyThriftClass field2);
>>         public abstract MyClass build();
>>     }
>> }
>>
>> MyThriftClass is not an AutoValue class and it inherits from
>> org.apache.thrift.TBase class.
>>
>> When I run a pipeline with a PCollection of elements that are instances
>> of this class, I got this error java.lang.IllegalStateException:
>> AutoValue generated class not found: com.foo.bar.AutoValue_MyThriftClass.
>>
>> My question is, is it possible to use a non-AutoValue member in an
>> AutoValue class like what I am doing now? If yes then how can I do it? If
>> no then what would be the alternatives?
>>
>> Thank you
>>
>> -Binh
>>
>>
>>

Re: Using a non-AutoValue member with AutoValueSchema

Posted by Reuven Lax via user <us...@beam.apache.org>.
We do have JavaBeanSchema which might work, depending on whether your
thrift class conforms to java beans.

On Thu, Aug 4, 2022 at 2:06 PM Binh Nguyen Van <bi...@gmail.com> wrote:

> Hi,
>
> I have an AutoValue class and it looks like this
>
> @AutoValue
> @DefaultSchema( AutoValueSchema.class )
> public abstract class MyClass {
>     public abstract String getField1();
>     public abstract MyThriftClass getField2();
>     public static Builder Builder() {
>         return new AutoValue_MyClass.Builder();
>     }
>
>     @AutoValue.Builder
>     public static abstract class Builder() {
>         public abstract Builder setField1(String field1);
>         public abstract Builder setField2(MyThriftClass field2);
>         public abstract MyClass build();
>     }
> }
>
> MyThriftClass is not an AutoValue class and it inherits from
> org.apache.thrift.TBase class.
>
> When I run a pipeline with a PCollection of elements that are instances of
> this class, I got this error java.lang.IllegalStateException: AutoValue
> generated class not found: com.foo.bar.AutoValue_MyThriftClass.
>
> My question is, is it possible to use a non-AutoValue member in an
> AutoValue class like what I am doing now? If yes then how can I do it? If
> no then what would be the alternatives?
>
> Thank you
>
> -Binh
>
>
>