Squishing data

Shari gypsyware at earthlink.net
Thu Aug 28 08:30:01 EDT 2003


>In response to Brian and Xavier...


Data Part 1 - The Array ...

Yes, I created the array and saved it as customProperties.  Half the 
data from the data stack needs to be in an array, and the array holds 
at least 283,800 separate pieces of data, called with myArray[x,y] 
(there are two parameters for each piece of data)

One piece of data holds 13 smaller pieces of data.  So initially I 
had tried myArray[x,y,1]   myArray[x,y,2]  etc. but the ending result 
was a stack that was 65 MB, that started at 13 MB!  I think it held 
about 3.5 million elements.

So I settled on not divvying up the 13 smaller pieces.  That is 
acceptable, as I don't believe getting item 1-13 of myArray[x,y] will 
pose a speed threat (haven't tested it yet though).  For this array, 
speed is CRITICAL and even a fraction of a second makes a difference.

As only one of the 13 smaller pieces will always have data, and the 
other 12 could be empty, I considered building the array using only 
the data that wasn't empty.  myArray[x,y,1]  [x,y,2]  [x,y,10]  if 
items 3-9 were empty, they wouldn't exist.  But I'm guessing that 
turning myArray[x,y] into myArray[several elements] would bump both 
the memory needs and disk space.

When you first load the program, it goes and gets the stored array, 
and puts it into a global variable.

Data Part 2 - The Stored Data ...

That left half a stack of data to figure out how to store and call 
up.  Everything in the stack is on one card.  The user will never 
"see" the stack, so it isn't pretty.  Just data storage.  So calling 
up the data should not take long.  At any given time, one of the 300 
fields needs to be in memory.  And as the user does things, this 
block of data will be replaced with another block from another field.

So it would presumably have to decompress whenever it changed out the 
data (which could be as often as once a minute, depending on what the 
user is doing, or as infrequently as once in five minutes).

If it were instantaneous, I'd let it read this part of the data from 
the data stack, rather than store block of data in memory.  Get line 
10 of fld whatEver of cd 1 of stack dataStorage.  But I doubt it 
wouldn't be quick enough.  (though I haven't tried it this way yet)

It makes the most sense to have a global variable, that will have one 
of the 300 fields in it, at any given time.  The code will always 
refer to line 10 of something, under these conditions, and line 234 
of something, under those conditions.  So having one something as the 
global variable (or array) makes sense.

I haven't tested it to see how long it would take to build an array 
on the fly, from the 300 fields.  put line 5 of fld 200 into 
dataArray[5]  repeat for each of the 1000 lines or so in the field...

I will experiment with the compression, and see what I can do with it.

Thank you, both!

(Yup, it's a rather windy post... but the more info you guys have, 
the more likely you might have some thoughts for me :-)

Shari







-- 
--Shareware Games for the Mac--
http://www.gypsyware.com



More information about the metacard mailing list