compression algorithm for sorted integers

后端 未结 6 1881
我寻月下人不归
我寻月下人不归 2020-12-09 11:12

I have a large sequence of random integers sorted from the lowest to the highest. The numbers start from 1 bit and end near 45 bits. In the beginning of the list I have numb

6条回答
  •  孤城傲影
    2020-12-09 12:14

    One option that worked well for me in the past was to store a list of 64-bit integers as 8 different lists of 8-bit values. You store the high 8 bits of the numbers, then the next 8 bits, etc. For example, say you have the following 32-bit numbers:

    0x12345678
    0x12349785
    0x13111111
    0x13444444
    

    The data stored would be (in hex):

    12,12,13,13
    34,34,11,44
    56,97,11,44
    78,85,11,44
    

    I then ran that through the deflate compressor.

    I don't recall what compression ratios I was able to achieve with this, but it was significantly better than compressing the numbers themselves.

提交回复
热议问题