. " " 2014 , Avro Java.
, , Avro Java ( , , ).
BigDecimal ByteBuffer
:
Avro . - two -s-complement . .
Java (, Avro 1.8.0-rc2):
public ByteBuffer toBytes(BigDecimal value, Schema schema, LogicalType type)
{
int scale = ((LogicalTypes.Decimal) type).getScale();
if (scale != value.scale()) {
throw new AvroTypeException("Cannot encode decimal with scale " +
value.scale() + " as scale " + scale);
}
return ByteBuffer.wrap(value.unscaledValue().toByteArray());
}
BigDecimal BigInteger Javadoc, , value.unscaledValue().toByteArray() .
, : return new BigDecimal(new BigInteger(bytes), scale);
?
, Avro 1.7, . () , . - , Avro .
Avro 1.8.0-rc2 . , (de) (. Conversion Conversions) GenericData. , BigDecimal, . ReflectData , ( AFAIK ).
, avro-/codegen .