《单线程的build hash table、write rows to chunks、hash join的步骤以及流程图》
生活随笔
收集整理的這篇文章主要介紹了
《单线程的build hash table、write rows to chunks、hash join的步骤以及流程图》
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Build Hash Table流程
- 1、初始化row buffer
- 2、從build input table中讀一行
- 3、若讀完build input table所有row,返回狀態READING_ROW_FROM_PROBE_item
- 4、否則,向hash map中寫入一條row
- 5、如果hash map 寫入成功,返回2,繼續執行
- 6、若hash map滿了,則寫chunk file
- 1、初始化chunk file
- 2、將剩余的row寫入chunk file
- 3、返回狀態READING_ROW_FROM_PROBE_item
流程圖如下:
Write Rows to chunks流程
- 1、從input表(build 或者 probe)讀row
- 2、寫入chunk file
- 1、構造join key
- 2、計算hash key并選擇chunk file
- 3、寫入相應的chunk file中
流程圖如下:
單線程hash join 步驟
step1:初始化
- build table init
- memory buffer init
- create hash map
- probe table init
- state 設為 Reading_Row_From_Probe_Iterator
step2:HashJoinIteratorRead,根據state做調整
-
(1)、state為Reading Row from probe iterator
- 1、從probe table read一行row
- 2、如果所有probe input row都讀完了
- 如果非spill to disk,對build input剩余的row構造hash map,重新對probe表做init,回到1繼續
- 如果為spill to disk,goto(2)
- 3、如果build input有chunk file,將probe input表寫入chunk file
- 4、從hash map里查找probe inputrow的查詢結果
- 5、goto(4)
-
(2)、state為Loading next chunk pair
- 找到下一對chunk pair做hash join
-
(3)、state為Reading row from probe input file,讀一個probe chunk的row做hash join
- 1、從probe chunk讀一行row
- 2、在hash table里查詢匹配
- 3、goto(4)
-
(4)、state為Reading from hash table,讀取hash table中匹配記錄
- 1、將查到的row buffer寫入build input表的record[0]中
- 2、若讀取完hash table中記錄,goto(1)或者(3)
狀態流程圖:
總結
以上是生活随笔為你收集整理的《单线程的build hash table、write rows to chunks、hash join的步骤以及流程图》的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《光遇》10.26每日任务过关技巧
- 下一篇: socket编程常见函数使用方法