コード例 #1
0
 @Override
 public void write(final ObjectDataOutput out, final BigDecimal obj) throws IOException {
   BigInteger bigInt = obj.unscaledValue();
   int scale = obj.scale();
   bigIntegerSerializer.write(out, bigInt);
   out.writeInt(scale);
 }
コード例 #2
0
 public void write(Kryo kryo, Output output, BigDecimal object) {
   if (object == null) {
     output.writeVarInt(NULL, true);
     return;
   }
   BigDecimal value = (BigDecimal) object;
   // fast-path optimizations for BigDecimal constants
   if (value == BigDecimal.ZERO) {
     bigIntegerSerializer.write(kryo, output, BigInteger.ZERO);
     output.writeInt(0, false); // for backwards compatibility
     return;
   }
   // default behaviour
   bigIntegerSerializer.write(kryo, output, value.unscaledValue());
   output.writeInt(value.scale(), false);
 }