简体   繁体   中英

Best way to encode data

I have huge amount of data in my database whith format :

lat;lon;speed;sec:lat;lon;speed;sec......

for example:

 53.284534;50.227268;67;0:53.285481;50.226627;68;6:53.286429;50.226042;66;12:.......

format is lattitude, longitude, speed, number of second from beginning. length of each string is from 1000 to 100000. I try to compress it before putting in database via gzcompress() and base64_encode(). In case of length of initial string 7607 symbols after gzcompress and base64_encode it will be 3444, so compression is 50%. Is any more effective way to compress strings like this?

Try just storing them as binary floats. This is very simple and it's very fast. Each number would use 4 bytes and that would make it possible to use them directly from within your code.

Or if you need them more precise, multiply each component by a pre-definied value (which may differ for each component), and store as 32-bit integer words.

There is clearly a strong correlation from sample to sample. I would subtract from each sample the previous sample, except of course for the first one. I would encode each difference as an integer of variable length (not as text but in binary). For lat and long I would multiply by 1,000,000 on the assumption (which you need to verify) that there are never more than six digits after the decimal. The second and third samples would each require only six bytes.

Then would I compress with gzip.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM