Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Considerations and Techniques for Saving Large Amounts of Data

Considerations and Techniques for Saving Large Amounts of Data
Thread Tools
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jan 30, 2004, 12:36 PM
 
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
Reply With Quote
Jan 30, 2004, 01:17 PM
 
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
Reply With Quote
Jan 30, 2004, 01:19 PM
 
But how does iCal do it? They certainly don't use a database.
     
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Jan 30, 2004, 03:45 PM
 
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
Reply With Quote
Jan 31, 2004, 02:51 AM
 
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
Reply With Quote
Feb 2, 2004, 12:54 AM
 
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
Reply With Quote
Feb 2, 2004, 03:02 AM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2