avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <seemanto.ba...@nomura.com>
Subject RE: Converting BigDecial to ByteBuffer
Date Tue, 19 Jan 2016 15:16:48 GMT
Can you serialize the BigDecimal to byte[]. Byetbuffer has a backing byte[]. It allows off
heap mem allocation.

-regards
Seemanto Barua


From: David Newberger [mailto:david.newberger@wandcorp.com]
Sent: Tuesday, January 19, 2016 9:29 AM
To: user@avro.apache.org
Subject: Converting BigDecial to ByteBuffer

Hello All,

I have an avro schema that includes the following as a field:

{
  "name" : "currency",
  "type" : ["null","bytes"],
  "logicalType": "decimal",
  "precision": 9,
  "scale": 4
},

When I run the avro-tools on it  to create a java file representing the schema it produces
a property that looks like public java.nio.ByteBuffer currency;

However, in other parts of the program I’m using Scala with values in BigDecimal types.

How can I convert a BigDecimal value to the expected ByteBuffer?

Is there anything special I need to do to ensure it is compatible with avro and other tools
like Impala?

Also is this the correct form to using currency values?

Cheers,

David Newberger



PLEASE READ: This message is for the named person's use only. It may contain confidential,
proprietary or legally privileged information. No confidentiality or privilege is waived or
lost by any mistransmission. If you receive this message in error, please delete it and all
copies from your system, destroy any hard copies and notify the sender. You must not, directly
or indirectly, use, disclose, distribute, print, or copy any part of this message if you are
not the intended recipient. Nomura Holding America Inc., Nomura Securities International,
Inc, and their respective subsidiaries each reserve the right to monitor all e-mail communications
through its networks. Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized to state the views
of such entity. Unless otherwise stated, any pricing information in this message is indicative
only, is subject to change and does not constitute an offer to deal at any price quoted. Any
reference to the terms of executed transactions should be treated as preliminary only and
subject to our formal written confirmation.


Mime
View raw message