-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added methods for partitioner (#181)
- Loading branch information
1 parent
56ebd27
commit 38731f7
Showing
4 changed files
with
94 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(ns zero-one.geni.partitioner | ||
(:refer-clojure :exclude [partition]) | ||
(:import | ||
(org.apache.spark HashPartitioner))) | ||
|
||
(defn hash-partitioner [partitions] | ||
(HashPartitioner. partitions)) | ||
|
||
(defn num-partitions [partitioner] | ||
(.numPartitions partitioner)) | ||
|
||
(defn get-partition [partitioner k] | ||
(.getPartition partitioner k)) | ||
|
||
(defn equals [left right] | ||
(.equals left right)) | ||
(def equals? equals) | ||
|
||
(defn hash-code [partitioner] | ||
(.hashCode partitioner)) |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns zero-one.geni.partitioner-test | ||
(:require | ||
[midje.sweet :refer [facts =>]] | ||
[zero-one.geni.partitioner :as partitioner])) | ||
|
||
(facts "On partitioner fields" :rdd | ||
(let [partitioner (partitioner/hash-partitioner 12)] | ||
(partitioner/num-partitions partitioner) => 12 | ||
(partitioner/get-partition partitioner 123) => int? | ||
(partitioner/equals? partitioner partitioner) => true | ||
(partitioner/hash-code partitioner) => int?)) | ||
|
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