Apache mahout 源碼閱讀筆記--DataModel之FileDataModel

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   ar   color   os   使用   

要做推薦,使用者行為資料是基礎。

使用者行為資料有哪些欄位呢?

mahout的DataModel支援,使用者ID,ItemID是必須的,偏好值(使用者對當前Item的評分),時間戳記 這四個欄位

{@code userID,itemID[,preference[,timestamp]]}

mahout資料來源支援從檔案、DB中讀取。

從FileDataModle.java的注釋來看,還是做了不少工作的。

1)原檔案更新後一定的時間段,才會reload

2)支援累加式更新(不用每次都重新copy所有資料)

3)根據欄位數目(有無評分)來選擇不同的結構儲存,節省記憶體

另外,

4)自己實現基礎類型的資料結構,節省記憶體

~/mahout-core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastIDSet.java
~/mahout-core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastByIDMap.java
自己的實現的兩個資料類型,都是通過hash快速尋找, 而且避免java的Long class, 直接採用原生態的long行來節省記憶體空間。
同類型的還有 FastMap.java

 

* <p> * 累加式更新的方式, This class will also look for update "delta" files in the same * directory, with file names that start the same way (up to the first period). * These files have the same format, and provide updated data that supersedes * what is in the main data file. This is a mechanism that allows an application * to push updates to {@link FileDataModel} without re-copying the entire data * file. *  * 同一個目錄下,數字來區分 * Finds update delta files in the same directory as the data file. This finds * any file whose name starts the same way as the data file (up to first period) * but isn‘t the data file itself. For example, if the data file is * /foo/data.txt.gz, you might place update files at /foo/data.1.txt.gz, * /foo/data.2.txt.gz, etc. * </p> * * <p> * 表示刪除的文法, 偏好為空白 One small format difference exists. Update files must also be * able to express deletes. This is done by ending with a blank preference * value, as in "123,456,". * </p> * * <p> * 累加式更新的檔案中,刪除和更新不能混合使用 Note that it‘s all-or-nothing -- all of the items in the * file must express no preference, or the all must. These cannot be mixed. Put * another way there will always be the same number of delimiters on every line * of the file! * </p>

 

FileDataModel封裝了從檔案讀取的功能,具體的儲存還是由GenericDataModel來實現的。

 

 

 

詳細的資料承載有這篇文章,這裡就不多著墨了。

 

Apache mahout 源碼閱讀筆記--DataModel之FileDataModel

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.