Ar an dara lá is fiche de mí na Samhain, scríobh Zajcev Evgeny:
Hello guys, here is my problem that i have no ideas how to solve.
I have really HUGE hash table that builds on (S)XEmacs start from text
file. That takes really long time and annoys much. What i want is
somehow serialize this hash table and save to file, so on start i just
need read this file and deserialize data back to hash table, which i
believe will be much faster than building it from text file.
is there any known methods to do this task?
(with-temp-buffer
(princ ";; -*- coding: escape-quoted -*-\n")
(princ "(setq desired-hash-table-variable-name ")
(let ((print-readably t))
(prin1 really-huge-hash-table))
(princ ")\n")
(write-file "desired-output-file-name" nil 'escape-quoted))
To load the data, you would just call #'load on the file. Alternatively:
(let ((database-handle (open-database
"desired-output-database-name"
'berkeley-db nil "rw+" #o644)))
(maphash #'(lambda (key value) (put-database
(encode-coding-string key 'koi8-r)
(encode-coding-string value 'koi8-r)
database-handle t))
really-huge-hash-table)
(close-database database-handle))
You would need to call #'get-database and #'decode-coding-string to do the
lookup, though.
If no, what is the best aproaches you see in order to implement
this?
for someone who is interested in details: my hash is table of russian
words that contains YO[1] and i use this table to perform automatic
YOfication of the text.
thanks
Footnotes:
[1]
http://en.wikipedia.org/wiki/%D0%81
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghé, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta