You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Skye Wanderman-Milne <sk...@cloudera.com> on 2012/11/21 01:00:14 UTC

why isn't getSchema static?

The SpecificCompiler produces a getSchema function, which looks like it
could be static but isn't. Is there a good reason for this?

I bring this up because when writing to a data file, you have to provide a
schema to the DataFileWriter.create call, and using something like
MyGeneratedClass.getSchema() seems like the natural way to do this
(especially if you haven't created any instances of MyGeneratedClass yet).
Is there a good way to get the Schema object without creating an instance
or parsing the schema yourself?

Skye

Re: why isn't getSchema static?

Posted by Doug Cutting <cu...@apache.org>.
If it helps, one can think of the static .SCHEMA$ field as analogous
to the .class literal
(http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.8.2).

Still, a static method to get the schema might be nicer than a public
static field.  We cannot easily change getSchema() to be static since
it's part of the GenericContainer interface.  So we might instead
generate a new static method, named something like getClassSchema().
If someone feels that adding this would be an improvement, please file
a Jira issue.

Doug

On Tue, Nov 27, 2012 at 1:45 PM, Harsh J <ha...@cloudera.com> wrote:
> I do think having that API (which Skye referred to) would be good too, if
> it can simply access the same thing as .SCHEMA$. Feels more Java API-like.
>
>
> On Wed, Nov 28, 2012 at 2:40 AM, Scott Carey <sc...@apache.org> wrote:
>
>> Yes, .SCHEMA$ is the static for a generated class' schema and is there for
>> users to access.  It can be hard to find however, since some IDE's hide
>> auto-completion  of methods/fields/classes with '$' in the name.
>>
>> On 11/20/12 4:09 PM, "Skye Wanderman-Milne" <sk...@cloudera.com> wrote:
>>
>> >GeneratedClass.SCHEMA$, but yes that does work. Thanks! I guess with the
>> >ugly variable name I assumed that wasn't meant to be exposed but it is
>> >indeed public :)
>> >
>> >
>> >On Tue, Nov 20, 2012 at 4:04 PM, Philip Zeyliger
>> ><ph...@cloudera.com>wrote:
>> >
>> >> GeneratedClass.$SCHEMA?
>> >>
>> >> I'm not on the most latest version, but I think that exists.
>> >>
>> >> -- Philip
>> >>
>> >> On Tue, Nov 20, 2012 at 4:00 PM, Skye Wanderman-Milne <
>> skye@cloudera.com
>> >> >wrote:
>> >>
>> >> > The SpecificCompiler produces a getSchema function, which looks like
>> >>it
>> >> > could be static but isn't. Is there a good reason for this?
>> >> >
>> >> > I bring this up because when writing to a data file, you have to
>> >>provide
>> >> a
>> >> > schema to the DataFileWriter.create call, and using something like
>> >> > MyGeneratedClass.getSchema() seems like the natural way to do this
>> >> > (especially if you haven't created any instances of MyGeneratedClass
>> >> yet).
>> >> > Is there a good way to get the Schema object without creating an
>> >>instance
>> >> > or parsing the schema yourself?
>> >> >
>> >> > Skye
>> >> >
>> >>
>>
>>
>>
>
>
> --
> Harsh J

Re: why isn't getSchema static?

Posted by Harsh J <ha...@cloudera.com>.
I do think having that API (which Skye referred to) would be good too, if
it can simply access the same thing as .SCHEMA$. Feels more Java API-like.


On Wed, Nov 28, 2012 at 2:40 AM, Scott Carey <sc...@apache.org> wrote:

> Yes, .SCHEMA$ is the static for a generated class' schema and is there for
> users to access.  It can be hard to find however, since some IDE's hide
> auto-completion  of methods/fields/classes with '$' in the name.
>
> On 11/20/12 4:09 PM, "Skye Wanderman-Milne" <sk...@cloudera.com> wrote:
>
> >GeneratedClass.SCHEMA$, but yes that does work. Thanks! I guess with the
> >ugly variable name I assumed that wasn't meant to be exposed but it is
> >indeed public :)
> >
> >
> >On Tue, Nov 20, 2012 at 4:04 PM, Philip Zeyliger
> ><ph...@cloudera.com>wrote:
> >
> >> GeneratedClass.$SCHEMA?
> >>
> >> I'm not on the most latest version, but I think that exists.
> >>
> >> -- Philip
> >>
> >> On Tue, Nov 20, 2012 at 4:00 PM, Skye Wanderman-Milne <
> skye@cloudera.com
> >> >wrote:
> >>
> >> > The SpecificCompiler produces a getSchema function, which looks like
> >>it
> >> > could be static but isn't. Is there a good reason for this?
> >> >
> >> > I bring this up because when writing to a data file, you have to
> >>provide
> >> a
> >> > schema to the DataFileWriter.create call, and using something like
> >> > MyGeneratedClass.getSchema() seems like the natural way to do this
> >> > (especially if you haven't created any instances of MyGeneratedClass
> >> yet).
> >> > Is there a good way to get the Schema object without creating an
> >>instance
> >> > or parsing the schema yourself?
> >> >
> >> > Skye
> >> >
> >>
>
>
>


