列存储压缩技巧,除公共除数或者同时减去最小数,字符串压缩的话,直接去重后用数字ID压缩

简介:

Column-store compression

At a high level, doc values are essentially a serialized column-store. As we discussed in the last section, column-stores excel at certain operations because the data is naturally laid out in a fashion that is amenable to those queries.

But they also excel at compressing data, particularly numbers. This is important for both saving space on disk and for faster access. Modern CPU’s are many orders of magnitude faster than disk drives (although the gap is narrowing quickly with upcoming NVMe drives). That means it is often advantageous to minimize the amount of data that must be read from disk, even if it requires extra CPU cycles to decompress.

To see how it can help compression, take this set of doc values for a numeric field:

Doc      Terms
-----------------------------------------------------------------
Doc_1 | 100
Doc_2 | 1000
Doc_3 | 1500
Doc_4 | 1200
Doc_5 | 300
Doc_6 | 1900
Doc_7 | 4200
-----------------------------------------------------------------

The column-stride layout means we have a contiguous block of numbers:[100,1000,1500,1200,300,1900,4200]

xxx

Doc values use several tricks like this. In order, the following compression schemes are checked:

  1. If all values are identical (or missing), set a flag and record the value
  2. If there are fewer than 256 values, a simple table encoding is used
  3. If there are > 256 values, check to see if there is a common divisor
  4. If there is no common divisor, encode everything as an offset from the smallest value

You’ll note that these compression schemes are not "traditional" general purpose compression like DEFLATE or LZ4. Because the structure of column-stores are rigid and well-defined, we can achieve higher compression by using specialized schemes rather than the more general compression algorithms like LZ4.

Note

You may be thinking "Well that’s great for numbers, but what about strings?" Strings are encoded similarly, with the help of an ordinal table. The strings are de-duplicated and sorted into a table, assigned an ID, and then those ID’s are used as numeric doc values. Which means strings enjoy many of the same compression benefits that numerics do.

The ordinal table itself has some compression tricks, such as using fixed, variable or prefix-encoded strings.

   

摘自:https://www.elastic.co/guide/en/elasticsearch/guide/current/_deep_dive_on_doc_values.html

















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6401472.html,如需转载请自行联系原作者


相关文章
|
5月前
|
算法
统计一字符串中,重叠字符出现的次数
统计一字符串中,重叠字符出现的次数
44 0
|
7月前
|
算法
算法题 — 整数转二进制,查找其中1的数量
算法题 — 整数转二进制,查找其中1的数量
53 0
|
算法 测试技术 C#
|
存储 机器学习/深度学习
求一个整数存储在内存中的二进制中1的个数;例如15有4个1(三种方法详解)
求一个整数存储在内存中的二进制中1的个数;例如15有4个1(三种方法详解)
144 0
求一个整数存储在内存中的二进制中1的个数;例如15有4个1(三种方法详解)
|
存储 数据库
长整数在插入较短的列时会被转换,但不会被截断为什么?公式是什么?
长整数在插入较短的列时会被转换,但不会被截断为什么?公式是什么?
求两个数二进制中不同位的个数
题目内容:两个int(32)整数m和n的二进制表达中,有多少个位(bit)不同? 输入例子: 1999 2299 输出例子: 7
|
机器学习/深度学习 算法
算法 | 妙法统计二进制中1的个数
二进制(binary),发现者莱布尼茨,是在数学和数字电路中以2为基数的记数系统,是以2为基数代表系统的二进位制。这一系统中,通常用两个不同的符号0(代表零)和1(代表一)来表示。数字电子电路中,逻辑门的实现直接应用了二进制,现代的计算机和依赖计算机的设备里都使用二进制。每个数字称为一个比特(Bit,Binary digit的缩写)
152 0
算法 | 妙法统计二进制中1的个数
|
存储
字符串按照固定长度分割并存储在数组
字符串按照固定长度分割并存储在数组
203 0
|
机器学习/深度学习 算法 Java
四种方式统计二进制表示中 1 的个数
四种方式统计二进制表示中 1 的个数