Searching db on both key and value? (bi-directional approach)

41 views
Skip to first unread message

Harit Himanshu

unread,
Oct 5, 2015, 1:24:47 PM10/5/15
to leveldb
Hello there


I am new to LevelDB, and exploring it since the project I started to work on is using it.
We have started hitting situations where we store too much data and I started looking into what we do at our application level.

String key = // generated from somewhere
String hashedKey = // encrypt key and save

mapDb.put(key, hashedKey)
decryptMapDb(hashKey, key)


Our key and hashedKey both are unique

The reason we put it there is application specific but we need to keep both key and hashedKey searchable. As we could see that we store same data twice to make sure we could search both ways.
I was looking for a way to reduce this storage if leveldb has a bi-directional search.

I started looking but the one I found was BidiMap in Google Collections Library

Questions
  1. Is there a BiDirectionalMap so that I save my data just once?
  2. What are other alternatives/recommendations?

Thank you in advance
+ Harit Himanshu

Reply all
Reply to author
Forward
0 new messages