天天看點

Spark 源碼分析 -- BlockStore

抽象接口類, 關鍵get和put都有兩個版本

序列化, putbytes, getbytes

非序列化, putvalues, getvalues

其中putvalues的傳回值為putresult, 其中的data可能是iterator或bytebuffer

對應diskstore其實很單純, 就是打開相應的檔案讀或寫.

對于memorystore複雜一些

首先使用linkedhashmap, 可周遊的hashmap, 來組織memorystore, 其中的hashmap的結構(blockid, entry)

使用entry抽象來表示block内容

并且在put的時候, 還涉及到memory空間的釋放, ensurefreespace