jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.89k stars 873 forks source link

How to properly setup Map<String, Object> #914

Closed zepernick closed 5 years ago

zepernick commented 6 years ago

First off, thank you for all your time and great work on this project!

I have a situation where I want to create a <String, Object> map for various application statistics. The map may contains dates, strings, int, etc. I have not been able to get it to compile when specifying the generics on the Map declaration

Map<String, Object> applicationStatsMap = db.hashMap("applicationStats");

I have tried to figure out what I can pass as a Serailizer. I can do Serializer.STRING for the key but am at a loss as to what to pass for the value. Is this possible?

allanwax commented 6 years ago

I don't know if this will work but try using Serializer.BYTE_ARRAY. But this may need you to serialize the object first. I've never tried this myself.