java - Fast Static Persisted Hash Table -


My application in Java requires a hash table to calculate it and look for crores in this hash table. The hash table should be very fast readable in the hashtable utility from the disk and the data is static in the table and it is not necessary to insert or delete it.

Do you recommend using any available lib to do this?

In addition, the size of the data is less than 200 MB.

If you do not have a human readable requirement, you can ensure that your data serializable interface is applicable And does the serialing of Hashim using the ObjectOutputstream. It's ugly but this work will be completed.

Another option would be DataInputStream and DataOutputStream allow you to write / write structured binary data.

Assume that you have a hashmap, you can write it like this:

  // realOutputStream probably should be a buffer-optup stream data outputTream output = new dataoutputstream (actual output Stream); (Map. Entry & lt; long, string & gt; entry: map.entrySet ()) {// Write the key output. Written line (entry.getKey). LongValue ()); Byte Bites [] = Entry Bytes ("UTF-8"); // string writing requires writing length and then bytes output. WriteInt (bytes.length); Output. Written (bytes, 0, bytes length); } // realInputStream should probably have a Buffered InputStream DataInputStream input = New DataInputStream (realInputStream); Maps & lt; Long, string & gt; Map = new hashmop & lt; Long, string & gt; (); While {true} {try {// key long key = output read. // Read the length of the string in byte int strlen = output.readInt (); Read the // bytes in an array byte buff [] = new byte [strangle]; Output.readFully (buf, 0, strlen); // Create map entry Map.put (long.view (key), new string (buff, "UTF-8")); } Hold (EOFException e) {// input is finished; }}   

Keep in mind it is assuming that you want to store and read the string as a UTF. You can not easily supply a character set and can not use jvm default encoding. Also keep in mind that with variable length like a string, you will need to write the length of that data before writing actual data. This is because you know how many bytes to read in order to reconstruct that string.

Comments