|
-
FK founder & general loiterer
best way to store 'ghost racer' data
Has anyone had to come up against the need to store in a database a large array of data. Im recording lap data for ghost riders, and the resulting textfiles as pure array data are 60-100k (thats a sample every 100 - 200 ms)
I am thinking that Ill take this data array and maybe use a byteArray compression on it and then whack it into my mysql database as binary data.
But I havent the foggiest as to how to go about it..... 
Any suggestions on a best practice for this most gratefully accepted
Last edited by Flashkit; 08-15-2008 at 02:40 AM.
-
FK founder & general loiterer
With some in depth googling I have found this to try.....
http://www.sephiroth.it/phpwiki/inde...earray_as_Blob
-
Hype over content...
I dunno if that link's sorted your problems or not mate.
Failing that, Run Length Encoding could save a lot ( You may have to split the data up into different streams, so say the speed in one stream which may compress well, and the "movement", ie rotation, in another. For the rotation delta encoding may be better, so you just save the differences, ie <timestamp><change in degrees>, although RLE would be sucky on that, hence the two streams ).
Also how about the storing the data in a bitmap, and letting a png encoder pack it all down for you ?
Squize.
-
if the user can't interact with the ghost and the simulation is tied to the framerate, you can just store input changes and the frame at which they occur instead of sampling repeatedly.
-
maybe check the angle from the last capture position to the current one and if it is equal or within a smal rangle like say 2° or 3° skip it and dont save it. But that way you would also have to store the timestamp or some skip number with each position or skip.
Binary data is indeed the way to go,- even reading will be very easy
it might something look like this:
PHP Code:
var binaryData:ByteArray = ... // data loaded externally into a byte array
var length = binaryData.readShort();
var x:int,y:int,time:int;
for(var i:int = 0; i < length; i++) {
x = binaryData.readShort();
y = binaryData.readShort();
time = binaryData.readShort();
}
writing in AS3 might be something like:
PHP Code:
var binaryData:ByteArray = new ByteArray();
binaryData.writeShort(ghosting.length);//array length
for(var i:int = 0; i < length; i++) {
binaryData.writeShort(ghosting[i].x);
binaryData.writeShort(ghosting[i].y);
binaryData.writeShort(ghosting[i].time);
}
look up the "ByteArray" class in the CS3 help (or online) because for example writeShort and writeInt are not the same (16 vs 32 bit)
some as3 binary links:
http://mikegrundvig.blogspot.com/200...ta-in-as3.html
http://www.kaourantin.net/2005/10/pn...er-in-as3.html
-
Script kiddie
I would give each arrow key its own binary stream, and use RLE to compress them. Simple, accurate, and small.
-
FK founder & general loiterer
I am using a bytearray indeed with the writeshorts.
I had hoped to use amfphp to save them as blobs in a mysql database, but no matter what I tried it borked, so I make a bytearray, compress it and then turn it into a base64 string.
All up it takes a 60k file down to 1k which is pretty sweet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|