You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Maulik Gandhi <mm...@gmail.com> on 2015/01/06 22:33:40 UTC

Feature: Clear all fields / Reset all fields to default value on Record template

Hello Avro Users,

Questions:

   1. I was wondering if adding a functionality of clearing all fields on
   Record, makes sense or not?
   2. I was wondering if adding a functionality of reseting all fields to
   default value (the default value would be what has been defined in AVDL) on
   Record, makes sense or not?

I did look up through old mail archive list and JIRA queue, but could not
find anything similar, please point me to any documentation or links if I
missed them.

In order to achieve what I am asking here, my best guess is modifying
existing Record template.  Please correct me if I am going on wrong path.

*Record.vm*:
https://github.com/apache/avro/blob/branch-1.7/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm

Thanks for your help and awesome work!!

Thanks,
- Maulik

Re: Feature: Clear all fields / Reset all fields to default value on Record template

Posted by Doug Cutting <cu...@apache.org>.
On Tue, Jan 6, 2015 at 1:33 PM, Maulik Gandhi <mm...@gmail.com> wrote:
> I was wondering if adding a functionality of clearing all fields on Record,
> makes sense or not?
> I was wondering if adding a functionality of reseting all fields to default
> value (the default value would be what has been defined in AVDL) on Record,
> makes sense or not?

These both seem reasonable to me.

The simplest thing to do is to clear the fieldSetFlags.  This could be
done with a method on RecordBuilderBase, something like (untested):

public void reset() {
  Arrays.fill(fieldSetFlags(), false);
}

The builder uses default values for fields that have not been set.

Doug

Re: Feature: Clear all fields / Reset all fields to default value on Record template

Posted by Vikas Saxena <vi...@gmail.com>.
Hi Maulik,
Here is the git link
https://github.com/apache/avro/tree/branch-1.7/lang/c/src/avro

You will need to refer to value.h file for the function definition.

Thanks,
Vikas

On Wed, Jan 7, 2015 at 9:26 AM, Maulik Gandhi <mm...@gmail.com> wrote:

> Hi Vikas,
>
> Can you share git link for function, which you are referring to. Is Java
> API for same available ?
>
> Thanks for replying.
> - Maulik
>
> On Tue, Jan 6, 2015 at 4:03 PM, Vikas Saxena <vi...@gmail.com>
> wrote:
>
>> Hi Maulik,
>> I think the new Value API supports this.
>> I have worked on the C library of avro and I am using a function avro_value_reset
>> which does the same.
>> Calling this function on your record variable will reset the variable and
>> its sub-fields (including sub-records and their fields)  to their default
>> values.
>>
>> Thanks,
>> Vikas
>>
>> On Wed, Jan 7, 2015 at 8:33 AM, Maulik Gandhi <mm...@gmail.com> wrote:
>>
>>> Hello Avro Users,
>>>
>>> Questions:
>>>
>>>    1. I was wondering if adding a functionality of clearing all fields
>>>    on Record, makes sense or not?
>>>    2. I was wondering if adding a functionality of reseting all fields
>>>    to default value (the default value would be what has been defined in AVDL)
>>>    on Record, makes sense or not?
>>>
>>> I did look up through old mail archive list and JIRA queue, but could
>>> not find anything similar, please point me to any documentation or links if
>>> I missed them.
>>>
>>> In order to achieve what I am asking here, my best guess is modifying
>>> existing Record template.  Please correct me if I am going on wrong path.
>>>
>>> *Record.vm*:
>>> https://github.com/apache/avro/blob/branch-1.7/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
>>>
>>> Thanks for your help and awesome work!!
>>>
>>> Thanks,
>>> - Maulik
>>>
>>
>>
>>
>> --
>> Thanks and regards,
>> Vikas Saxena.
>>
>
>


-- 
Thanks and regards,
Vikas Saxena.

Re: Feature: Clear all fields / Reset all fields to default value on Record template

Posted by Maulik Gandhi <mm...@gmail.com>.
Hi Vikas,

Can you share git link for function, which you are referring to. Is Java
API for same available ?

Thanks for replying.
- Maulik

On Tue, Jan 6, 2015 at 4:03 PM, Vikas Saxena <vi...@gmail.com>
wrote:

