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

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

    XMLWordPrintableJSON

Details

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

        Issue Links

          Activity

            People

              mikhail Mikhail Gryzykhin
              jmigdal Jacek Migdal
              Votes:
              1 Vote for this issue
              Watchers:
              26 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: