You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by "steve.hostettler@gmail.com" <st...@gmail.com> on 2020/06/02 08:37:45 UTC

Ignite and Java 9+

Hello,

The method doWriteString(@Nullable String val) writes everything in UTF-8.
This is a bit a waste because with  Java 9+
<https://openjdk.java.net/jeps/254>  , strings are optimised and if all
chars are ISO-LATIN-1 all char are represented with 1 byte instead of two. I
would consider creating 2 type of strings : One with type 0x9 that behaves
as it does currently and another  0x39 that checks that s.getBytes().length
== s.length()

what do you think?



--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/

Re: Ignite and Java 9+

Posted by "steve.hostettler@gmail.com" <st...@gmail.com>.
Indeed, I misread the code and it already saves "str4e" on 5 bytes and
"str4€" on 7 bytes.
 Sorry for the waste of time.



--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/

Re: Ignite and Java 9+

Posted by Ivan Pavlukhin <vo...@gmail.com>.
A note. I assumed that we talk about BinaryWriterExImpl.doWriteString.

2020-06-02 12:52 GMT+03:00, Ivan Pavlukhin <vo...@gmail.com>:
> Hi Steve,
>
> Could you please describe in more details in what cases do you expect
> a profit? AFAIK UTF-8 requires 1 byte for Latin-1 characters.
>
> I did not learn in depth about aforementioned Java 9 compact strings
> but my understanding is that it is about reducing space taken by
> java.lang.String objects in a Java heap memory.
>
> 2020-06-02 11:37 GMT+03:00, steve.hostettler@gmail.com
> <st...@gmail.com>:
>> Hello,
>>
>> The method doWriteString(@Nullable String val) writes everything in
>> UTF-8.
>> This is a bit a waste because with  Java 9+
>> <https://openjdk.java.net/jeps/254>  , strings are optimised and if all
>> chars are ISO-LATIN-1 all char are represented with 1 byte instead of
>> two.
>> I
>> would consider creating 2 type of strings : One with type 0x9 that
>> behaves
>> as it does currently and another  0x39 that checks that
>> s.getBytes().length
>> == s.length()
>>
>> what do you think?
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>>
>
>
> --
>
> Best regards,
> Ivan Pavlukhin
>


-- 

Best regards,
Ivan Pavlukhin

Re: Ignite and Java 9+

Posted by Ivan Pavlukhin <vo...@gmail.com>.
Hi Steve,

Could you please describe in more details in what cases do you expect
a profit? AFAIK UTF-8 requires 1 byte for Latin-1 characters.

I did not learn in depth about aforementioned Java 9 compact strings
but my understanding is that it is about reducing space taken by
java.lang.String objects in a Java heap memory.

2020-06-02 11:37 GMT+03:00, steve.hostettler@gmail.com
<st...@gmail.com>:
> Hello,
>
> The method doWriteString(@Nullable String val) writes everything in UTF-8.
> This is a bit a waste because with  Java 9+
> <https://openjdk.java.net/jeps/254>  , strings are optimised and if all
> chars are ISO-LATIN-1 all char are represented with 1 byte instead of two.
> I
> would consider creating 2 type of strings : One with type 0x9 that behaves
> as it does currently and another  0x39 that checks that s.getBytes().length
> == s.length()
>
> what do you think?
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>


-- 

Best regards,
Ivan Pavlukhin