You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Pereslegin (Jira)" <ji...@apache.org> on 2024/05/08 08:26:00 UTC

[jira] (IGNITE-22061) Use compact representation of BigDecimal with large scale for integers / numbers with trailing zeros

    [ https://issues.apache.org/jira/browse/IGNITE-22061 ]


    Pavel Pereslegin deleted comment on IGNITE-22061:
    -------------------------------------------

was (Author: xtern):
Looks like this issue is fixed in IGNITE-21745
The following test case now passes successfully.

{code:java}
int scale = Short.MAX_VALUE;
BigDecimal value = new BigDecimal("10").setScale(scale, RoundingMode.HALF_UP);
ByteBuffer bytes = new BinaryTupleBuilder(1).appendDecimal(value, scale).build();

assertEquals(5, bytes.limit());
{code}


> Use compact representation of BigDecimal with large scale for integers / numbers with trailing zeros
> ----------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-22061
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22061
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>
> BigDecimals that represent integer numbers can take up a lot of space, when scale is specified:
> {code:java}
> BigDecimal dc = new BigDecimal("11111111").setScale(1024, RoundingMode.HALF_UP);
> System.out.println("Difference:");
> System.out.println(MarshallerUtil.sizeInBytes(dc) - dc.stripTrailingZeros().setScale(0, RoundingMode.HALF_UP).unscaledValue().toByteArray().length);
> {code}
> The code prints:
> {code}
> Difference:
> 427
> {code}
> Let's update BinaryTuple format to store such numbers in more compact form that does not store trailing zeros.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)