|
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/ |
|
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, [hidden email] <[hidden email]>: > 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 |
|
A note. I assumed that we talk about BinaryWriterExImpl.doWriteString.
2020-06-02 12:52 GMT+03:00, Ivan Pavlukhin <[hidden email]>: > 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, [hidden email] > <[hidden email]>: >> 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 |
|
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/ |
| Free forum by Nabble | Edit this page |
