Created
February 20, 2015 10:55
-
-
Save samklr/0bcd46a3b4cb775206a0 to your computer and use it in GitHub Desktop.
Example of a specific data 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
class AlphabetPartitioner extends Partitioner { | |
def numPartitions = 26 | |
def getPartition(key: Any): Int = key match { | |
case s: String => s(0).toUpper - 'A' | |
} | |
override def equals(other: Any): Boolean = other.isInstanceOf[AlphabetPartitioner] | |
override def hashCode: Int = 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment