Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored thin layer around Mahout matrices. Pulled out local mode, …
…only distributed mode against Hadoop cluster now.
- Loading branch information
1 parent
1c31cab
commit 52a59c8
Showing
7 changed files
with
209 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
(ns lsa4solr.hadoop-utils) | ||
(ns lsa4solr.hadoop-utils | ||
(:import (org.apache.mahout.math VectorWritable) | ||
(org.apache.hadoop.io IntWritable) | ||
(org.apache.hadoop.fs FileSystem Path) | ||
(org.apache.hadoop.io SequenceFile$Writer))) | ||
|
||
(defn write-vectors [writer | ||
m] | ||
(doall (map #(.append writer %1 (new org.apache.mahout.math.VectorWritable (.vector %2))) | ||
(map #(new org.apache.hadoop.io.IntWritable %) | ||
(doall (map #(.append writer %1 (VectorWritable. (.vector %2))) | ||
(map #(IntWritable. %) | ||
(range 0 (.numRows m))) | ||
(iterator-seq (.iterator m))))) | ||
|
||
(defn write-matrix [hadoop-conf m path-string] | ||
(let [fs (org.apache.hadoop.fs.FileSystem/get hadoop-conf) | ||
path (new org.apache.hadoop.fs.Path path-string)] | ||
(doto (new org.apache.hadoop.io.SequenceFile$Writer | ||
fs | ||
hadoop-conf | ||
path | ||
org.apache.hadoop.io.IntWritable | ||
org.apache.mahout.math.VectorWritable) | ||
(let [fs (FileSystem/get hadoop-conf) | ||
path (Path. path-string)] | ||
(doto (SequenceFile$Writer. fs | ||
hadoop-conf | ||
path | ||
IntWritable | ||
VectorWritable) | ||
(write-vectors m) | ||
(.close)))) |
Oops, something went wrong.