[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: saving a numeric table to a disk file
- To: hmadorf@eso.org
- Subject: Re: saving a numeric table to a disk file
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Tue, 16 Jun 1992 10:05:49 -0500
- Cc: info-mcl
>Hi MCLers,
>
>I am working on a table management system for scientific
>applications. A table consists of a rectangular array of
>objects, typically 20 columns and 20,000 rows usually with floats.
>
>What I am looking for is a way to efficiently write such a table to
>disk and read it back into memory again in order to achieve
>persistency. In Fortran I would simply use an unformatted read/write.
>
>So far I have been using Lisp's print/format to create a .lisp
>ASCII file, which I compile and load later. This approach suffers
>from two inefficiencies: firstly when the ASCII representation is
>generated from the internal Lisp object representation, and secondly
>when I have to compile the file, which takes quite some time om the
>Mac.
>
>Any suggestions?
>
>Hans-Martin Adorf
One way is illustrated by the file "MCL Help Map.lisp" in the "Library"
folder. It saves a large hash table to a file. You could have a file
named "Save-*array*.lisp" containing the following code:
---------------------------------------------------------
; save-value.lisp
(in-package :ccl)
(setq *value* '#.*value*)
---------------------------------------------------------
Now, you can save and restore values to a fasl file as follows:
---------------------------------------------------------
; save-value-to-file.lisp
(in-package :ccl)
(export '(save-value-to-file read-value-from-file))
(defvar *value*)
(defparameter *save-value-source-file*
; Change to another directory if you like
"ccl:save-value.lisp")
(defun save-value-to-file (value file)
(let ((*value* value))
(compile-file *save-value-source-file*
:output-file file)))
(defun read-value-from-file (file)
(let ((*value* nil))
(load file)
*value*))