質問

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