@Override public int estimateByteSize(Object o) { if (o == null) { return 1; } BigDecimal v = (BigDecimal) o; // TODO: should we strip zeros and round here too? return Math.min(getLength(v), MAX_BIG_DECIMAL_BYTES); }
@Override public byte[] toBytes(Object object) { if (object == null) { return ByteUtil.EMPTY_BYTE_ARRAY; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); byte[] result = new byte[Math.min(len, MAX_BIG_DECIMAL_BYTES)]; PDataType.toBytes(v, result, 0, len); return result; }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { return 0; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); return PDataType.toBytes(v, bytes, offset, len); }
@Override public int estimateByteSize(Object o) { if (o == null) { return 1; } BigDecimal v = (BigDecimal) o; // TODO: should we strip zeros and round here too? return Math.min(getLength(v), MAX_BIG_DECIMAL_BYTES); }
@Override public int estimateByteSize(Object o) { if (o == null) { return 1; } BigDecimal v = (BigDecimal) o; // TODO: should we strip zeros and round here too? return Math.min(getLength(v), MAX_BIG_DECIMAL_BYTES); }
@Override public byte[] toBytes(Object object) { if (object == null) { return ByteUtil.EMPTY_BYTE_ARRAY; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); byte[] result = new byte[Math.min(len, MAX_BIG_DECIMAL_BYTES)]; PDataType.toBytes(v, result, 0, len); return result; }
@Override public byte[] toBytes(Object object) { if (object == null) { return ByteUtil.EMPTY_BYTE_ARRAY; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); byte[] result = new byte[Math.min(len, MAX_BIG_DECIMAL_BYTES)]; PDataType.toBytes(v, result, 0, len); return result; }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { return 0; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); return PDataType.toBytes(v, bytes, offset, len); }
@Override public int toBytes(Object object, byte[] bytes, int offset) { if (object == null) { return 0; } BigDecimal v = (BigDecimal) object; v = NumberUtil.normalize(v); int len = getLength(v); return PDataType.toBytes(v, bytes, offset, len); }