Some data are serialized to an outputstream via Chronicle Wire.
Object m = ... ;
OutputStream out = ... ;
WireType.RAW //
.apply(Bytes.elasticByteBuffer()) //
.getValueOut().object(m) //
.bytes().copyTo(out)
;
I want to get them back from an Inputstream.
InputStream in = ... ;
WireType.RAW
.apply(Bytes.elasticByteBuffer())
.getValueIn()
???
;
Object m = ???; // How to initialize m ?
How to read my initial object m
from in
?
There is an assumption you will have some idea of how long the data is and read it in one go. It is also assumed you will want to reuse the buffers to avoid creating garbage. To minimise latency data is typical read to/from NIO Channels.
I have raised an issue to create this example, Improve support for Input/OutputStream and non Marshallable objects https://github.com/OpenHFT/Chronicle-Wire/issues/111
This should do what you want efficiently without creating garbage each time.
You can then do the following
Sample code
This code is a lot simpler if your DTO extends
Marshallable
but this will work whether you extend an interface or not. i.e. you don't need to extend Serializable.Also if you know what the type will be you don't need to write it each time.
The helper classes above have been added to the latest SNAPSHOT