Stream Indirection

The first thing to understand when allocating storage is that is a two-stage process. The initial request will return a PSOutputStream which should be written to as any other java OutputStream.

Once all the data has been written to the stream, the PSOutputStream method save should be called, for example:

IStore store = new RWStore("somestore.rw", 0);

store.startTransaction();

PSOutputStream outstr = store.realloc(0);
ObjectOutputStream obout = new ObjectOutputStream(outstr);

obout.writeInt(someInt);
obout.writeObject("some string");

obout.flush();

int addr = outstr.save();

store.commitTransaction();

save will return the address at which the data has been written and can later be used to retrieve it.

You should also note the use of the startTransaction and commitTransaction methods.