discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyed Archiver and partial information retrieval


From: Richard Frith-Macdonald
Subject: Re: Keyed Archiver and partial information retrieval
Date: Sat, 7 Feb 2004 16:35:17 +0000


On 7 Feb 2004, at 15:42, Stefan Urbanek wrote:

Hi,

I have a question about keyed archiver in GNUstep. One of disadvantages of NSCoding protocol is, that I can not get partial information from the archive and i have to load and read whole data. Sometimes there are situations, that I would like to know only one value from the archive. Does (will) NSKeyedArchiver get only value for key I request or it does load the whole data?

It can be very handy for large archves, where user can store information about data stored and then be able to retrieve only those data. Concrete example:

In AgentFarms I would like to store simulation state and several other objects like collections of data in archive. Simulation state can be quite big (all simulated objects are stored), also the collected data can be large. There are situations, where i would like to 'peek' into the stored simulation to get essential information about saved state, like simulation time, model used, 'thumbnail' of the state, etc... Moreover, sometimes it is not possible to read whole archive, because it may contain classes that are just going to be loaded from bundles. (and i do not want to load them if i do not know whether they wil be used or not)Currently I am going to solve this problem by using two files: archive and property list. However, this solution requires directory-like storage and is not very practical. Keyed archive would be excellent solution for this problem, if GNUstep is/was able to fetch only several objects from the archive. Root object keys would be sufficient.

Is this feature implemented or planned?

The NSKeyedArchiver API allows you to retrieve only those items you want ... but that doesn't mean that only parts are read in. It reads the entire archive and then walks through it extracting the elements it is asked for.

The primary motivation for implementing this was coding compatibility with MacOS-X so that an archive written by GNUstep can be read on MacOS-X and vice versa ... so the archive format is the same as MacOS-X and it's probably not reasonably possible
to perform incremental reads.

The setClass:forClassName: method can be used to easily cope with the case where you don't actually want to instantiate instances of objects that would need to be loaded from bundles... so that's not a problem... but I think avoiding loading the whole data would be trickier. I think for high volume data the two file solution would be best, where the objects containing a lot of data would append the data to one file, and encode themselves as the size and offset to the data. On decoding these objects could just decode the size and offset, and leave retrieval of the actual data until later.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]