You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Bill Baird <bi...@traxtech.com> on 2013/08/14 18:34:10 UTC

Best Practices - c#/java/ruby, decimals and dates

Hello,

I have a legacy windows c# implementation that needs to be able serialize a
large object structure for deserialization in java and ruby.  This contains
business data and has many fields that are either decimal or date/datetime
types.

To facilitate this, I am creating an Avro json schema that can be used by
c#, java, and ruby implementations.  My question is about the best way to
handle decimal and date datatypes.  Yes, I know they could be converted to
strings for serialization, but that would require explicit conversion to and
from the native decimal/bigdecimal types and in general force the Avro
emitted classes to be either wrapped or duplicated in classes which expose
them as the desired decimal or date types.

Since Avro does not natively support these types, what is considered best
practice?  I'd certainly like to avoid the overhead/complexity of wrapping
an entire class structure.  I see posts about java annotations for date
types that look like they will be in 1.7.5, but I don't see how this will
help in my situation.

Thanks in advance,
Bill 



--
View this message in context: http://apache-avro.679487.n3.nabble.com/Best-Practices-c-java-ruby-decimals-and-dates-tp4027985.html
Sent from the Avro - Users mailing list archive at Nabble.com.

Re: Best Practices - c#/java/ruby, decimals and dates

Posted by Mason <ma...@verbasoftware.com>.
Regarding datetimes, I convert to milliseconds since the UNIX epoch, 
UTC, before encoding with Avro.

On 8/14/13 09:34 AM, Bill Baird wrote:
> Hello,
>
> I have a legacy windows c# implementation that needs to be able serialize a
> large object structure for deserialization in java and ruby.  This contains
> business data and has many fields that are either decimal or date/datetime
> types.
>
> To facilitate this, I am creating an Avro json schema that can be used by
> c#, java, and ruby implementations.  My question is about the best way to
> handle decimal and date datatypes.  Yes, I know they could be converted to
> strings for serialization, but that would require explicit conversion to and
> from the native decimal/bigdecimal types and in general force the Avro
> emitted classes to be either wrapped or duplicated in classes which expose
> them as the desired decimal or date types.
>
> Since Avro does not natively support these types, what is considered best
> practice?  I'd certainly like to avoid the overhead/complexity of wrapping
> an entire class structure.  I see posts about java annotations for date
> types that look like they will be in 1.7.5, but I don't see how this will
> help in my situation.
>
> Thanks in advance,
> Bill
>
>
>
> --
> View this message in context: http://apache-avro.679487.n3.nabble.com/Best-Practices-c-java-ruby-decimals-and-dates-tp4027985.html
> Sent from the Avro - Users mailing list archive at Nabble.com.