0

I am not familiar with databases and I usually benefit from memory and data structures such as Maps. However right now my data is huge and by reading it into memory it quickly overflows and then the system entirely freezes (linux 12.04 LTS).

So I thought maybe database is a good idea, however I need a quick and straightforward way of implementing and accessing it. It should also be a fast type of database. For instance Kyoto or something similar.

So I'd like to put the following data in database:

HashMap<String, List> Index = new HashMap<String,List>();
List<String> sentences = new List<String>();

and then access them this way: Access by key for the hashmap, and access by List index for the List.

Thanks in advance!

MAZDAK
  • 573
  • 1
  • 4
  • 16
  • you need to do some learning about how database works in java, there is no such hard and fast solution for your problem. – Abubakkar Apr 15 '13 at 09:35

2 Answers2

0

Usually for accessing data in the form of key-value pairs as you seem to need a solution like Memcached is used.
But if the problem is the memory size you could "simulate" a hashmap in a relational db.
This seems similar to storing hashmap in SQL

Community
  • 1
  • 1
Cratylus
  • 52,998
  • 69
  • 209
  • 339
0

You could make your own implementation by extending HashMap class and adding the methods you need:

  • persist() , loads into the db the current records from the HashMap
  • retrieve(int limit) , retrieves from the db the records with a limit

etc.

For db layer you could use REDIS its ideal for what you want

Stephan
  • 8,000
  • 3
  • 36
  • 42