[new] ObjectFiler in Squeak - Persistency of OrderedCollections

Bijan Parsia bparsia at email.unc.edu
Sun Jan 27 23:24:49 UTC 2002


On Sun, 27 Jan 2002, Martín Altobello wrote:

[snip]
> My question is: What's the Squeak implementation of "ObjectFiler" (as
> seen in SmalltalkExpress)? in Smalltalk Express we could save and
> retreive OrderedCollections from disk as follow:
> 
> test := ObjectFiler loadAllFromPathName: 'test.dat'.
> ObjectFiler dumpAll: test newFile:'c:\temp\test.dat'.
> 
> This was great because it allowed us to save OrderedCollections
> containing many different objects, etc.

There are many solutions. One I'm fond of is Mark's FileDictionary:

	http://minnow.cc.gatech.edu/squeak/512

	(First entry)

This is based on DataStream and ReferenceStream. If you look at the class
comment for ReferenceStream, you'll see the following example:

"""Here is the way to use DataStream and ReferenceStream:
	rr _ ReferenceStream fileNamed: 'test.obj'.
	rr nextPut: <your object>.
	rr close.

To get it back:
	rr _ ReferenceStream fileNamed: 'test.obj'.
	<your object> _ rr next.
	rr close."""

Yes make "your object" the OrderedCollection.

They have #nextPutAll: so

	[rr := ReferenceStream fileNamed: 'test.obj'.
	rr nextPutAll: <yourCollectionOfObjects>.] ensure: [rr close].

Will just put the contents of the OC. Not sure if that's preferable.

And then there are ImageSegments, of which I do not yet have sufficent
control. But they do seem a tad Project biased.

[snip]
> I apologize if this question is "off topic" or "newbie type", but I'd
> really apreaciate help on this.

It's a perfectly fine question.

With a bit more of a description of ObjectFiler, it should be able to
implement it pretty precisely, so your code would be portable, if that's
of interest.

Cheers,
Bijan Parsia.




More information about the Squeak-dev mailing list