ptupitsyn commented on code in PR #3493:
URL: https://github.com/apache/ignite-3/pull/3493#discussion_r1542370656
##########
modules/binary-tuple/src/main/java/org/apache/ignite/internal/binarytuple/BinaryTupleBuilder.java:
##########
@@ -315,8 +315,19 @@ public BinaryTupleBuilder appendNumber(BigInteger value) {
* @return {@code this} for chaining.
*/
public BinaryTupleBuilder appendDecimalNotNull(BigDecimal value, int
scale) {
- // TODO IGNITE-21745: Inefficient serialization, many bytes wasted to
store small values when scale is big.
- putBytes(value.setScale(scale,
RoundingMode.HALF_UP).unscaledValue().toByteArray());
+ if (value.scale() > scale) {
+ value = value.setScale(scale, RoundingMode.HALF_UP);
+ }
+
+ value = value.stripTrailingZeros();
+
+ // See CatalogUtils.MAX_DECIMAL_SCALE = Short.MAX_VALUE
+ assert value.scale() <= Short.MAX_VALUE : "Decimal scale is too large:
" + value.scale() + " > " + Short.MAX_VALUE;
+ assert value.scale() >= Short.MIN_VALUE : "Decimal scale is too small:
" + value.scale() + " < " + Short.MIN_VALUE;
Review Comment:
Agree. Replaced with exceptions, added test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]