I'm having trouble writing an Avro schema for java.math.BigDecimal type, I tried the following:
`
@namespace("test")
protocol My_Protocol_v1 {
record BigDecimal {
@java-class("java.math.BigDecimal") string value;
}
`
But it's not working: This IDL schema compiles fine and can generate a Java class called BigDecimal, but I cannot really use the generated BigDecimal as java.math.BigDecimal, what's wrong? or How should I do it?
Thanks a lot
OK, so I emailed Apache Avro dev email list and got a response from Doug Cutting (Thanks a lot Doug).
I believe this has already been implemented but not yet released.
It was implemented in: https://issues.apache.org/jira/browse/AVRO-1847
This is slated to be included in the 1.8.2 release, which should soon be out.
Just to shed some light on how it works in the newer version:
We just started using rc4 of 1.8.2
and you can create BigDecimal fields with the following syntax:
record Thing {
decimal(10,2) foo;
}
The Thing
class will have a BigDecimal
property foo
with a precision of 10 and scale of 2.
即使编译器版本已更改为 1.8.2 版本,decimal(10,2) 也不会在 avsc 模式中生成十进制数据类型。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.