sqlite variable-length integers 实现方式
来源:互联网 发布:淘宝买百度云怎么搜 编辑:程序博客网 时间:2024/05/16 17:34
网站地址:http://sqlite.org/src4/doc/trunk/www/varint.wiki
这种存储方式的好处在于,
1 可以用比较少的位数来存储比较小的数字(在实际应用中,存储的比较多),而用比较多的位数来存储比较大的数字(在实际应用中,存储的比较少)。
2 长度可以在第一个字节就可以知道
3 编码之后的字节串的排序没改变。一个已经排序好的数组,编码之后,还是排好序的
编码:
- If V<=240 then output a single by A0 equal to V.
- If V<=2287 then output A0 as (V-240)/256 + 241 and A1 as (V-240)%256.
- If V<=67823 then output A0 as 249, A1 as (V-2288)/256, and A2 as (V-2288)%256.
- If V<=16777215 then output A0 as 250 and A1 through A3 as a big-endian 3-byte integer.
- If V<=4294967295 then output A0 as 251 and A1..A4 as a big-ending 4-byte integer.
- If V<=1099511627775 then output A0 as 252 and A1..A5 as a big-ending 5-byte integer.
- If V<=281474976710655 then output A0 as 253 and A1..A6 as a big-ending 6-byte integer.
- If V<=72057594037927935 then output A0 as 254 and A1..A7 as a big-ending 7-byte integer.
- Otherwise then output A0 as 255 and A1..A8 as a big-ending 8-byte integer.
解码
- If A0 is between 0 and 240 inclusive, then the result is the value of A0.
- If A0 is between 241 and 248 inclusive, then the result is 240+256*(A0-241)+A1.
- If A0 is 249 then the result is 2288+256*A1+A2.
- If A0 is 250 then the result is A1..A3 as a 3-byte big-ending integer.
- If A0 is 251 then the result is A1..A4 as a 4-byte big-ending integer.
- If A0 is 252 then the result is A1..A5 as a 5-byte big-ending integer.
- If A0 is 253 then the result is A1..A6 as a 6-byte big-ending integer.
- If A0 is 254 then the result is A1..A7 as a 7-byte big-ending integer.
- If A0 is 255 then the result is A1..A8 as a 8-byte big-ending integer.
位数 最大数字
1240
22287
367823
4224-1
5232-1
6240-1
7248-1
8256-1
9264-1
0 0
- sqlite variable-length integers 实现方式
- variable-length argument lists
- variable length arrays
- 函数参数Variable-length Arguments
- android Sqlite Orm 实现方式
- lots of "GET variable length limit exceeded"
- Learning Perl: 4.6. Variable-Length Parameter Lists
- C中的Variable length arrays (变长数组)
- Editing a variable-length list, Knockout-style
- C#游长变元表(variable-length argument list)
- SQL方式实现SQLite增删改查
- Delphi FireDAC 出现Variable length column[*] overflow. Value length - [80], column maximum length
- ORA-01483: invalid length for DATE or NUMBER bind variable
- Chapel 0.9 -- variable length arguments函数中的参数类型推导
- shell 几中专用修饰符 :- :+ := ${variable:offset:length}
- ORA-01483: invalid length for DATE or NUMBER bind variable
- Parameter \' \': No size set for variable length data type: String
- OSI-VLSM(Variable Length Subnet Mask)可变长子网掩码
- RGBD物体识别(3)--ubuntu安装opencv3和opencv-contrib
- 关于NSIS打包的一些处理
- linux安装boost库
- 如何查看oracle trace 文件
- 【杭电oj】3635 - Dragon Balls(带权并查集,好题)
- sqlite variable-length integers 实现方式
- 观察者模式(浅谈监听器工作原理)
- java--Struts2入门示例教程(五)
- VS2013主题&配色方案
- Mvc与servlet
- 搜索与机器学习
- linux中安装jdk+jmeter-
- docker exec 运行命令
- Android 上传头像