 |
 |
Considerations and Techniques for Saving Large Amounts of Data
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Hi,
I have a few application 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 save events, as soon as the user creates them, the to a .ics files, 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.
~Ian
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by macrophyllum:
Hi,
I have a few application 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.
Sounds like you might want to consider a database.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
But how does iCal do it? They certainly don't use a database.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Perhaps using NSArchiver and auto-saving every time an array or dictionary is added?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
You could do something like what (I assume) Entourage X does. Store both the entry and its array position in your flat file. When an entry is changed, if the new entry uses the same number of bytes as the old one, replace the existing record. If not, mark the old entry as invalid and append the new entry to the end of the flat file. When a new entry is inserted into the middle of the array, just append the entry to the end of your flat file (it contains the location, so no problem). When an entry is removed, mark it is invalid in your flat file.
Periodically, you'll need to compact the flat file to remove the invalid entries for things that were removed.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I am not so good with terminology. What is a "flat file", do you mean the file that will be read and written to disk?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
Originally posted by macrophyllum:
I am not so good with terminology. What is a "flat file", do you mean the file that will be read and written to disk?
Yeah, as opposed to a directory or something like a resource-fork file.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|