Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-4218

Data Block Encoding of KeyValues (aka delta encoding / prefix compression

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.94.0
    • Fix Version/s: 0.94.0
    • Component/s: io
    • Labels:
    • Hadoop Flags:
      Reviewed
    • Release Note:
      Hide
      Adds a block compression that stores the diff from the previous key only. Good for big keys and small value datasets. Makes writing and scanning slower but because the blocks compressed with this feature stay compressed when in memory up in the block cache, more data is cached. Off by default (DATA_BLOCK_ENCODING=NONE on column descriptor). To enable, set DATA_BLOCK_ENCODING to PREFIX, DIFF or FAST_DIFF on the column descriptor. Set ENCODE_ON_DISK to true on column descriptor to have the encoding in place out in the hfile (on by default).
      Show
      Adds a block compression that stores the diff from the previous key only. Good for big keys and small value datasets. Makes writing and scanning slower but because the blocks compressed with this feature stay compressed when in memory up in the block cache, more data is cached. Off by default (DATA_BLOCK_ENCODING=NONE on column descriptor). To enable, set DATA_BLOCK_ENCODING to PREFIX, DIFF or FAST_DIFF on the column descriptor. Set ENCODE_ON_DISK to true on column descriptor to have the encoding in place out in the hfile (on by default).

      Description

      A compression for keys. Keys are sorted in HFile and they are usually very similar. Because of that, it is possible to design better compression than general purpose algorithms,

      It is an additional step designed to be used in memory. It aims to save memory in cache as well as speeding seeks within HFileBlocks. It should improve performance a lot, if key lengths are larger than value lengths. For example, it makes a lot of sense to use it when value is a counter.

      Initial tests on real data (key length = ~ 90 bytes , value length = 8 bytes) shows that I could achieve decent level of compression:
      key compression ratio: 92%
      total compression ratio: 85%
      LZO on the same data: 85%
      LZO after delta encoding: 91%
      While having much better performance (20-80% faster decompression ratio than LZO). Moreover, it should allow far more efficient seeking which should improve performance a bit.

      It seems that a simple compression algorithms are good enough. Most of the savings are due to prefix compression, int128 encoding, timestamp diffs and bitfields to avoid duplication. That way, comparisons of compressed data can be much faster than a byte comparator (thanks to prefix compression and bitfields).

      In order to implement it in HBase two important changes in design will be needed:
      -solidify interface to HFileBlock / HFileReader Scanner to provide seeking and iterating; access to uncompressed buffer in HFileBlock will have bad performance
      -extend comparators to support comparison assuming that N first bytes are equal (or some fields are equal)

      Link to a discussion about something similar:
      http://search-hadoop.com/m/5aqGXJEnaD1/hbase+windows&subj=Re+prefix+compression

        Attachments

        1. 0001-Delta-encoding.patch
          409 kB
          Mikhail Bautin
        2. 0001-Delta-encoding-fixed-encoded-scanners.patch
          379 kB
          Mikhail Bautin
        3. 4218.txt
          402 kB
          Ted Yu
        4. 4218-2012-01-14.txt
          479 kB
          Ted Yu
        5. 4218-v16.txt
          407 kB
          Ted Yu
        6. ASF.LICENSE.NOT.GRANTED--D1659.1.patch
          469 kB
          Phabricator
        7. ASF.LICENSE.NOT.GRANTED--D1659.2.patch
          471 kB
          Phabricator
        8. ASF.LICENSE.NOT.GRANTED--D1659.3.patch
          471 kB
          Phabricator
        9. ASF.LICENSE.NOT.GRANTED--D447.1.patch
          371 kB
          Phabricator
        10. ASF.LICENSE.NOT.GRANTED--D447.10.patch
          372 kB
          Phabricator
        11. ASF.LICENSE.NOT.GRANTED--D447.11.patch
          389 kB
          Phabricator
        12. ASF.LICENSE.NOT.GRANTED--D447.12.patch
          388 kB
          Phabricator
        13. ASF.LICENSE.NOT.GRANTED--D447.13.patch
          389 kB
          Phabricator
        14. ASF.LICENSE.NOT.GRANTED--D447.14.patch
          387 kB
          Phabricator
        15. ASF.LICENSE.NOT.GRANTED--D447.15.patch
          385 kB
          Phabricator
        16. ASF.LICENSE.NOT.GRANTED--D447.16.patch
          407 kB
          Phabricator
        17. ASF.LICENSE.NOT.GRANTED--D447.17.patch
          402 kB
          Phabricator
        18. ASF.LICENSE.NOT.GRANTED--D447.18.patch
          414 kB
          Phabricator
        19. ASF.LICENSE.NOT.GRANTED--D447.19.patch
          414 kB
          Phabricator
        20. ASF.LICENSE.NOT.GRANTED--D447.2.patch
          357 kB
          Phabricator
        21. ASF.LICENSE.NOT.GRANTED--D447.20.patch
          419 kB
          Phabricator
        22. ASF.LICENSE.NOT.GRANTED--D447.21.patch
          419 kB
          Phabricator
        23. ASF.LICENSE.NOT.GRANTED--D447.22.patch
          438 kB
          Phabricator
        24. ASF.LICENSE.NOT.GRANTED--D447.23.patch
          479 kB
          Phabricator
        25. ASF.LICENSE.NOT.GRANTED--D447.24.patch
          473 kB
          Phabricator
        26. ASF.LICENSE.NOT.GRANTED--D447.25.patch
          486 kB
          Phabricator
        27. ASF.LICENSE.NOT.GRANTED--D447.26.patch
          487 kB
          Phabricator
        28. ASF.LICENSE.NOT.GRANTED--D447.3.patch
          358 kB
          Phabricator
        29. ASF.LICENSE.NOT.GRANTED--D447.4.patch
          327 kB
          Phabricator
        30. ASF.LICENSE.NOT.GRANTED--D447.5.patch
          357 kB
          Phabricator
        31. ASF.LICENSE.NOT.GRANTED--D447.6.patch
          359 kB
          Phabricator
        32. ASF.LICENSE.NOT.GRANTED--D447.7.patch
          360 kB
          Phabricator
        33. ASF.LICENSE.NOT.GRANTED--D447.8.patch
          370 kB
          Phabricator
        34. ASF.LICENSE.NOT.GRANTED--D447.9.patch
          372 kB
          Phabricator
        35. Data-block-encoding-2011-12-23.patch
          409 kB
          Ted Yu
        36. Delta_encoding_with_memstore_TS.patch
          376 kB
          Mikhail Bautin
        37. Delta-encoding.patch-2011-12-22_11_52_07.patch
          409 kB
          Mikhail Bautin
        38. Delta-encoding.patch-2012-01-05_15_16_43.patch
          439 kB
          Mikhail Bautin
        39. Delta-encoding.patch-2012-01-05_16_31_44_copy.patch
          439 kB
          Mikhail Bautin
        40. Delta-encoding.patch-2012-01-05_16_31_44.patch
          439 kB
          Mikhail Bautin
        41. Delta-encoding.patch-2012-01-05_18_50_47.patch
          444 kB
          Mikhail Bautin
        42. Delta-encoding.patch-2012-01-07_14_12_48.patch
          444 kB
          Mikhail Bautin
        43. Delta-encoding.patch-2012-01-13_12_20_07.patch
          464 kB
          Mikhail Bautin
        44. Delta-encoding-2012-01-17_11_09_09.patch
          499 kB
          Mikhail Bautin
        45. Delta-encoding-2012-01-25_00_45_29.patch
          513 kB
          Mikhail Bautin
        46. Delta-encoding-2012-01-25_16_32_14.patch
          514 kB
          Mikhail Bautin
        47. open-source.diff
          340 kB
          Jacek Migdal

          Issue Links

            Activity

              People

              • Assignee:
                mikhail Mikhail Bautin
                Reporter:
                jmigdal Jacek Migdal
              • Votes:
                1 Vote for this issue
                Watchers:
                27 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: