문제

I have an object which I want to convert into a stream of bytes and then to operate on it. I don't want to serialise the object, but just to convert it. I have read this article, where Java Unsafe class is used and the conversion is very fast. However, is there any other fast solution for this?

도움이 되었습니까?

해결책 2

There are a number of libraries in development to do what you suggest. I believe all of them are discussed on this forum. https://groups.google.com/forum/#!forum/mechanical-sympathy which may also have many topics which may interest you.

In short you can do it using Unsafe, or a library which uses it. In fact I have one of my own, but again it is in development.

For the effort involved this will only make much of a difference if you have many GB of data. At this point the reduce GC times and reduced size of the heap are the main advantages, on saving a single de-reference.

다른 팁

Fast Convertion is possible. You can use GSON lib. then get it to json string. Use the string as per your requirement. Hope this helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top