fun readFrameAsByteArray(tailer: ExcerptTailer): ByteArray {
// read next message size
val result = ByteArray(tailer.readInt())
// read message content
tailer.read(result)
tailer.finish()
return result
}
fun writeByteArrayFrame(appender: ExcerptAppender, data: ByteArray) : Long{
// current index we write to
val index = appender.index()
// calculate total message size
val msgSize = 4 + data.size
appender.startExcerpt(msgSize.toLong())
// write length of the message
appender.writeInt(data.size)
// write message content
appender.write(data)
appender.finish()
return index
}
fun readFrameAsByteString(tailer: ExcerptTailer): ByteString {
// todo
}
fun writeByteStringFrame(appender: ExcerptAppender, data: ByteString) : Long{
// todo
}
I would use Chronicle Queue v4. Indexed Chronicle would pad some messages which why the length might be required.
Queue v4 doesn't do this. It also supports reading to/from a byte [] with a length so you can reuse a byte [] and avoid garbage.
It also supports deserialization of reused mutable objects without the need for generated code so you don't create any garbage end to end.
Regards, Peter.
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
As you are writing raw data, most likely you want to use.
appender.writeBytes(bytes);
or you can use any combination of Bytes methods eg.
appender.writeBytes(b -> b.write(bytesArray));