> Hi Maulik,
> I think the new Value API supports this.
> I have worked on the C library of avro and I am using a function avro_value_reset
> which does the same.
> Calling this function on your record variable will reset the variable and
> its sub-fields (including sub-records and their fields)  to their default
> values.
>
> Thanks,
> Vikas
>
> On Wed, Jan 7, 2015 at 8:33 AM, Maulik Gandhi <mm...@gmail.com> wrote:
>
>> Hello Avro Users,
>>
>> Questions:
>>
>>    1. I was wondering if adding a functionality of clearing all fields
>>    on Record, makes sense or not?
>>    2. I was wondering if adding a functionality of reseting all fields
>>    to default value (the default value would be what has been defined in AVDL)
>>    on Record, makes sense or not?
>>
>> I did look up through old mail archive list and JIRA queue, but could not
>> find anything similar, please point me to any documentation or links if I
>> missed them.
>>
>> In order to achieve what I am asking here, my best guess is modifying
>> existing Record template.  Please correct me if I am going on wrong path.
>>
>> *Record.vm*:
>> https://github.com/apache/avro/blob/branch-1.7/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
>>
>> Thanks for your help and awesome work!!
>>
>> Thanks,
>> - Maulik
>>
>
>
>
> --
> Thanks and regards,
> Vikas Saxena.
>

Re: Feature: Clear all fields / Reset all fields to default value on Record template

Posted by Vikas Saxena <vi...@gmail.com>.
Hi Maulik,
I think the new Value API supports this.
I have worked on the C library of avro and I am using a function
avro_value_reset
which does the same.
Calling this function on your record variable will reset the variable and
its sub-fields (including sub-records and their fields)  to their default
values.

Thanks,
Vikas

On Wed, Jan 7, 2015 at 8:33 AM, Maulik Gandhi <mm...@gmail.com> wrote:

> Hello Avro Users,
>
> Questions:
>
>    1. I was wondering if adding a functionality of clearing all fields on
>    Record, makes sense or not?
>    2. I was wondering if adding a functionality of reseting all fields to
>    default value (the default value would be what has been defined in AVDL) on
>    Record, makes sense or not?
>
> I did look up through old mail archive list and JIRA queue, but could not
> find anything similar, please point me to any documentation or links if I
> missed them.
>
> In order to achieve what I am asking here, my best guess is modifying
> existing Record template.  Please correct me if I am going on wrong path.
>
> *Record.vm*:
> https://github.com/apache/avro/blob/branch-1.7/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
>
> Thanks for your help and awesome work!!
>
> Thanks,
> - Maulik
>



-- 
Thanks and regards,
Vikas Saxena.

Re: Feature: Clear all fields / Reset all fields to default value on Record template

Posted by Maulik Gandhi <mm...@gmail.com>.
Sorry if I forgot to mention, I am working with Builder way of creating a
Record.  Thus taking example of clearing all fields on User example.

User.Builder userBuilder = User.newBuilder();

// Step-1: Logic: set fields on userBuilder, potentially emit User object
by building it userBuilder.build()
// Step-2: Clear the contents on userBuilder, by calling
userBuilder.clearAll() (new feature)
// Step-3: Go back to Step-1

*Avro Getting Started:*
http://avro.apache.org/docs/1.7.7/gettingstartedjava.html#Creating+Users

Thanks,
- Maulik

On Tue, Jan 6, 2015 at 3:33 PM, Maulik Gandhi <mm...@gmail.com> wrote:

> Hello Avro Users,
>
> Questions:
>
>    1. I was wondering if adding a functionality of clearing all fields on
>    Record, makes sense or not?
>    2. I was wondering if adding a functionality of reseting all fields to
>    default value (the default value would be what has been defined in AVDL) on
>    Record, makes sense or not?
>
> I did look up through old mail archive list and JIRA queue, but could not
> find anything similar, please point me to any documentation or links if I
> missed them.
>
> In order to achieve what I am asking here, my best guess is modifying
> existing Record template.  Please correct me if I am going on wrong path.
>
> *Record.vm*:
> https://github.com/apache/avro/blob/branch-1.7/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
>
> Thanks for your help and awesome work!!
>
> Thanks,
> - Maulik
>