1. 程式人生 > >TSM檔案格式及例項解析(四)——string的排列

TSM檔案格式及例項解析(四)——string的排列

目錄

引:

資料

簡析

Indexes:

blocks:

關聯string

小結:


TSM檔案格式現已基本明瞭,某些壓縮演算法有空再去研究一下。

引:

現在想知道未壓縮的檔案格式是怎樣。

但是翻遍官方配置文件

https://docs.influxdata.com/influxdb/v1.6/administration/config/#data-settings-data

並沒有設定不壓縮資料的選項。嘗試一下string的排列,在某些情況下(資料簡單,彼此無關聯),這些string的value是簡單length-value結構。 但是做不到多個timestamps不壓縮

資料

言歸正傳,先來一組field 為string的資料

insert cars,brand=bmw,model=x5 location="tianhe",direction="up",weather="sunny"            1535354189281013006
insert cars,brand=bmw,model=x5 location="luogang",direction="down",weather="cloudy"       1535354189281014006
insert cars,brand=bmw,model=x5 location="huangpu",direction="north",weather="rainny"       1535354189281015006
insert cars,brand=bmw,model=x5 location="panyu",direction="west",weather="overcast"     1535354189281016006
insert cars,brand=bmw,model=x5 location="nansha",direction="south",weather="shower"       1535354189281017006
insert cars,brand=bmw,model=x5 location="liwan",direction="east",weather="sleet"        1535354189281018006
insert cars,brand=bmw,model=x5 location="yuexiu",direction="fail",weather="blizzard"     1535354189281019006

TSM檔案格式

 

簡析

按照之前的解析方法

 

 

 

Indexes:

Indexes的起始位置為offset C8處, 0024...

blocks:

 

這三組string的values並沒有被壓縮成肉眼不可見,length-value 表示。

實際上這已經是snappy演算法壓縮後的結果,只是在這三組資料的情況下,是明碼可見的。以後再去研究snappy演算法,弄清楚什麼樣的資料會被壓縮,什麼情況下只是用簡單length-value的形式表示。

 

關聯string

再來一組有關聯的,且很長的string

insert cars,brand=bmw,model=320li position="zhongguoguangdongguangzhoutianhe" 1535354189281020006
insert cars,brand=bmw,model=320li position="zhongguoguangdongguangzhouhuangpu" 1535354189281021006

得到檔案是這樣的

很明顯,string value 是從 10 43開始的

這裡的string肉眼不可見,需要解壓縮後才知道了。

 

小結:

string作為value, 檔案資料格式依舊保持 header, blocks ,indexes,footer這種基本結構。

block中timestamps的儲存還是照舊RLE or s8b.

只有value的部分按照snappy演算法進行壓縮,或壓縮成肉眼不可見,或只是length-value結構。