currently I'm working with an ArrayListMultiMap of Guave where I handle over 100.000 items. The key of the map is a byte array, the values are long.
Now I want to reduce the overhead.
My idea is to use only primitive collections and the hashmap of trove. So in the end each key (byte array) points to a primitive collection (primitive long set).
My question is how to use a byte array as key in a THashmap. In Guave I wrapped the byte array in a class, but this produces overhead.
thank you
You can use a
byte arrayas the key directly (no need to wrap it, etc.):Example output:
EDIT:
If you do not want identity-based keys then you can use
TByteArrayListinstead ofbyte[]. On my machine it has an overhead of 25 bytes per instance. If each of your 100,000 items/longs were stored in its ownTLongSeteach mapped to a uniquebyte arraythen this makes an overhead of 2.5 megabytes (25 bytes x 100,000). This seems acceptable to me as a worse-case-scenario but if you do want to avoid it then Rob Eden's answer with aTCustomHashMapseems the way to go.