Re: Newbie Q:Considerations/Techniques for Saving Large Amounts of Data
Re: Newbie Q:Considerations/Techniques for Saving Large Amounts of Data
- Subject: Re: Newbie Q:Considerations/Techniques for Saving Large Amounts of Data
- From: Glen Low <email@hidden>
- Date: Sat, 31 Jan 2004 08:54:59 +0800
My question is this, without implementing a database, how can I write
large data files to disk efficiently? Read below for more details.
I have a few applications which need to save thousands of objects in
arrays. What's more, is that each time the user uses the program they
will likely add more objects to different arrays, making the data
structure larger and larger and thus writing the file to disk will
take
longer and longer.
I have noticed that iCal saves events as soon as the user creates
them,
to a .ics file, but you never notice it saving. Maybe they have
another
thread do the saving, or maybe there is a way to just re-write part of
the file?
Any thoughts, help or tips are most welcome.
You could try memory-mapped files. Basically the OS treats a disk file
as if it were main memory, taking care of reading, writing and
buffering the data. OS X has the UNIX function mmap (C API) which does
this, and NSData has a dataWithContentsOfMappedFile: method. There are
some caveats, mainly that the data should be self-contained, and the
memory layout should be identical to the disk layout (otherwise there
is no advantage). I don't think you can simply stuff ObjC objects with
efficiency into a memory-mapped file.
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.