-- 
Harsh J

Re: why isn't getSchema static?

Posted by Scott Carey <sc...@apache.org>.
Yes, .SCHEMA$ is the static for a generated class' schema and is there for
users to access.  It can be hard to find however, since some IDE's hide
auto-completion  of methods/fields/classes with '$' in the name.

On 11/20/12 4:09 PM, "Skye Wanderman-Milne" <sk...@cloudera.com> wrote:

>GeneratedClass.SCHEMA$, but yes that does work. Thanks! I guess with the
>ugly variable name I assumed that wasn't meant to be exposed but it is
>indeed public :)
>
>
>On Tue, Nov 20, 2012 at 4:04 PM, Philip Zeyliger
><ph...@cloudera.com>wrote:
>
>> GeneratedClass.$SCHEMA?
>>
>> I'm not on the most latest version, but I think that exists.
>>
>> -- Philip
>>
>> On Tue, Nov 20, 2012 at 4:00 PM, Skye Wanderman-Milne <skye@cloudera.com
>> >wrote:
>>
>> > The SpecificCompiler produces a getSchema function, which looks like
>>it
>> > could be static but isn't. Is there a good reason for this?
>> >
>> > I bring this up because when writing to a data file, you have to
>>provide
>> a
>> > schema to the DataFileWriter.create call, and using something like
>> > MyGeneratedClass.getSchema() seems like the natural way to do this
>> > (especially if you haven't created any instances of MyGeneratedClass
>> yet).
>> > Is there a good way to get the Schema object without creating an
>>instance
>> > or parsing the schema yourself?
>> >
>> > Skye
>> >
>>



Re: why isn't getSchema static?

Posted by Skye Wanderman-Milne <sk...@cloudera.com>.
GeneratedClass.SCHEMA$, but yes that does work. Thanks! I guess with the
ugly variable name I assumed that wasn't meant to be exposed but it is
indeed public :)


On Tue, Nov 20, 2012 at 4:04 PM, Philip Zeyliger <ph...@cloudera.com>wrote:

> GeneratedClass.$SCHEMA?
>
> I'm not on the most latest version, but I think that exists.
>
> -- Philip
>
> On Tue, Nov 20, 2012 at 4:00 PM, Skye Wanderman-Milne <skye@cloudera.com
> >wrote:
>
> > The SpecificCompiler produces a getSchema function, which looks like it
> > could be static but isn't. Is there a good reason for this?
> >
> > I bring this up because when writing to a data file, you have to provide
> a
> > schema to the DataFileWriter.create call, and using something like
> > MyGeneratedClass.getSchema() seems like the natural way to do this
> > (especially if you haven't created any instances of MyGeneratedClass
> yet).
> > Is there a good way to get the Schema object without creating an instance
> > or parsing the schema yourself?
> >
> > Skye
> >
>

Re: why isn't getSchema static?

Posted by Philip Zeyliger <ph...@cloudera.com>.
GeneratedClass.$SCHEMA?

I'm not on the most latest version, but I think that exists.

-- Philip

On Tue, Nov 20, 2012 at 4:00 PM, Skye Wanderman-Milne <sk...@cloudera.com>wrote:

> The SpecificCompiler produces a getSchema function, which looks like it
> could be static but isn't. Is there a good reason for this?
>
> I bring this up because when writing to a data file, you have to provide a
> schema to the DataFileWriter.create call, and using something like
> MyGeneratedClass.getSchema() seems like the natural way to do this
> (especially if you haven't created any instances of MyGeneratedClass yet).
> Is there a good way to get the Schema object without creating an instance
> or parsing the schema yourself?
>
> Skye
>