Mysql源碼分析--csv儲存引擎

來源:互聯網
上載者:User

標籤:mmap   返回   blog   public   目的   字元   span   ora   簡單   

一直想分析下mysql的源碼,開始的時候不知道從哪下手,先從csv的檔案儲存體開始吧,這個還是比較簡單的。我是用的是mysql5.7.16版本的源碼。

csv源碼檔案在mysql源碼的mysql-5.7.16\storage\csv檔案夾下,這裡面除了一個make檔案,剩下的四個檔案就是csv的儲存讀取代碼。

transparent_file.h/cc檔案比較簡單,只定義了一個Transparent_file類,目的是從指定的檔案中讀取資料到緩衝中。

class Transparent_file{  File filedes;  uchar *buff;  /* in-memory window to the file or mmaped area */  /* current window sizes */  my_off_t lower_bound;//檔案位移開始位置  my_off_t upper_bound;//檔案位移結束位置  uint buff_size;//快取檔案的長度public:  Transparent_file();  ~Transparent_file();  void init_buff(File filedes_arg);//從檔案中讀取資料到記憶體緩衝中  uchar *ptr();//返回記憶體緩衝指標  my_off_t start();  my_off_t end();  char get_value (my_off_t offset);  my_off_t read_next();//讀取下一段};

1.Transparent_file建構函式,根據buff_size和字元的大小申請了指定長度的空間,只是申請,沒有初始設定檔案中的資料。

2.init_buff函數的作用是從指定檔案中負載檔案內容到緩衝中。

3.read_next從檔案中下一個buff_size長度的內容放到緩衝中,並重寫lower_bound和upper_bound的值。

4.get_value從檔案中讀取指定位置長度為buff_size的資料,放到緩衝中。

未完待續。。。

Mysql源碼分析--csv儲存引擎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.