I am using MapDB, and attempting to create a direct-memory map, using long-arrays as keys, and I am getting the following error:
java.lang.ClassCastException: [J cannot be cast to [B
at org.mapdb.Hasher$2.hashCode(Hasher.java:46)
at org.mapdb.HTreeMap.hash(HTreeMap.java:954)
at org.mapdb.HTreeMap.get(HTreeMap.java:390)
My code is:
Map<long[],LongBitsWrapper> inUseMap;
DB db = DBMaker
.newMemoryDirectDB()
.transactionDisable()
.asyncWriteFlushDelay( 100 )
.make();
HTreeMapMaker maker =
db.createHashMap( "longBitsInUseMap" )
.hasher( Hasher.BYTE_ARRAY )
.keySerializer( Serializer.BYTE_ARRAY );
inUseMap = maker.makeOrGet();
Any idea what I am doing wrong?
The map keys are of type long[]
(binary name [J
) but you're trying to use a hasher that works with byte[]
([B
). Try using Hasher.LONG_ARRAY
instead.