Converting BigDecial to ByteBuffer

2016-01-19 Thread David Newberger
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



RE: add new attributes into avro schema

2015-12-17 Thread David Newberger
Hi,

I’m fairly new to working with avro so I could be wrong however this:

https://avro.apache.org/docs/1.7.7/api/java/org/apache/avro/SchemaBuilder.html

“Primitive Types
All Avro primitive types are trivial to configure. A primitive type in Avro 
JSON can be declared two ways, one that supports custom properties and one that 
does not:
{"type":"int"}
{"type":{"name":"int"}}
{"type":{"name":"int", "customProp":"val"}}
The analogous code form for the above three JSON lines are the below three 
lines:
  .intType()
  .intBuilder().endInt()
  .intBuilder().prop("customProp", "val").endInt()
Every primitive type has a shortcut to create the trivial type, and a builder 
when custom properties are required. The first line above is a shortcut for the 
second, analogous to the JSON case.”

makes it look like you can.

David Newberger

From: John Smith [mailto:lenov...@gmail.com]
Sent: Thursday, December 17, 2015 5:13 AM
To: user@avro.apache.org
Subject: add new attributes into avro schema

Hi,
is it possible to extend avro schema with custom attributes, for example

{
 "type":"record",
  "name":"X",
   "fields":[
  {"name":"b3","type":"int","doc":"blabla","newField1":"test", 
"newField2":"test2"}
]}');


Thank you!