Is there a super fast compare byte[] method in Chronicle Bytes?

167 views Asked by At

I'm storing a Murmur3 64-bit hash as a byte array in a Chronicle bytes object. I trying to sort these keys as fast as physically possible. I implemented quick sort to do that. I noticed there a set of compare and swap methods but nothing for a byte array. Is there anything I can use to speed up my quick sort? Profiling indicated that most pressure is on net.openhft.chronicle.bytes.AbstractBytes.readCheckOffset(long, long, boolean) AbstractBytes.java

Thanks for any hints.

1

There are 1 answers

0
Peter Lawrey On

The fastest way to compare two byte[] would be to use Unsafe to read an int or a long from the underlying arrays (and swap the byte order if little endian) This would give you a very fast comparison.

For the most part, Chronicle Bytes is designed to make it either to work with off heap memory though it also supports on heap e.g. byte[].